Propagate DcUpdateEach setting

This commit is contained in:
9seconds
2026-02-16 15:07:56 +01:00
parent 836a481026
commit 308e372a5d
9 changed files with 22 additions and 12 deletions
+4
View File
@@ -99,6 +99,10 @@ const (
// reads from Telegram after which connection will be terminated. This is
// required to abort stale connections.
TCPRelayReadTimeout = 20 * time.Second
// DefaultDCUpdateEach defines a time period that is used to fetch
// a relevant list of DCs to use from Telegram using its own MTPROTO API.
DefaultDCUpdateEach = time.Hour
)
// Network defines a knowledge how to work with a network. It may sound fun but
+1 -4
View File
@@ -1,7 +1,5 @@
package dc
import "time"
type preferIP uint8
const (
@@ -12,8 +10,7 @@ const (
)
const (
DefaultDC = 2
DefaultUpdateDCAddressesEach = time.Hour
DefaultDC = 2
defaultAppID = 123456
defaultAppHash = ""
-4
View File
@@ -37,10 +37,6 @@ func (t *Telegram) GetAddresses(dc int) []Addr {
}
func (t *Telegram) Run(ctx context.Context, updateEach time.Duration) {
if updateEach == 0 {
updateEach = DefaultUpdateDCAddressesEach
}
t.update(ctx)
ticker := time.NewTicker(updateEach)
+6 -1
View File
@@ -324,7 +324,12 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) {
telegram: tg,
}
go tg.Run(ctx, 0) // TODO: propagate value
dcUpdateEach := opts.DCUpdateEach
if dcUpdateEach == 0 {
dcUpdateEach = DefaultDCUpdateEach
}
go tg.Run(ctx, dcUpdateEach)
pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
func(arg interface{}) {
+4
View File
@@ -119,6 +119,10 @@ type ProxyOpts struct {
//
// This is an optional setting
DCOverrides map[int][]string
// DCUpdateEach defines a time duration that is used to fetch a list of
// DCs to use from the Telegram.
DCUpdateEach time.Duration
}
func (p ProxyOpts) valid() error {