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
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

init.go 915B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package network
  2. import (
  3. "context"
  4. "errors"
  5. "net"
  6. "net/http"
  7. "time"
  8. )
  9. const (
  10. DefaultTimeout = 10 * time.Second
  11. DefaultIdleTimeout = time.Minute
  12. DefaultHTTPTimeout = 5 * time.Second
  13. DefaultBufferSize = 4096
  14. ProxyDialerOpenThreshold = 5
  15. ProxyDialerHalfOpenTimeout = time.Minute
  16. ProxyDialerResetFailuresTimeout = 10 * time.Second
  17. DefaultDOHHostname = "9.9.9.9"
  18. DNSTimeout = 5 * time.Second
  19. )
  20. var (
  21. ErrCircuitBreakerOpened = errors.New("circuit breaker is opened")
  22. ErrCannotDialWithAllProxies = errors.New("cannot dial with all proxies")
  23. )
  24. type Dialer interface {
  25. Dial(network, address string) (net.Conn, error)
  26. DialContext(ctx context.Context, network, address string) (net.Conn, error)
  27. }
  28. type Network interface {
  29. Dialer
  30. DNSResolve(network, hostname string) (ips []string, err error)
  31. MakeHTTPClient(timeout time.Duration) *http.Client
  32. IdleTimeout() time.Duration
  33. }