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 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. DefaultBufferSize = 4096
  13. ProxyDialerOpenThreshold = 5
  14. ProxyDialerHalfOpenTimeout = time.Minute
  15. ProxyDialerResetFailuresTimeout = 10 * time.Second
  16. DefaultDOHHostname = "9.9.9.9"
  17. DNSTimeout = 5 * time.Second
  18. HTTPTimeout = 10 * 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 DialFunc func(ctx context.Context, protocol, address string) (net.Conn, error)
  25. type Dialer interface {
  26. Dial(network, address string) (net.Conn, error)
  27. DialContext(ctx context.Context, network, address string) (net.Conn, error)
  28. }
  29. type Network interface {
  30. Dialer
  31. DNSResolve(network, hostname string) (ips []string, err error)
  32. MakeHTTPClient(DialFunc) *http.Client
  33. IdleTimeout() time.Duration
  34. }