Add fetching of addresses from proxyGetConfig endpoint

This commit is contained in:
9seconds
2026-02-24 12:55:16 +01:00
parent 908842063a
commit 94d46d2c65
11 changed files with 419 additions and 80 deletions
+20 -13
View File
@@ -1,5 +1,10 @@
package dc
import (
"context"
"time"
)
type preferIP uint8
const (
@@ -10,7 +15,18 @@ const (
)
const (
// Default DC to connect to if not sure.
DefaultDC = 2
// How often should we request updates from
// https://core.telegram.org/getProxyConfig
PublicConfigUpdateEach = time.Hour
PublicConfigUpdateURLv4 = "https://core.telegram.org/getProxyConfig"
PublicConfigUpdateURLv6 = "https://core.telegram.org/getProxyConfigV6"
// How often should we extract hosts from Telegram using help.getConfig
// method.
OwnConfigUpdateEach = time.Hour
)
type Logger interface {
@@ -18,6 +34,10 @@ type Logger interface {
WarningError(msg string, err error)
}
type Updater interface {
Run(ctx context.Context)
}
var (
// https://github.com/telegramdesktop/tdesktop/blob/master/Telegram/SourceFiles/mtproto/mtproto_dc_options.cpp#L30
defaultDCAddrSet = dcAddrSet{
@@ -57,17 +77,4 @@ var (
},
},
}
defaultDCOverridesAddrSet = dcAddrSet{
v4: map[int][]Addr{
203: {
{Network: "tcp4", Address: "91.105.192.100:443"},
},
},
v6: map[int][]Addr{
203: {
{Network: "tcp6", Address: "[2a0a:f280:0203:000a:5000:0000:0000:0100]:443"},
},
},
}
)