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
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

example.config.toml 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # This is an example of the configuration file for mtg. You actually can
  2. # run mtg with it. It starts a proxy on all interfaces with a secret
  3. # ee367a189aee18fa31c190054efd4a8e9573746f726167652e676f6f676c65617069732e636f6d
  4. #
  5. # It has all possible options with default values. So, a real world
  6. # configuration file should contain only those options you are going to
  7. # use. You do not need to enumerate all of them. In other words, each
  8. # option here has a default value. If you comment a key-value pair, it
  9. # should not make any effect.
  10. #
  11. # stats is the only exception.
  12. # Debug starts application in debug mode. It starts to be quite verbose
  13. # in output. Actually, the idea is that you run it in debug mode only if
  14. # you have any issue.
  15. debug = false
  16. # A secret. Please remember that mtg supports only FakeTLS mode, legacy
  17. # simple and secured mode are prohibited. For you it means that secret
  18. # should either be base64-encoded or starts with ee.
  19. secret = "ee367a189aee18fa31c190054efd4a8e9573746f726167652e676f6f676c65617069732e636f6d"
  20. # Host:port pair to run proxy on.
  21. bind-to = "0.0.0.0:3128"
  22. # Defines how many concurrent connections are allowed to this proxy.
  23. # All other incoming connections are going to be dropped.
  24. concurrency = 8192
  25. # A size of user-space buffer for TCP to use. Since we do 2 connections,
  26. # then we have tcp-buffer * (4 + 2) per each connection: read/write for
  27. # each connection + 2 copy buffers to pump the data between sockets.
  28. tcp-buffer = "4kb"
  29. # Sometimes you want to enforce mtg to use some types of
  30. # IP connectivity to Telegram. We have 4 modes:
  31. # - prefer-ipv6:
  32. # We can use both ipv4 and ipv6 but ipv6 has a preference
  33. # - prefer-ipv4:
  34. # We can use both ipv4 and ipv6 but ipv4 has a preference
  35. # - only-ipv6:
  36. # Only ipv6 connectivity is used
  37. # - only-ipv4:
  38. # Only ipv4 connectivity is used
  39. prefer-ip = "prefer-ipv6"
  40. # FakeTLS uses domain fronting protection. So it needs to know a port to
  41. # access.
  42. cloak-port = 443
  43. # network defines different network-related settings
  44. [network]
  45. # please be aware that mtg needs to do some external requests. For
  46. # example, if you do not pass public ips, it will request your public ip
  47. # address from some external service.
  48. #
  49. # As for 2.0, if you set a public-ip on your own, mtg won't issue any
  50. # network requests except of those required for Telegram.
  51. #
  52. # so, in order of doing them, it needs to do DNS lookup. mtg ignores DNS
  53. # resolver of the operating system and uses DOH instead. This is a host
  54. # it has to access.
  55. #
  56. # By default we use Quad9.
  57. doh-ip = "9.9.9.9"
  58. # mtg can work via proxies (for now, we support only socks5). Proxy
  59. # configuration is done via list. So, you can specify many proxies
  60. # there.
  61. #
  62. # Actually, if you supply an empty list, then no proxies are going to be
  63. # used. If you supply a single proxy, then mtg will use it exclusively.
  64. # If you supply >= 2, then mtg will load balance between them.
  65. #
  66. # If you add an empty string here, this is an equivalent of 'plain network',
  67. # with no proxy usage.
  68. #
  69. # Proxy configuration is done via ordinary URI schema:
  70. #
  71. # socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s
  72. #
  73. # Only socks5 proxy is used. user/password is optional. As you can
  74. # see, you can specify some parameters in GET query. These parameters
  75. # configure circuit breaker.
  76. #
  77. # open_threshold means a number of errors which should happen so we stop
  78. # use a proxy.
  79. #
  80. # half_open_timeout means a time period (in Golang duration notation)
  81. # after which we can retry with this proxy
  82. #
  83. # reset_failures_timeout means a time period when we flush out errors
  84. # when circuit breaker in closed state.
  85. #
  86. # Please see https://docs.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker
  87. # on details about circuit breakers.
  88. proxies = [
  89. # "socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s"
  90. ]
  91. # network timeouts define different settings for timeouts. tcp timeout
  92. # define a global timeout on establishing of network connections. idle
  93. # means a timeout on pumping data between sockset when nothing is
  94. # happening.
  95. #
  96. # please be noticed that handshakes have no timeouts intentionally. You can
  97. # find a reasoning here:
  98. # https://www.ndss-symposium.org/wp-content/uploads/2020/02/23087-paper.pdf
  99. [network.timeout]
  100. tcp = "5s"
  101. http = "10s"
  102. idle = "1m"
  103. # FakeTLS can compare timestamps to prevent probes. Each message has
  104. # encrypted timestamp. So, mtg can compare this timestamp and decide if
  105. # we need to proceed with connection or not.
  106. #
  107. # Please ensure that you have some ntp active on this host. Otherwise,
  108. # you can endup with badly performing proxy.
  109. [defense.time]
  110. # You can enable/disable that. A good idea is always enable.
  111. enabled = true
  112. # Time can be skewed by many reasons. So, this is a time interval
  113. # when message is cosidered as a good one.
  114. allow-skewness = "5s"
  115. # Some countries do active probing on Telegram connections. This technique
  116. # allows to protect from such effort.
  117. #
  118. # mtg has a cache of some connection fingerprints. Actually, first bytes
  119. # of each connection. So, it stores them in some in-memory LRU+TTL cache.
  120. # You can configure this cache here.
  121. [defense.anti-replay]
  122. # You can enable/disable this feature.
  123. enabled = true
  124. # max size of such a cache. Please be aware that this number is
  125. # approximate we try hard to store data quite dense but it is possible
  126. # that we can go over this limit for 10-20% under some conditions and
  127. # architectures.
  128. max-size = "16mb"
  129. # we use stable bloom filters for anti-replay cache. This helps
  130. # to maintain a desired error ratio.
  131. error-rate = 0.0001
  132. # You can protect proxies by using different blocklists. If client has
  133. # ip from the given range, we do not try to do a proper handshake. We
  134. # actually route it to fronting domain. So, this client will never ever
  135. # have a chance to use mtg to access Telegram.
  136. #
  137. # Please remember that blocklists are initialized in async way. So,
  138. # when you start a proxy, blocklists are empty, they are populated and
  139. # processed in backgrounds. An error in any URL is ignored.
  140. [defense.blocklist]
  141. # You can enable/disable this feature.
  142. enabled = true
  143. # This is a limiter for concurrency. In order to protect website
  144. # from overloading, we download files in this number of threads.
  145. download-concurrency = 2
  146. # A list of URLs in FireHOL format (https://iplists.firehol.org/)
  147. # You can provider links here (starts with https:// or http://) or
  148. # path to a local file, but in this case it should be absolute.
  149. urls = [
  150. # "https://iplists.firehol.org/files/firehol_level1.netset",
  151. # "/local.file"
  152. ]
  153. # How often do we need to update a blocklist set.
  154. update-each = "24h"
  155. # statsd statistics integration.
  156. [stats.statsd]
  157. # enabled/disabled
  158. enabled = false
  159. # host:port for UDP endpoint of statsd
  160. address = "127.0.0.1:8888"
  161. # prefix of metric for statsd
  162. metric-prefix = "mtg"
  163. # prometheus metrics integration.
  164. [stats.prometheus]
  165. # enabled/disabled
  166. enabled = true
  167. # host:port where to start http server for endpoint
  168. bind-to = "127.0.0.1:3129"
  169. # prefix of http path
  170. http-path = "/"
  171. # prefix for metrics for prometheus
  172. metric-prefix = "mtg"