Documentation ¶
Index ¶
- Variables
- func GetAddresses(protocol string, l net.Listener) []string
- func GetLocalPeerAddresses(port int) ([]string, error)
- func RandStringBytesMaskImprSrc(n int) string
- func Read(conn *Connection) (*object.Object, error)
- func SendConnectionEvent(outgoing bool)
- func SendEvent(event telemetry.Collectable)
- func SendObjectEvent(direction string, contentType string, objectSize int)
- func Write(o *object.Object, conn *Connection) error
- type Addresses
- type Connection
- type LocalInfo
- func (l *LocalInfo) AddAddress(addrs ...string)
- func (l *LocalInfo) AddContentHash(hashes ...string)
- func (l *LocalInfo) AddIdentityKey(identityKey *crypto.PrivateKey) error
- func (l *LocalInfo) GetFingerprint() crypto.Fingerprint
- func (l *LocalInfo) GetHostname() string
- func (l *LocalInfo) GetPeerInfo() *peer.PeerInfo
- func (l *LocalInfo) GetPeerKey() *crypto.PrivateKey
- func (l *LocalInfo) RemoveContentHash(hashes ...string)
- type Middleware
- type MiddlewareHandler
- type Network
- type Option
- type Options
- type Transport
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrAllAddressesFailed for when a peer cannot be dialed ErrAllAddressesFailed = errors.New("all addresses failed to dial") // ErrNoAddresses for when a peer has no addresses ErrNoAddresses = errors.New("no addresses") // ErrNotForUs object is not meant for us ErrNotForUs = errors.New("object not for us") // ErrMissingKey when a key is not passed ErrMissingKey = errors.New("missing key") // ErrECDSAPrivateKeyRequired when a key is not an ECDSA key ErrECDSAPrivateKeyRequired = errors.New( "network currently requires an ecdsa private key") // ErrNonce is when the nonce does not match ErrNonce = errors.New("nonce does not match") )
View Source
var (
BindLocal = false // TODO(geoah) refactor to remove global
)
View Source
var (
UseUPNP = false
)
Functions ¶
func GetAddresses ¶
GetAddresses returns the addresses the transport is listening to
func GetLocalPeerAddresses ¶
GetLocalPeerAddresses returns the addresses TCP can listen to on the local machine
func RandStringBytesMaskImprSrc ¶
RandStringBytesMaskImprSrc returns a random string given a length
func SendConnectionEvent ¶
func SendConnectionEvent(outgoing bool)
SendConnectionEvent sends a connection event
func SendObjectEvent ¶
SendObjectEvent sends a connection event
Types ¶
type Addresses ¶
func NewAddresses ¶
func NewAddresses() Addresses
type Connection ¶
type Connection struct { RemotePeerKey *crypto.PublicKey IsIncoming bool // contains filtered or unexported fields }
func (*Connection) Close ¶ added in v0.3.2
func (c *Connection) Close() error
type LocalInfo ¶
type LocalInfo struct {
// contains filtered or unexported fields
}
func NewLocalInfo ¶
func NewLocalInfo(hostname string, key *crypto.PrivateKey) ( *LocalInfo, error)
func (*LocalInfo) AddAddress ¶
func (*LocalInfo) AddContentHash ¶
AddContentHash that should be published with the peer info
func (*LocalInfo) AddIdentityKey ¶ added in v0.3.2
func (l *LocalInfo) AddIdentityKey(identityKey *crypto.PrivateKey) error
func (*LocalInfo) GetFingerprint ¶
func (l *LocalInfo) GetFingerprint() crypto.Fingerprint
func (*LocalInfo) GetHostname ¶
func (*LocalInfo) GetPeerInfo ¶
GetPeerInfo returns the local peer info
func (*LocalInfo) GetPeerKey ¶
func (l *LocalInfo) GetPeerKey() *crypto.PrivateKey
func (*LocalInfo) RemoveContentHash ¶
RemoveContentHash from the peer info
type MiddlewareHandler ¶
type MiddlewareHandler func(ctx context.Context, conn *Connection) (*Connection, error)
MiddlewareHandler ...
type Network ¶
type Network interface { Dial(ctx context.Context, address string, options ...Option) (*Connection, error) Listen(ctx context.Context) (chan *Connection, error) AddMiddleware(handler MiddlewareHandler) AddTransport(tag string, tsp Transport) }
Network interface
type Option ¶
type Option func(*Options)
func WithLocalDiscoveryOnly ¶
func WithLocalDiscoveryOnly() Option
type Transport ¶
type Transport interface { Dial(ctx context.Context, address string) (*Connection, error) Listen(ctx context.Context) (chan *Connection, error) }
func NewHTTPTransport ¶ added in v0.3.1
func NewTCPTransport ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.