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文字以内のものにしてください。

init.go 1.3KB

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