Fallback to another DC if given is unknown

This commit is contained in:
9seconds
2021-09-24 11:47:35 +03:00
parent d0f18be91d
commit fbe4d32590
4 changed files with 44 additions and 1 deletions
+8
View File
@@ -42,6 +42,14 @@ func (t Telegram) Dial(ctx context.Context, dc int) (net.Conn, error) {
return nil, fmt.Errorf("cannot dial to %d dc: %w", dc, err)
}
func (t Telegram) IsKnownDC(dc int) bool {
return t.pool.isValidDC(dc)
}
func (t Telegram) GetFallbackDC() int {
return t.pool.getRandomDC()
}
func New(dialer Dialer, ipPreference string, useTestDCs bool) (*Telegram, error) {
var pref preferIP