mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:54:01 +03:00
Add fetching of addresses from proxyGetConfig endpoint
This commit is contained in:
+20
-13
@@ -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"},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user