Documentation ¶
Index ¶
- Variables
- func BuildSharedCipher(key []byte, checksum []byte) (cipher.Stream, error)
- func NewCipherCtr(key, iv []byte) (cipher.Stream, error)
- func SharedKey(ourKey ed25519.PrivateKey, serverKey ed25519.PublicKey) ([]byte, error)
- type ADNL
- func (a *ADNL) Answer(ctx context.Context, queryID []byte, result tl.Serializable) error
- func (a *ADNL) Close()
- func (a *ADNL) GetAddressList() address.List
- func (a *ADNL) GetDisconnectHandler() func(addr string, key ed25519.PublicKey)
- func (a *ADNL) GetID() []byte
- func (a *ADNL) GetQueryHandler() func(msg *MessageQuery) error
- func (a *ADNL) Query(ctx context.Context, req, result tl.Serializable) error
- func (a *ADNL) RemoteAddr() string
- func (a *ADNL) SendCustomMessage(ctx context.Context, req tl.Serializable) error
- func (a *ADNL) SetAddresses(list address.List)
- func (a *ADNL) SetChannelReadyHandler(handler func(ch *Channel))
- func (a *ADNL) SetCustomMessageHandler(handler func(msg *MessageCustom) error)
- func (a *ADNL) SetDisconnectHandler(handler func(addr string, key ed25519.PublicKey))
- func (a *ADNL) SetQueryHandler(handler func(msg *MessageQuery) error)
- type Channel
- type CustomMessageHandler
- type DisconnectHandler
- type Gateway
- func (g *Gateway) Close() error
- func (g *Gateway) GetAddressList() address.List
- func (g *Gateway) GetID() []byte
- func (g *Gateway) RegisterClient(addr string, key ed25519.PublicKey) (Peer, error)
- func (g *Gateway) SetConnectionHandler(handler func(client Peer) error)
- func (g *Gateway) SetExternalIP(ip net.IP)
- func (g *Gateway) StartClient() (err error)
- func (g *Gateway) StartServer(listenAddr string) (err error)
- type MessageAnswer
- type MessageConfirmChannel
- type MessageCreateChannel
- type MessageCustom
- type MessageNop
- type MessagePart
- type MessagePing
- type MessagePong
- type MessageQuery
- type MessageReinit
- type PacketContent
- type Peer
- type PrivateKeyAES
- type PublicKeyAES
- type PublicKeyED25519
- type PublicKeyOverlay
- type PublicKeyUnEnc
- type QueryHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var Dial = func(addr string, timeout time.Duration) (net.Conn, error) { return net.DialTimeout("udp", addr, timeout) }
Dial - can be changed to websockets for example, this way can be used from browser if compiled to wasm
View Source
var ErrTooShortData = errors.New("too short data")
View Source
var Logger = log.Println
View Source
var RawListener = func(addr string) (net.PacketConn, error) { return net.ListenPacket("udp", addr) }
View Source
var ToKeyID = tl.Hash
Deprecated: use tl.Hash
Functions ¶
Types ¶
type ADNL ¶
type ADNL struct {
// contains filtered or unexported fields
}
func Connect ¶
func Connect(ctx context.Context, addr string, peerKey ed25519.PublicKey, ourKey ed25519.PrivateKey) (_ *ADNL, err error)
Connect - connect to ADNL UDP Peer Deprecated: Connect is DEPRECATED use Gateway
func (*ADNL) GetAddressList ¶
func (*ADNL) GetDisconnectHandler ¶ added in v1.9.3
func (*ADNL) GetQueryHandler ¶ added in v1.7.0
func (a *ADNL) GetQueryHandler() func(msg *MessageQuery) error
func (*ADNL) RemoteAddr ¶
func (*ADNL) SendCustomMessage ¶
func (*ADNL) SetAddresses ¶
func (*ADNL) SetChannelReadyHandler ¶
func (*ADNL) SetCustomMessageHandler ¶
func (a *ADNL) SetCustomMessageHandler(handler func(msg *MessageCustom) error)
func (*ADNL) SetDisconnectHandler ¶
func (*ADNL) SetQueryHandler ¶
func (a *ADNL) SetQueryHandler(handler func(msg *MessageQuery) error)
type Channel ¶
type Channel struct {
// contains filtered or unexported fields
}
func (*Channel) SendCustomMessage ¶
type CustomMessageHandler ¶
type CustomMessageHandler func(msg *MessageCustom) error
type DisconnectHandler ¶
type Gateway ¶ added in v1.6.0
type Gateway struct {
// contains filtered or unexported fields
}
func NewGateway ¶ added in v1.6.0
func NewGateway(key ed25519.PrivateKey) *Gateway
func (*Gateway) GetAddressList ¶ added in v1.6.0
func (*Gateway) RegisterClient ¶ added in v1.6.0
func (*Gateway) SetConnectionHandler ¶ added in v1.6.0
func (*Gateway) SetExternalIP ¶ added in v1.6.0
func (*Gateway) StartClient ¶ added in v1.6.0
func (*Gateway) StartServer ¶ added in v1.6.0
type MessageAnswer ¶
type MessageConfirmChannel ¶
type MessageCreateChannel ¶
type MessageCustom ¶
type MessageCustom struct {
Data any `tl:"bytes struct boxed"`
}
type MessageNop ¶
type MessageNop struct{}
type MessagePart ¶
type MessagePing ¶
type MessagePing struct {
Value int64 `tl:"long"`
}
type MessagePong ¶
type MessagePong struct {
Value int64 `tl:"long"`
}
type MessageQuery ¶
type MessageReinit ¶
type MessageReinit struct {
Date int32 `tl:"int"`
}
type PacketContent ¶
type PacketContent struct { Rand1 []byte From *PublicKeyED25519 FromIDShort []byte Messages []any Address *address.List PriorityAddress *address.List Seqno *int64 ConfirmSeqno *int64 RecvAddrListVersion *int32 RecvPriorityAddrListVersion *int32 ReinitDate *int32 DstReinitDate *int32 Signature []byte Rand2 []byte }
func (*PacketContent) Serialize ¶
func (p *PacketContent) Serialize() ([]byte, error)
type Peer ¶ added in v1.6.0
type Peer interface { SetCustomMessageHandler(handler func(msg *MessageCustom) error) SetQueryHandler(handler func(msg *MessageQuery) error) GetDisconnectHandler() func(addr string, key ed25519.PublicKey) SetDisconnectHandler(handler func(addr string, key ed25519.PublicKey)) SendCustomMessage(ctx context.Context, req tl.Serializable) error Query(ctx context.Context, req, result tl.Serializable) error Answer(ctx context.Context, queryID []byte, result tl.Serializable) error GetQueryHandler() func(msg *MessageQuery) error RemoteAddr() string GetID() []byte Close() }
type PrivateKeyAES ¶
type PrivateKeyAES struct {
Key []byte `tl:"int256"`
}
type PublicKeyAES ¶
type PublicKeyAES struct {
Key []byte `tl:"int256"`
}
type PublicKeyED25519 ¶
type PublicKeyOverlay ¶
type PublicKeyOverlay struct {
Key []byte `tl:"bytes"`
}
type PublicKeyUnEnc ¶
type PublicKeyUnEnc struct {
Key []byte `tl:"bytes"`
}
type QueryHandler ¶
type QueryHandler func(msg *MessageQuery) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.