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)
- func ToKeyID(key any) ([]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) GetID() []byte
- 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) 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) }
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) 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 ¶
type Gateway struct {
// contains filtered or unexported fields
}
func NewGateway ¶
func NewGateway(key ed25519.PrivateKey) *Gateway
func (*Gateway) GetAddressList ¶
func (*Gateway) RegisterClient ¶
func (*Gateway) SetConnectionHandler ¶
func (*Gateway) SetExternalIP ¶
func (*Gateway) StartClient ¶
func (*Gateway) StartServer ¶
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 ¶
type Peer interface { SetCustomMessageHandler(handler func(msg *MessageCustom) error) SetQueryHandler(handler func(msg *MessageQuery) error) 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 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.