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
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

example.config.toml 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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 = true
  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. # This defines what types of traffic mtg listens to. If you are not sure,
  23. # then definitely keep it disable. Enable it only and only if incoming traffic
  24. # is coming from some sort of load-balancer like HAProxy or ELB.
  25. # https://www.haproxy.org/download/2.3/doc/proxy-protocol.txt
  26. #
  27. # mtg uses a library that supports v1 and v2 versions of ProxyProtocol.
  28. # default value is false.
  29. # proxy-protocol-listener = false
  30. # Defines how many concurrent connections are allowed to this proxy.
  31. # All other incoming connections are going to be dropped.
  32. concurrency = 8192
  33. # A size of user-space buffer for TCP to use. Since we do 2 connections,
  34. # then we have tcp-buffer * (4 + 2) per each connection: read/write for
  35. # each connection + 2 copy buffers to pump the data between sockets.
  36. #
  37. # Deprecated: this setting is no longer makes any effect.
  38. # tcp-buffer = "4kb"
  39. # Sometimes you want to enforce mtg to use some types of
  40. # IP connectivity to Telegram. We have 4 modes:
  41. # - prefer-ipv6:
  42. # We can use both ipv4 and ipv6 but ipv6 has a preference
  43. # - prefer-ipv4:
  44. # We can use both ipv4 and ipv6 but ipv4 has a preference
  45. # - only-ipv6:
  46. # Only ipv6 connectivity is used
  47. # - only-ipv4:
  48. # Only ipv4 connectivity is used
  49. prefer-ip = "prefer-ipv6"
  50. # FakeTLS uses domain fronting protection. So it needs to know a port to
  51. # access.
  52. domain-fronting-port = 443
  53. # FakeTLS can compare timestamps to prevent probes. Each message has
  54. # encrypted timestamp. So, mtg can compare this timestamp and decide if
  55. # we need to proceed with connection or not.
  56. #
  57. # Sometimes time can be skewed so we accept all messages within a
  58. # time range of this parameter.
  59. tolerate-time-skewness = "5s"
  60. # Telegram has a concept of DC. You can think about DC as a number of a cluster
  61. # with a certain purpose. Some clusters serve media, some - messages, some rule
  62. # channels and so on. But sometimes unknown DC number is requested by client.
  63. # It could be a bug or some global reconfiguration of the Telegram.
  64. #
  65. # By default, proxy rejects such requests. But it is also possible to fallback
  66. # this request to any DC. Telegram works in a way that any DC is able to serve
  67. # any request but sacrificing a latency.
  68. #
  69. # If this setting is disabled (default), mtg will reject a connection.
  70. # Otherwise, chose a new DC.
  71. allow-fallback-on-unknown-dc = false
  72. # Telegram uses different DCs for different purposes. Unfortunately, most of
  73. # DCs are not public, and dependent on a location of the current user, so
  74. # mtg cannot know upfront about all of them, and how to access them. It has
  75. # a default list of DCs, including some CDN IPs, but it is possible that some
  76. # of them are not working for you. In this case, you can override them here.
  77. [[dc-overrides]]
  78. dc = 101
  79. ips = ["127.0.0.1:443"]
  80. # network defines different network-related settings
  81. [network]
  82. # please be aware that mtg needs to do some external requests. For
  83. # example, if you do not pass public ips, it will request your public ip
  84. # address from some external service.
  85. #
  86. # As for 2.0, if you set a public-ip on your own, mtg won't issue any
  87. # network requests except of those required for Telegram.
  88. #
  89. # so, in order of doing them, it needs to do DNS lookup. mtg ignores DNS
  90. # resolver of the operating system and uses DOH instead. This is a host
  91. # it has to access.
  92. #
  93. # By default we use Cloudflare.
  94. doh-ip = "1.1.1.1"
  95. # mtg can work via proxies (for now, we support only socks5). Proxy
  96. # configuration is done via list. So, you can specify many proxies
  97. # there.
  98. #
  99. # Actually, if you supply an empty list, then no proxies are going to be
  100. # used. If you supply a single proxy, then mtg will use it exclusively.
  101. # If you supply >= 2, then mtg will load balance between them.
  102. #
  103. # If you add an empty string here, this is an equivalent of 'plain network',
  104. # with no proxy usage.
  105. #
  106. # Proxy configuration is done via ordinary URI schema:
  107. #
  108. # socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s
  109. #
  110. # Only socks5 proxy is used. user/password is optional. As you can
  111. # see, you can specify some parameters in GET query. These parameters
  112. # configure circuit breaker.
  113. #
  114. # open_threshold means a number of errors which should happen so we stop
  115. # use a proxy.
  116. #
  117. # half_open_timeout means a time period (in Golang duration notation)
  118. # after which we can retry with this proxy
  119. #
  120. # reset_failures_timeout means a time period when we flush out errors
  121. # when circuit breaker in closed state.
  122. #
  123. # Please see https://docs.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker
  124. # on details about circuit breakers.
  125. proxies = [
  126. # "socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s"
  127. ]
  128. # network timeouts define different settings for timeouts. tcp timeout
  129. # define a global timeout on establishing of network connections. idle
  130. # means a timeout on pumping data between sockset when nothing is
  131. # happening.
  132. #
  133. # please be noticed that handshakes have no timeouts intentionally. You can
  134. # find a reasoning here:
  135. # https://www.ndss-symposium.org/wp-content/uploads/2020/02/23087-paper.pdf
  136. [network.timeout]
  137. tcp = "5s"
  138. http = "10s"
  139. idle = "1m"
  140. # Some countries do active probing on Telegram connections. This technique
  141. # allows to protect from such effort.
  142. #
  143. # mtg has a cache of some connection fingerprints. Actually, first bytes
  144. # of each connection. So, it stores them in some in-memory LRU+TTL cache.
  145. # You can configure this cache here.
  146. [defense.anti-replay]
  147. # You can enable/disable this feature.
  148. enabled = true
  149. # max size of such a cache. Please be aware that this number is
  150. # approximate we try hard to store data quite dense but it is possible
  151. # that we can go over this limit for 10-20% under some conditions and
  152. # architectures.
  153. max-size = "1mib"
  154. # we use stable bloom filters for anti-replay cache. This helps
  155. # to maintain a desired error ratio.
  156. error-rate = 0.001
  157. # You can protect proxies by using different blocklists. If client has
  158. # ip from the given range, we do not try to do a proper handshake. We
  159. # actually route it to fronting domain. So, this client will never ever
  160. # have a chance to use mtg to access Telegram.
  161. #
  162. # Please remember that blocklists are initialized in async way. So,
  163. # when you start a proxy, blocklists are empty, they are populated and
  164. # processed in backgrounds. An error in any URL is ignored.
  165. [defense.blocklist]
  166. # You can enable/disable this feature.
  167. enabled = true
  168. # This is a limiter for concurrency. In order to protect website
  169. # from overloading, we download files in this number of threads.
  170. download-concurrency = 2
  171. # A list of URLs in FireHOL format (https://iplists.firehol.org/)
  172. # You can provider links here (starts with https:// or http://) or
  173. # path to a local file, but in this case it should be absolute.
  174. urls = [
  175. "https://iplists.firehol.org/files/firehol_level1.netset",
  176. # "/local.file"
  177. ]
  178. # How often do we need to update a blocklist set.
  179. update-each = "24h"
  180. # Allowlist is an opposite to a blocklist. Only those IPs that are coming from
  181. # subnets defined in these lists are allowed. All others will be rejected.
  182. #
  183. # If this feature is disabled, then there won't be any check performed by this
  184. # validator. It is possible to combine both blocklist and whitelist.
  185. [defense.allowlist]
  186. # You can enable/disable this feature.
  187. enabled = false
  188. # This is a limiter for concurrency. In order to protect website
  189. # from overloading, we download files in this number of threads.
  190. download-concurrency = 2
  191. # A list of URLs in FireHOL format (https://iplists.firehol.org/)
  192. # You can provider links here (starts with https:// or http://) or
  193. # path to a local file, but in this case it should be absolute.
  194. urls = [
  195. # "https://iplists.firehol.org/files/firehol_level1.netset",
  196. # "/local.file"
  197. ]
  198. update-each = "24h"
  199. # statsd statistics integration.
  200. [stats.statsd]
  201. # enabled/disabled
  202. enabled = false
  203. # host:port for UDP endpoint of statsd
  204. address = "127.0.0.1:8888"
  205. # prefix of metric for statsd
  206. metric-prefix = "mtg"
  207. # tag format to use
  208. # supported values are 'datadog', 'influxdb' and 'graphite'
  209. # default format is graphite.
  210. tag-format = "datadog"
  211. # prometheus metrics integration.
  212. [stats.prometheus]
  213. # enabled/disabled
  214. enabled = true
  215. # host:port where to start http server for endpoint
  216. bind-to = "127.0.0.1:3129"
  217. # prefix of http path
  218. http-path = "/"
  219. # prefix for metrics for prometheus
  220. metric-prefix = "mtg"