package dcs

Import Path
	github.com/gotd/td/telegram/dcs (on go.dev)

Dependency Relation
	imports 24 packages, and imported by 2 packages

Involved Source Files dns.go Package dcs contains Telegram DCs list and some helpers. find.go list.go mtproxy.go plain.go prod.go protocol.go resolver.go resolver_notjs.go test.go websocket.go
Code Examples package main import ( "context" "fmt" "time" "golang.org/x/net/proxy" "github.com/gotd/td/telegram" "github.com/gotd/td/telegram/dcs" ) func main() { // Dial using proxy from environment. // Creating connection. ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() client := telegram.NewClient(1, "appHash", telegram.Options{ Resolver: dcs.Plain(dcs.PlainOptions{Dial: proxy.Dial}), }) _ = client.Run(ctx, func(ctx context.Context) error { fmt.Println("Started") return nil }) } package main import ( "context" "fmt" "time" "golang.org/x/net/proxy" "github.com/gotd/td/telegram" "github.com/gotd/td/telegram/dcs" ) func main() { // Dial using SOCKS5 proxy. sock5, _ := proxy.SOCKS5("tcp", "IP:PORT", &proxy.Auth{ User: "YOURUSERNAME", Password: "YOURPASSWORD", }, proxy.Direct) dc := sock5.(proxy.ContextDialer) // Creating connection. ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() client := telegram.NewClient(1, "appHash", telegram.Options{ Resolver: dcs.Plain(dcs.PlainOptions{ Dial: dc.DialContext, }), }) _ = client.Run(ctx, func(ctx context.Context) error { fmt.Println("Started") return nil }) }
Package-Level Type Names (total 13, in which 8 are exported)
/* sort exporteds by: | */
DialFunc connects to the address on the named network.
DNSConfig is DC connection config obtained from DNS. Date field of HelpConfigSimple. Expires field of HelpConfigSimple. Rules field of HelpConfigSimple. Options returns DC options from this config. func ParseDNSConfig(txt []string) (DNSConfig, error)
List is a list of Telegram DC addresses and domains. Domains map[int]string Options []tg.DCOption Test bool Zero returns true if this List is zero value. func Prod() List func Staging() List func Test() List func Resolver.CDN(ctx context.Context, dc int, list List) (transport.Conn, error) func Resolver.MediaOnly(ctx context.Context, dc int, list List) (transport.Conn, error) func Resolver.Primary(ctx context.Context, dc int, list List) (transport.Conn, error)
MTProxyOptions is MTProxy resolver creation options. Dial specifies the dial function for creating unencrypted TCP connections. If Dial is nil, then the resolver dials using package net. Network to use. Defaults to "tcp" Random source for MTProxy obfuscator. func MTProxy(addr string, secret []byte, opts MTProxyOptions) (Resolver, error)
PlainOptions is plain resolver creation options. Dial specifies the dial function for creating unencrypted TCP connections. If Dial is nil, then the resolver dials using package net. Network to use. Defaults to "tcp". NoObfuscated denotes to filter out TCP Obfuscated Only DCs. PreferIPv6 gives IPv6 DCs higher precedence. Default is to prefer IPv4 DCs over IPv6. Protocol is the transport protocol to use. Defaults to intermediate. Random source for TCPObfuscated DCs. func Plain(opts PlainOptions) Resolver
Protocol is MTProto transport protocol. See https://core.telegram.org/mtproto/mtproto-transports ( Protocol) Codec() transport.Codec ( Protocol) Handshake(conn net.Conn) (transport.Conn, error) github.com/gotd/td/transport.Protocol
Resolver resolves DC and creates transport MTProto connection. ( Resolver) CDN(ctx context.Context, dc int, list List) (transport.Conn, error) ( Resolver) MediaOnly(ctx context.Context, dc int, list List) (transport.Conn, error) ( Resolver) Primary(ctx context.Context, dc int, list List) (transport.Conn, error) func DefaultResolver() Resolver func MTProxy(addr string, secret []byte, opts MTProxyOptions) (Resolver, error) func Plain(opts PlainOptions) Resolver func Websocket(opts WebsocketOptions) Resolver
WebsocketOptions is Websocket resolver creation options. Dialer specifies the websocket dialer. If Dialer is nil, then the resolver dials using websocket.DefaultDialer. Random source for MTProxy obfuscator. func Websocket(opts WebsocketOptions) Resolver
Package-Level Functions (total 12, in which 10 are exported)
DefaultResolver returns default DC resolver for current platform.
FindDCs searches DCs candidates from given config.
FindPrimaryDCs searches new primary DC from given config. Unlike FindDC, it filters CDNs and MediaOnly servers, returns error if not found.
MTProxy creates MTProxy obfuscated DC resolver. See https://core.telegram.org/mtproto/mtproto-transports#transport-obfuscation.
ParseDNSConfig parses tg.HelpConfigSimple from TXT response.
Plain creates plain DC resolver.
Prod returns production DC list.
Staging returns staging DC list. Deprecated: Use Test().
Test returns test DC list.
Websocket creates Websocket DC resolver. See https://core.telegram.org/mtproto/transports#websocket.
Package-Level Variables (only one, which is unexported)