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.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Network contains a default implementation of the network.
  2. //
  3. // Please see [mtglib.Network] interface to get some basic idea behind this
  4. // abstraction.
  5. //
  6. // This implementation is more simple that v1 because life shows that all
  7. // this complexity, especially around circuit breakers and DoH is not really
  8. // required. There is no chance that if DNS address is spoofed, that real
  9. // IP would work as expected.
  10. package network
  11. import (
  12. "errors"
  13. "time"
  14. )
  15. const (
  16. // DefaultTimeout is a default timeout for establishing TCP connection.
  17. DefaultTimeout = 10 * time.Second
  18. // DefaultHTTPTimeout defines a default timeout for making HTTP request.
  19. DefaultHTTPTimeout = 10 * time.Second
  20. // DefaultIdleTimeout defines a timeout for idle HTTP connections
  21. DefaultIdleTimeout = time.Minute
  22. // DefaultTCPKeepAlivePeriod defines a time period between 2 consecuitive
  23. // probes.
  24. //
  25. // Deprecated: use DefaultKeepAliveIdle and DefaultKeepAliveInterval instead.
  26. DefaultTCPKeepAlivePeriod = 10 * time.Second
  27. // DefaultKeepAliveIdle is the time a connection must be idle before
  28. // the first keepalive probe is sent.
  29. DefaultKeepAliveIdle = 30 * time.Second
  30. // DefaultKeepAliveInterval is the time between consecutive keepalive
  31. // probes.
  32. DefaultKeepAliveInterval = 10 * time.Second
  33. // DefaultKeepAliveCount is the number of unacknowledged probes before
  34. // the connection is considered dead.
  35. DefaultKeepAliveCount = 3
  36. // User Agent to use in HTTP client.
  37. UserAgent = "curl/8.5.0"
  38. // tcpLingerTimeout defines a number of seconds to wait for sending
  39. // unacknowledged data.
  40. tcpLingerTimeout = 1
  41. )
  42. var ErrCannotDial = errors.New("cannot dial to any address")