|
|
@@ -23,11 +23,12 @@ type Proxy struct {
|
|
23
|
23
|
ctxCancel context.CancelFunc
|
|
24
|
24
|
streamWaitGroup sync.WaitGroup
|
|
25
|
25
|
|
|
26
|
|
- tolerateTimeSkewness time.Duration
|
|
27
|
|
- bufferSize int
|
|
28
|
|
- domainFrontingPort int
|
|
29
|
|
- workerPool *ants.PoolWithFunc
|
|
30
|
|
- telegram *telegram.Telegram
|
|
|
26
|
+ allowFallbackOnUnknownDC bool
|
|
|
27
|
+ tolerateTimeSkewness time.Duration
|
|
|
28
|
+ bufferSize int
|
|
|
29
|
+ domainFrontingPort int
|
|
|
30
|
+ workerPool *ants.PoolWithFunc
|
|
|
31
|
+ telegram *telegram.Telegram
|
|
31
|
32
|
|
|
32
|
33
|
secret Secret
|
|
33
|
34
|
network Network
|
|
|
@@ -209,7 +210,7 @@ func (p *Proxy) doObfuscated2Handshake(ctx *streamContext) error {
|
|
209
|
210
|
func (p *Proxy) doTelegramCall(ctx *streamContext) error {
|
|
210
|
211
|
dc := ctx.dc
|
|
211
|
212
|
|
|
212
|
|
- if !p.telegram.IsKnownDC(dc) {
|
|
|
213
|
+ if p.allowFallbackOnUnknownDC && !p.telegram.IsKnownDC(dc) {
|
|
213
|
214
|
dc = p.telegram.GetFallbackDC()
|
|
214
|
215
|
ctx.logger = ctx.logger.BindInt("fallback_dc", dc)
|
|
215
|
216
|
|
|
|
@@ -285,18 +286,19 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) {
|
|
285
|
286
|
|
|
286
|
287
|
ctx, cancel := context.WithCancel(context.Background())
|
|
287
|
288
|
proxy := &Proxy{
|
|
288
|
|
- ctx: ctx,
|
|
289
|
|
- ctxCancel: cancel,
|
|
290
|
|
- secret: opts.Secret,
|
|
291
|
|
- network: opts.Network,
|
|
292
|
|
- antiReplayCache: opts.AntiReplayCache,
|
|
293
|
|
- ipBlocklist: opts.IPBlocklist,
|
|
294
|
|
- eventStream: opts.EventStream,
|
|
295
|
|
- logger: opts.getLogger("proxy"),
|
|
296
|
|
- domainFrontingPort: opts.getDomainFrontingPort(),
|
|
297
|
|
- tolerateTimeSkewness: opts.getTolerateTimeSkewness(),
|
|
298
|
|
- bufferSize: opts.getBufferSize(),
|
|
299
|
|
- telegram: tg,
|
|
|
289
|
+ ctx: ctx,
|
|
|
290
|
+ ctxCancel: cancel,
|
|
|
291
|
+ secret: opts.Secret,
|
|
|
292
|
+ network: opts.Network,
|
|
|
293
|
+ antiReplayCache: opts.AntiReplayCache,
|
|
|
294
|
+ ipBlocklist: opts.IPBlocklist,
|
|
|
295
|
+ eventStream: opts.EventStream,
|
|
|
296
|
+ logger: opts.getLogger("proxy"),
|
|
|
297
|
+ domainFrontingPort: opts.getDomainFrontingPort(),
|
|
|
298
|
+ tolerateTimeSkewness: opts.getTolerateTimeSkewness(),
|
|
|
299
|
+ bufferSize: opts.getBufferSize(),
|
|
|
300
|
+ allowFallbackOnUnknownDC: opts.AllowFallbackOnUnknownDC,
|
|
|
301
|
+ telegram: tg,
|
|
300
|
302
|
}
|
|
301
|
303
|
|
|
302
|
304
|
pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
|