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
+10 -1
View File
@@ -207,7 +207,16 @@ func (p *Proxy) doObfuscated2Handshake(ctx *streamContext) error {
}
func (p *Proxy) doTelegramCall(ctx *streamContext) error {
conn, err := p.telegram.Dial(ctx, ctx.dc)
dc := ctx.dc
if !p.telegram.IsKnownDC(dc) {
dc = p.telegram.GetFallbackDC()
ctx.logger = ctx.logger.BindInt("fallback_dc", dc)
ctx.logger.Warning("unknown DC, fallbacks")
}
conn, err := p.telegram.Dial(ctx, dc)
if err != nil {
return fmt.Errorf("cannot dial to Telegram: %w", err)
}