Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram. If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738
  1. package doppel
  2. import (
  3. "context"
  4. "net/http"
  5. "time"
  6. "github.com/9seconds/mtg/v2/essentials"
  7. "github.com/9seconds/mtg/v2/mtglib/internal/tls"
  8. )
  9. const (
  10. // Please see Stats description
  11. // https://blog.cloudflare.com/optimizing-tls-over-tcp-to-reduce-latency/
  12. // https://github.com/cloudflare/sslconfig/blob/master/patches/nginx__dynamic_tls_records.patch
  13. TLSRecordSizeStart = 1369
  14. TLSRecordSizeAccel = 4229
  15. TLSRecordSizeMax = 16384 - tls.SizeHeader
  16. TLSCounterAccelAfter = 40
  17. TLSCounterMaxAfter = TLSCounterAccelAfter + 20
  18. TLSRecordSizeResetAfter = time.Second
  19. )
  20. // copypasted from mtglib
  21. type Network interface {
  22. // Dial establishes context-free TCP connections.
  23. Dial(network, address string) (essentials.Conn, error)
  24. // DialContext dials using a context. This is a preferrable way of
  25. // establishing TCP connections.
  26. DialContext(ctx context.Context, network, address string) (essentials.Conn, error)
  27. // MakeHTTPClient build an HTTP client with given dial function. If nothing is
  28. // provided, then DialContext of this interface is going to be used.
  29. MakeHTTPClient(func(ctx context.Context, network, address string) (essentials.Conn, error)) *http.Client
  30. }