Documentation
¶
Index ¶
- Constants
- Variables
- func IsDisabledChannel(chType ChannelType) bool
- type AddrInfo
- type ChannelType
- type Config
- type IntAlias
- type IntAliases
- type Logger
- type MessageConfig
- type MessageIntAlias
- type MessagePing
- func (ping *MessagePing) Bytes() []byte
- func (ping *MessagePing) Read(b []byte) error
- func (ping *MessagePing) ReadFrom(reader io.Reader) error
- func (ping *MessagePing) SignSender(privKey ed25519.PrivateKey) (err error)
- func (ping *MessagePing) VerifySender(pubKey ed25519.PublicKey) (err error)
- func (ping *MessagePing) Write(b []byte) error
- func (ping *MessagePing) WriteTo(writer io.Writer) error
- type MessagePingData
- type MessagePong
- func (pong *MessagePong) Bytes() []byte
- func (pong *MessagePong) Read(b []byte) error
- func (pong *MessagePong) SignRecipient(privKey ed25519.PrivateKey) (err error)
- func (pong *MessagePong) VerifyRecipient(pubKey ed25519.PublicKey) (err error)
- func (pong *MessagePong) Write(b []byte) error
- func (pong *MessagePong) WriteTo(writer io.Writer) error
- type MessagePongData
- type MessageType
- type Peer
- func (peer *Peer) Close() (err error)
- func (peer *Peer) CloseIPFS() (err error)
- func (peer *Peer) GetID() peer.ID
- func (peer *Peer) GetIPFSControlStream() (result Stream)
- func (peer *Peer) GetIPFSForwarderStream() (result Stream)
- func (peer *Peer) GetOptimalChannel(chTypes ...ChannelType) (optimalChannelType ChannelType)
- func (peer *Peer) GetPublicKey() ed25519.PublicKey
- func (peer *Peer) GetRemoteRealIP(chType ChannelType) (result net.IP)
- func (peer *Peer) LockDo(fn func())
- func (peer *Peer) NewIncomingStream(stream Stream, peerAddr AddrInfo) (err error)
- func (peer *Peer) RLockDo(fn func())
- func (peer *Peer) SendPing(chType ChannelType) (err error)
- func (peer *Peer) SetIPFSControlStream(stream Stream) (err error)
- func (peer *Peer) SetIPFSForwarderStream(stream Stream, isOutgoing bool)
- func (peer *Peer) SetIntAlias(newIntAlias IntAlias)
- func (peer *Peer) SetSimpleTunnelConn(conn net.Conn)
- func (peer *Peer) Start()
- func (peer *Peer) StartChannel(chType ChannelType)
- func (peer *Peer) SwitchDirectChannelToPathOfChannel(chType ChannelType)
- type PeerConfig
- type Peers
- type Stream
- type TrustConfig
- type UpperHandler
- type VPN
- func (vpn *VPN) AddUpperHandler(upperHandler UpperHandler)
- func (vpn *VPN) Close() (err error)
- func (vpn *VPN) ConsiderKnownPeer(peerAddr AddrInfo)
- func (vpn *VPN) GetIP(intAlias uint64, chType ChannelType) (resultIP net.IP, err error)
- func (vpn *VPN) GetIntAlias() (r IntAlias)
- func (vpn *VPN) GetMyIP(chType ChannelType) (net.IP, error)
- func (vpn *VPN) GetNetworkMaximalSize() uint64
- func (vpn *VPN) GetNetworkSize() (result uint64)
- func (vpn *VPN) GetOrCreatePeerByID(peerID peer.ID) (result *Peer)
- func (vpn *VPN) GetPSK() (r []byte)
- func (vpn *VPN) GetPublicKey() ed25519.PublicKey
- func (vpn *VPN) IsBadAddress(maddr multiaddr.Multiaddr) bool
- func (vpn *VPN) IsStarted() bool
- func (vpn *VPN) LoadConfig() (err error)
- func (vpn *VPN) LockDo(fn func())
- func (vpn *VPN) NewIncomingStream(stream Stream, peerAddr AddrInfo)
- func (vpn *VPN) OnPeerConnect(peerID peer.ID)
- func (vpn *VPN) PrivKey() (r ed25519.PrivateKey)
- func (vpn *VPN) ProtocolID() protocol.ID
- func (vpn *VPN) RLockDo(fn func())
- func (vpn *VPN) ReconnectToPeer(peerID peer.ID)
- func (vpn *VPN) SaveConfig() (err error)
- func (vpn *VPN) SetID(newID peer.ID)
- func (vpn *VPN) SetIntAlias(newValue uint64) (err error)
- func (vpn *VPN) SetMyAddrs(addrs []multiaddr.Multiaddr)
- func (vpn *VPN) SetNetwork(mesh *network.Network)
- func (vpn *VPN) SetPSK(psk []byte)
- func (vpn *VPN) SetPrivateKey(privKey ed25519.PrivateKey)
- func (vpn *VPN) Start() (err error)
- func (vpn *VPN) UpdateWireGuardConfiguration()
- type WGNet
Constants ¶
View Source
const ( ChannelType_undefined = ChannelType(iota) ChannelTypeDirect ChannelTypeIPFS ChannelTypeTunnel ChannelType_max ChannelTypeAutoRouted )
View Source
const ( MessageTypeUndefined = MessageType(iota) MessageTypePing MessageTypePong MessageTypeIntAlias MessageTypeEnscapsulated MessageTypeConfig )
View Source
const ( TopicUpdateSimpleTunnelPort = `vpn.update_simple_tunnel_port` TopicRequestSimpleTunnelPort = `vpn.request_simple_tunnel_port` TopicUpdateDirectPort = `vpn.update_direct_port` TopicRequestDirectPort = `vpn.request_direct_port` )
View Source
const (
PeerIDSize = 38
)
Variables ¶
View Source
var ( ErrUnknownMessageType = e.New("unknown message type") ErrMessageTooShort = e.New(`message is too short`) ErrMessageFragmented = e.New(`message was fragmented`) ErrInvalidSize = e.New(`invalid size`) ErrNegativeRTT = e.New(`negative RTT`) ErrWriterIsNil = e.New(`writer is nil`) ErrUnexpectedCount = e.New(`unexpected count`) )
View Source
var ( ErrAlreadyClosed = e.New(`already closed`) ErrAlreadyStarted = e.New(`already started`) ErrWrongMessageLength = e.New(`wrong message length`) ErrInvalidPeerID = e.New(`invalid peer ID`) )
View Source
var ( ChannelTypes = []ChannelType{ ChannelTypeDirect, ChannelTypeIPFS, ChannelTypeTunnel, } )
View Source
var (
ErrInvalidSignature = e.New(`invalid signature`)
)
Functions ¶
func IsDisabledChannel ¶
func IsDisabledChannel(chType ChannelType) bool
Types ¶
type ChannelType ¶
type ChannelType uint8
func (ChannelType) String ¶
func (chType ChannelType) String() string
type Config ¶
type IntAlias ¶
type IntAliases ¶
type IntAliases []*IntAlias
func (*IntAliases) Marshal ¶
func (aliases *IntAliases) Marshal() ([]byte, error)
func (*IntAliases) Unmarshal ¶
func (aliases *IntAliases) Unmarshal(b []byte) error
type MessageConfig ¶
type MessageIntAlias ¶
type MessageIntAlias struct { PeerID [PeerIDSize]byte Value uint64 MaxNetworkSize uint64 Timestamp int64 Since int64 Index int32 Count int32 }
func (*MessageIntAlias) FillFrom ¶
func (msg *MessageIntAlias) FillFrom(intAlias *IntAlias) (err error)
func (*MessageIntAlias) FillTo ¶
func (msg *MessageIntAlias) FillTo(intAlias *IntAlias) (err error)
func (*MessageIntAlias) Read ¶
func (msg *MessageIntAlias) Read(b []byte) error
func (*MessageIntAlias) Write ¶
func (msg *MessageIntAlias) Write(b []byte) error
type MessagePing ¶
type MessagePing struct { MessagePingData SenderSignature [ed25519.SignatureSize]byte }
func (*MessagePing) Bytes ¶
func (ping *MessagePing) Bytes() []byte
func (*MessagePing) Read ¶
func (ping *MessagePing) Read(b []byte) error
func (*MessagePing) SignSender ¶
func (ping *MessagePing) SignSender(privKey ed25519.PrivateKey) (err error)
func (*MessagePing) VerifySender ¶
func (ping *MessagePing) VerifySender(pubKey ed25519.PublicKey) (err error)
func (*MessagePing) Write ¶
func (ping *MessagePing) Write(b []byte) error
type MessagePingData ¶
func (*MessagePingData) Bytes ¶
func (pingData *MessagePingData) Bytes() []byte
func (*MessagePingData) Write ¶
func (pingData *MessagePingData) Write(b []byte) error
type MessagePong ¶
type MessagePong struct { MessagePongData RecipientSignature [ed25519.SignatureSize]byte }
func (*MessagePong) Bytes ¶
func (pong *MessagePong) Bytes() []byte
func (*MessagePong) Read ¶
func (pong *MessagePong) Read(b []byte) error
func (*MessagePong) SignRecipient ¶
func (pong *MessagePong) SignRecipient(privKey ed25519.PrivateKey) (err error)
func (*MessagePong) VerifyRecipient ¶
func (pong *MessagePong) VerifyRecipient(pubKey ed25519.PublicKey) (err error)
func (*MessagePong) Write ¶
func (pong *MessagePong) Write(b []byte) error
type MessagePongData ¶
type MessagePongData struct { MessagePing ReceiveTS int64 SendTS int64 }
func (*MessagePongData) Bytes ¶
func (pongData *MessagePongData) Bytes() []byte
type MessageType ¶
type MessageType uint16
func ReadMessageType ¶
func ReadMessageType(b []byte) MessageType
func (MessageType) String ¶
func (t MessageType) String() string
type Peer ¶
type Peer struct { ID peer.ID VPN *VPN IntAlias IntAlias DirectAddr *net.UDPAddr IPFSControlStream Stream IPFSForwarderStream Stream IPFSTunnelAddrToWG *net.UDPAddr IPFSTunnelConnToWG *net.UDPConn SimpleTunnelConn net.Conn SimpleTunnelConnToWG *net.UDPConn SimpleTunnelAddrToWG *net.UDPAddr IsTrusted TrustConfig WgPubKey wgtypes.Key LastSuccessfulPingTS atomic.Value LastSuccessfulIPFSPingTS atomic.Value // contains filtered or unexported fields }
func (*Peer) GetIPFSControlStream ¶
func (*Peer) GetIPFSForwarderStream ¶
func (*Peer) GetOptimalChannel ¶
func (peer *Peer) GetOptimalChannel(chTypes ...ChannelType) (optimalChannelType ChannelType)
func (*Peer) GetPublicKey ¶
func (*Peer) GetRemoteRealIP ¶
func (peer *Peer) GetRemoteRealIP(chType ChannelType) (result net.IP)
func (*Peer) NewIncomingStream ¶
func (*Peer) SendPing ¶
func (peer *Peer) SendPing(chType ChannelType) (err error)
func (*Peer) SetIPFSControlStream ¶
func (*Peer) SetIPFSForwarderStream ¶
func (*Peer) SetIntAlias ¶
func (*Peer) SetSimpleTunnelConn ¶
func (*Peer) StartChannel ¶
func (peer *Peer) StartChannel(chType ChannelType)
func (*Peer) SwitchDirectChannelToPathOfChannel ¶
func (peer *Peer) SwitchDirectChannelToPathOfChannel(chType ChannelType)
type PeerConfig ¶
type Peers ¶
type Peers []*Peer
func (Peers) ToWireGuardConfigs ¶
func (peers Peers) ToWireGuardConfigs(chType ChannelType) (result []wgtypes.PeerConfig, err error)
type TrustConfig ¶
type TrustConfig struct {
Routing bool
}
type UpperHandler ¶
type UpperHandler interface { OnUpdateMyIP(ip net.IP) OnNewRoute(peerID peer.ID, chType ChannelType, ip net.IP) OnRemoveRoute(peerID peer.ID, chType ChannelType) }
type VPN ¶
type VPN struct { Config // contains filtered or unexported fields }
func (*VPN) AddUpperHandler ¶
func (vpn *VPN) AddUpperHandler(upperHandler UpperHandler)
func (*VPN) ConsiderKnownPeer ¶
func (*VPN) GetIntAlias ¶
func (*VPN) GetNetworkMaximalSize ¶
func (*VPN) GetNetworkSize ¶
func (*VPN) GetOrCreatePeerByID ¶
func (*VPN) GetPublicKey ¶
func (*VPN) IsBadAddress ¶
func (*VPN) LoadConfig ¶
func (*VPN) NewIncomingStream ¶
func (*VPN) OnPeerConnect ¶
func (*VPN) PrivKey ¶
func (vpn *VPN) PrivKey() (r ed25519.PrivateKey)
func (*VPN) ProtocolID ¶
func (*VPN) ReconnectToPeer ¶
func (*VPN) SaveConfig ¶
func (*VPN) SetIntAlias ¶
func (*VPN) SetMyAddrs ¶
func (vpn *VPN) SetMyAddrs(addrs []multiaddr.Multiaddr)
func (*VPN) SetNetwork ¶
func (*VPN) SetPrivateKey ¶
func (vpn *VPN) SetPrivateKey(privKey ed25519.PrivateKey)
func (*VPN) UpdateWireGuardConfiguration ¶
func (vpn *VPN) UpdateWireGuardConfiguration()
Source Files
¶
Click to show internal directories.
Click to hide internal directories.