Documentation
¶
Index ¶
- Constants
- Variables
- func CallRpcEndpoint(e string, p interface{}) (res interface{}, err error)
- func Custom(v uint16) uint16
- func EnsureDir(c string) error
- func SetCustomHandler(pc uint16, h CustomHandler)
- func SetRpcEndpoint(e string, f RpcEndpoint)
- func TlsProtocols() []string
- func UniqueTimestamp() uint64
- type Agent
- func (a *Agent) AddService(service string) chan net.Conn
- func (a *Agent) AllRPC(ctx context.Context, endpoint string, data interface{}) ([]interface{}, error)
- func (a *Agent) AnyRpc(ctx context.Context, division string, endpoint string, data interface{}) error
- func (a *Agent) BroadcastPacket(ctx context.Context, pc uint16, data []byte) error
- func (a *Agent) BroadcastRpc(ctx context.Context, endpoint string, data interface{}) error
- func (a *Agent) CacheDir() string
- func (a *Agent) Close()
- func (a *Agent) ConfigureTlsServer(cfg *tls.Config)
- func (a *Agent) Connect(id string, service string) (net.Conn, error)
- func (a *Agent) CountPeers() int
- func (a *Agent) DbGet(key string) ([]byte, error)
- func (a *Agent) DbSet(key string, value []byte) error
- func (a *Agent) DbWatch(key string, cb func(string, []byte))
- func (a *Agent) DebugLocks(w io.Writer)
- func (a *Agent) Dial(network, addr string) (net.Conn, error)
- func (a *Agent) DialContext(c context.Context, network, addr string) (net.Conn, error)
- func (a *Agent) DivisionPrefixRpc(ctx context.Context, divMatch string, endpoint string, data interface{}) error
- func (a *Agent) DivisionRpc(ctx context.Context, division int, endpoint string, data interface{}) error
- func (a *Agent) DumpInfo(w io.Writer)
- func (a *Agent) GenInternalCert() (tls.Certificate, error)
- func (a *Agent) GetCA() (*x509.CertPool, error)
- func (a *Agent) GetClientTlsConfig() (*tls.Config, error)
- func (a *Agent) GetInternalCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (a *Agent) GetInternalTlsConfig() (*tls.Config, error)
- func (a *Agent) GetPeer(id string) *Peer
- func (a *Agent) GetPeerByName(name string) *Peer
- func (a *Agent) GetPeers() []*Peer
- func (a *Agent) GetPeersCount() uint32
- func (a *Agent) GetPublicCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (a *Agent) GetTlsConfig() (*tls.Config, error)
- func (a *Agent) Id() string
- func (a *Agent) IsConnected(id string) bool
- func (a *Agent) KeyShake128(N []byte) (sha3.ShakeHash, error)
- func (a *Agent) KeyShake256(N []byte) (sha3.ShakeHash, error)
- func (a *Agent) Lock(ctx context.Context, name string) (*LocalLock, error)
- func (a *Agent) LogDmesg(w io.Writer) (int64, error)
- func (a *Agent) LogTarget() io.Writer
- func (a *Agent) MetaSet(key string, value interface{})
- func (a *Agent) Name() (string, string)
- func (a *Agent) NewDbCursor(bucket []byte) (*DbCursor, error)
- func (a *Agent) RPC(ctx context.Context, id string, endpoint string, data interface{}) (interface{}, error)
- func (a *Agent) RoundTripper() http.RoundTripper
- func (a *Agent) SeedCrypt(in []byte) ([]byte, error)
- func (a *Agent) SeedDecrypt(in []byte) ([]byte, error)
- func (a *Agent) SeedId() uuid.UUID
- func (a *Agent) SeedShake128(N []byte) sha3.ShakeHash
- func (a *Agent) SeedShake256(N []byte) sha3.ShakeHash
- func (a *Agent) SeedSign(in []byte) []byte
- func (a *Agent) SeedTlsConfig(c *tls.Config)
- func (a *Agent) SendPacketTo(ctx context.Context, target string, pc uint16, data []byte) error
- func (a *Agent) SendTo(ctx context.Context, target string, pkt interface{}) error
- type AgentOption
- type CustomHandler
- type DbCursor
- type DbStamp
- func (t DbStamp) After(t2 DbStamp) bool
- func (t DbStamp) Bytes() []byte
- func (t *DbStamp) GobDecode(data []byte) error
- func (t DbStamp) GobEncode() ([]byte, error)
- func (t DbStamp) MarshalBinary() ([]byte, error)
- func (t DbStamp) String() string
- func (t DbStamp) Unix() int64
- func (t DbStamp) UnixNano() int64
- func (t *DbStamp) UnmarshalBinary(data []byte) error
- type DbWatchCallback
- type GetFileFunc
- type LocalLock
- type OptionListener
- type OptionPort
- type Packet
- type PacketAnnounce
- type PacketDbRecord
- type PacketDbRequest
- type PacketDbVersions
- type PacketDbVersionsEntry
- type PacketHandshake
- type PacketRpc
- type PacketRpcResponse
- type PacketSeed
- type Peer
- func (p *Peer) Agent() *Agent
- func (p *Peer) Close(reason string) error
- func (p *Peer) Division() string
- func (p *Peer) Id() string
- func (p *Peer) Meta() map[string]interface{}
- func (p *Peer) Name() string
- func (p *Peer) Send(ctx context.Context, pkt Packet) error
- func (p *Peer) String() string
- func (p *Peer) WritePacket(ctx context.Context, pc uint16, data []byte) error
- type RpcEndpoint
- type ServiceConn
Constants ¶
const ( PacketMaxLen = 32 * 1024 * 1024 // 32MB PacketHeaderSize = 6 // 2 bytes packet code, 4 bytes packet length PacketMaxBody = PacketMaxLen - PacketHeaderSize PacketLegacy = 0xffff // legacy gob-encoded packet PacketPing = 0x1001 PacketPong = 0x3001 PacketLockReq = 0x1002 // request for lock PacketLockRes = 0x3002 // response (aye or nay) PacketLockConfirm = 0x1003 // lock is confirmed (or re-confirmed) → status = 1 PacketLockRelease = 0x1004 // lock is released PacketClose = 0x1fff PacketCustom = 0xa000 // 0xa000 ~ 0xafff are custom channels PacketCustomMax = 0xafff Aye = 1 Nay = 0 )
const UUID_SEEDID_SPACE = "da736663-83ec-46ef-9c29-3f9102c5c519"
Variables ¶
var ( ErrWriteQueueFull = errors.New("peer write queue is full") ErrPeerNoRoute = errors.New("no route to peer") ErrConnectionClosed = errors.New("connection has been closed") ErrInvalidLegacy = errors.New("invalid operation on legacy peer") ErrInvalidLockName = errors.New("invalid lock name") ErrCancelledLock = errors.New("lock request has been cancelled") )
Functions ¶
func CallRpcEndpoint ¶ added in v0.3.23
CallRpcEndpoint will call the named RPC endpoint on the local machine
func Custom ¶ added in v0.5.12
Custom returns a packet id for a given custom packet Typically you will define your custom packet as follow:
var MyCustomPacket = fleet.Custom(0)
func SetCustomHandler ¶ added in v0.5.12
func SetCustomHandler(pc uint16, h CustomHandler)
func SetRpcEndpoint ¶
func SetRpcEndpoint(e string, f RpcEndpoint)
func TlsProtocols ¶ added in v0.6.12
func TlsProtocols() []string
TlsProtocols returns a list of TLS protocols managed by the fleet system that should be directed to the fleet agent listener
func UniqueTimestamp ¶ added in v0.6.15
func UniqueTimestamp() uint64
UniqueTimestamp returns a uint64 timestamp in microsecond that is unique, so that even if called multiple times in the same millisecond each call will return a different value.
This can be safely called from multiple threads, it does not lock.
Types ¶
type Agent ¶
type Agent struct { IP string // ip as seen from outside // getfile callback GetFile GetFileFunc // contains filtered or unexported fields }
func New ¶ added in v0.5.0
func New(opts ...AgentOption) *Agent
New will just initialize a basic agent without any settings
func Self ¶ added in v0.5.0
func Self() *Agent
Self returns the Agent instance returned by New() (or similar), and will wait if instance has not been instanciated yet. As such, Self() should not be used in func init(), but only in separate goroutines or after instance has been created.
func WithGetFile ¶ added in v0.5.0
func WithGetFile(f GetFileFunc) *Agent
return a new agent using the provided GetFile method
func WithIssuer ¶ added in v0.5.0
func (*Agent) BroadcastPacket ¶ added in v0.5.12
func (*Agent) BroadcastRpc ¶ added in v0.5.0
func (*Agent) ConfigureTlsServer ¶ added in v0.5.0
func (*Agent) Connect ¶ added in v0.5.0
connect to given peer under specified protocol (if supported)
func (*Agent) CountPeers ¶ added in v0.6.8
func (*Agent) DbWatch ¶ added in v0.5.0
DbWatch will trigger the cb function upon updates of the given key Special key "*" covers all keys (can only be one callback for a key)
func (*Agent) DebugLocks ¶ added in v0.6.21
func (*Agent) DialContext ¶ added in v0.5.0
func (*Agent) DivisionPrefixRpc ¶ added in v0.5.0
func (*Agent) DivisionRpc ¶ added in v0.5.0
func (*Agent) GenInternalCert ¶ added in v0.5.0
func (a *Agent) GenInternalCert() (tls.Certificate, error)
func (*Agent) GetClientTlsConfig ¶ added in v0.5.0
func (*Agent) GetInternalCertificate ¶ added in v0.7.0
func (a *Agent) GetInternalCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error)
return internal certificate (cached)
func (*Agent) GetInternalTlsConfig ¶ added in v0.5.11
func (*Agent) GetPeerByName ¶ added in v0.5.0
func (*Agent) GetPeersCount ¶ added in v0.6.12
GetPeersCount return the number of existing peers, connected or not. The value may be more than the number of entries GetPeers will return as some peers may be down or unavailable.
func (*Agent) GetPublicCertificate ¶ added in v0.7.0
func (a *Agent) GetPublicCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error)
func (*Agent) GetTlsConfig ¶ added in v0.5.0
GetTlsConfig returns TLS config suitable for making public facing ssl servers.
func (*Agent) IsConnected ¶ added in v0.5.0
func (*Agent) KeyShake128 ¶ added in v0.5.4
KeyShake128 uses PKCS8 private key blob as hash key
func (*Agent) KeyShake256 ¶ added in v0.5.4
KeySha256 uses PKCS8 private key blob as hash key
func (*Agent) NewDbCursor ¶ added in v0.5.0
func (*Agent) RoundTripper ¶ added in v0.5.0
func (a *Agent) RoundTripper() http.RoundTripper
func (*Agent) SeedTlsConfig ¶ added in v0.5.0
func (*Agent) SendPacketTo ¶ added in v0.5.12
type AgentOption ¶ added in v0.6.12
type AgentOption interface {
// contains filtered or unexported methods
}
type CustomHandler ¶ added in v0.5.12
type DbWatchCallback ¶ added in v0.3.16
type LocalLock ¶ added in v0.6.12
type LocalLock struct {
// contains filtered or unexported fields
}
type OptionListener ¶ added in v0.6.12
type OptionPort ¶ added in v0.6.12
type OptionPort int
type PacketAnnounce ¶
type PacketDbRecord ¶
type PacketDbRequest ¶ added in v0.3.14
type PacketDbRequest struct { TargetId string SourceId string Bucket []byte // typically "app" Key []byte }
PacketDbRequest requests a specific record, response will be a PacketDbRecord
type PacketDbVersions ¶ added in v0.3.14
type PacketDbVersions struct {
Info []*PacketDbVersionsEntry
}
PacketDbVersions signals what records are available in a peer, typically sent on connection established
type PacketDbVersionsEntry ¶ added in v0.3.14
type PacketHandshake ¶
type PacketRpcResponse ¶
type PacketSeed ¶
type Peer ¶
type RpcEndpoint ¶
type RpcEndpoint func(interface{}) (interface{}, error)
type ServiceConn ¶
embed connection in a separate object to avoid confusing go's HTTP server (among other stuff)