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 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. # Sometimes you want to enforce mtg to use some types of
  34. # IP connectivity to Telegram. We have 4 modes:
  35. # - prefer-ipv6:
  36. # We can use both ipv4 and ipv6 but ipv6 has a preference
  37. # - prefer-ipv4:
  38. # We can use both ipv4 and ipv6 but ipv4 has a preference
  39. # - only-ipv6:
  40. # Only ipv6 connectivity is used
  41. # - only-ipv4:
  42. # Only ipv4 connectivity is used
  43. prefer-ip = "prefer-ipv6"
  44. # If this setting is set, then mtg will try to get proxy updates from Telegram
  45. # Usually this is completely fine to have it disabled, because mtg has a list
  46. # of some core proxies hardcoded.
  47. auto-update = false
  48. # FakeTLS uses domain fronting protection. So it needs to know a port to
  49. # access.
  50. #
  51. # Deprecated: use [domain-fronting] configuration block. If relevant option
  52. # is defined there, this one would be ignored.
  53. # domain-fronting-port = 443
  54. # By default, mtg resolves the fronting hostname (from the secret) via DNS
  55. # to establish a TCP connection. If DNS resolution of that hostname is blocked,
  56. # you can specify an IP address to connect to directly. The hostname is still
  57. # used for SNI in the TLS handshake.
  58. #
  59. # default value is not set (DNS resolution is used).
  60. #
  61. # Deprecated: use [domain-fronting] configuration block. If relevant option
  62. # is defined there, this one would be ignored.
  63. # domain-fronting-ip = "10.0.0.10"
  64. # This makes a communication between both fronting website and mtg to use
  65. # proxy protocol.
  66. #
  67. # Deprecated: use [domain-fronting] configuration block. If relevant option
  68. # is defined there, this one would be ignored.
  69. # domain-fronting-proxy-protocol = false
  70. # FakeTLS can compare timestamps to prevent probes. Each message has
  71. # encrypted timestamp. So, mtg can compare this timestamp and decide if
  72. # we need to proceed with connection or not.
  73. #
  74. # Sometimes time can be skewed so we accept all messages within a
  75. # time range of this parameter.
  76. tolerate-time-skewness = "5s"
  77. # Telegram has a concept of DC. You can think about DC as a number of a cluster
  78. # with a certain purpose. Some clusters serve media, some - messages, some rule
  79. # channels and so on. But sometimes unknown DC number is requested by client.
  80. # It could be a bug or some global reconfiguration of the Telegram.
  81. #
  82. # By default, proxy rejects such requests. But it is also possible to fallback
  83. # this request to any DC. Telegram works in a way that any DC is able to serve
  84. # any request but sacrificing a latency.
  85. #
  86. # If this setting is disabled (default), mtg will reject a connection.
  87. # Otherwise, chose a new DC.
  88. allow-fallback-on-unknown-dc = false
  89. # This section is relevant to communication with fronting domain. Usually
  90. # you do not need to setup anything here but there are plenty of cases, especially
  91. # if you put mtg behind load balancer, when some specific configuration is
  92. # required.
  93. [domain-fronting]
  94. # By default, mtg resolves the fronting hostname (from the secret) via DNS
  95. # to establish a TCP connection. If DNS resolution of that hostname is blocked,
  96. # you can specify an IP address to connect to directly. The hostname is still
  97. # used for SNI in the TLS handshake.
  98. #
  99. # default value is not set (DNS resolution is used).
  100. # ip = "10.10.10.11"
  101. # FakeTLS uses domain fronting protection. So it needs to know a port to
  102. # access. Default value is 443
  103. # port = 443
  104. # This makes a communication between both fronting website and mtg to use
  105. # proxy protocol.
  106. # proxy-protocol = false
  107. # network defines different network-related settings
  108. [network]
  109. # please be aware that mtg needs to do some external requests. For
  110. # example, if you do not pass public ips, it will request your public ip
  111. # address from some external service.
  112. #
  113. # As for 2.0, if you set a public-ip on your own, mtg won't issue any
  114. # network requests except of those required for Telegram.
  115. #
  116. # so, in order of doing them, it needs to do DNS lookup. mtg ignores DNS
  117. # resolver of the operating system and uses DOH instead. This is a host
  118. # it has to access.
  119. #
  120. # By default we use Cloudflare.
  121. #
  122. # DEPRECATED option:
  123. # If dns option is specified, it will be used instead. No default is defined
  124. # anymore. But if you set this option, this is literally the same providing
  125. # https:// URL to `dns`.
  126. #
  127. # In other words:
  128. #
  129. # doh-ip = "1.1.1.1"
  130. #
  131. # is literally the same as
  132. #
  133. # dns = "https://1.1.1.1"
  134. # doh-ip = "1.1.1.1"
  135. # Starting from mtg v2.1.12 we have changed a configuration for DNS. Now it
  136. # supports DNS-over-HTTPS, DNS-over-TLS, custom UDP resolver and system
  137. # resolver.
  138. #
  139. # Here is how to define DNS-over-HTTPS:
  140. # - https://1.1.1.1
  141. # - https://1.1.1.1/dns-query
  142. # - https://cloudflare-dns.com/dns-query
  143. # - https://cloudflare-dns.com
  144. #
  145. # Here is how to define DNS-over-TLS:
  146. # - tls://1.1.1.1
  147. # - tls://cloudflare-dns.com
  148. #
  149. # Here is how to define a custom UDP resolver (we support only IPs here)
  150. # - 1.1.1.1
  151. # - udp://1.1.1.1
  152. #
  153. # If you set it to empty string, default resolver will be used.
  154. # But please comment out doh-ip
  155. dns = "https://1.1.1.1"
  156. # mtg can work via proxies (for now, we support only socks5). Proxy
  157. # configuration is done via list. So, you can specify many proxies
  158. # there.
  159. #
  160. # Actually, if you supply an empty list, then no proxies are going to be
  161. # used. If you supply a single proxy, then mtg will use it exclusively.
  162. # If you supply >= 2, then mtg will load balance between them.
  163. #
  164. # If you add an empty string here, this is an equivalent of 'plain network',
  165. # with no proxy usage.
  166. #
  167. # Proxy configuration is done via ordinary URI schema:
  168. #
  169. # socks5://user:password@host:port
  170. #
  171. # Only socks5 proxy is used. user/password is optional. As you can
  172. # see, you can specify some parameters in GET query. These parameters
  173. # configure circuit breaker.
  174. proxies = [
  175. # "socks5://user:password@host:port"
  176. ]
  177. # network timeouts define different settings for timeouts. tcp timeout
  178. # define a global timeout on establishing of network connections. idle
  179. # means a timeout on pumping data between sockset when nothing is
  180. # happening.
  181. #
  182. # please be noticed that handshakes have no timeouts intentionally. You can
  183. # find a reasoning here:
  184. # https://www.ndss-symposium.org/wp-content/uploads/2020/02/23087-paper.pdf
  185. [network.timeout]
  186. tcp = "5s"
  187. http = "10s"
  188. idle = "1m"
  189. # Some countries do active probing on Telegram connections. This technique
  190. # allows to protect from such effort.
  191. #
  192. # mtg has a cache of some connection fingerprints. Actually, first bytes
  193. # of each connection. So, it stores them in some in-memory LRU+TTL cache.
  194. # You can configure this cache here.
  195. [defense.anti-replay]
  196. # You can enable/disable this feature.
  197. enabled = true
  198. # max size of such a cache. Please be aware that this number is
  199. # approximate we try hard to store data quite dense but it is possible
  200. # that we can go over this limit for 10-20% under some conditions and
  201. # architectures.
  202. max-size = "1mib"
  203. # we use stable bloom filters for anti-replay cache. This helps
  204. # to maintain a desired error ratio.
  205. error-rate = 0.001
  206. # You can protect proxies by using different blocklists. If client has
  207. # ip from the given range, we do not try to do a proper handshake. We
  208. # actually route it to fronting domain. So, this client will never ever
  209. # have a chance to use mtg to access Telegram.
  210. #
  211. # Please remember that blocklists are initialized in async way. So,
  212. # when you start a proxy, blocklists are empty, they are populated and
  213. # processed in backgrounds. An error in any URL is ignored.
  214. [defense.blocklist]
  215. # You can enable/disable this feature.
  216. enabled = true
  217. # This is a limiter for concurrency. In order to protect website
  218. # from overloading, we download files in this number of threads.
  219. download-concurrency = 2
  220. # A list of URLs in FireHOL format (https://iplists.firehol.org/)
  221. # You can provider links here (starts with https:// or http://) or
  222. # path to a local file, but in this case it should be absolute.
  223. urls = [
  224. "https://iplists.firehol.org/files/firehol_level1.netset",
  225. # "/local.file"
  226. ]
  227. # How often do we need to update a blocklist set.
  228. update-each = "24h"
  229. # Allowlist is an opposite to a blocklist. Only those IPs that are coming from
  230. # subnets defined in these lists are allowed. All others will be rejected.
  231. #
  232. # If this feature is disabled, then there won't be any check performed by this
  233. # validator. It is possible to combine both blocklist and whitelist.
  234. [defense.allowlist]
  235. # You can enable/disable this feature.
  236. enabled = false
  237. # This is a limiter for concurrency. In order to protect website
  238. # from overloading, we download files in this number of threads.
  239. download-concurrency = 2
  240. # A list of URLs in FireHOL format (https://iplists.firehol.org/)
  241. # You can provider links here (starts with https:// or http://) or
  242. # path to a local file, but in this case it should be absolute.
  243. urls = [
  244. # "https://iplists.firehol.org/files/firehol_level1.netset",
  245. # "/local.file"
  246. ]
  247. update-each = "24h"
  248. # statsd statistics integration.
  249. [stats.statsd]
  250. # enabled/disabled
  251. enabled = false
  252. # host:port for UDP endpoint of statsd
  253. address = "127.0.0.1:8888"
  254. # prefix of metric for statsd
  255. metric-prefix = "mtg"
  256. # tag format to use
  257. # supported values are 'datadog', 'influxdb' and 'graphite'
  258. # default format is graphite.
  259. tag-format = "datadog"
  260. # prometheus metrics integration.
  261. [stats.prometheus]
  262. # enabled/disabled
  263. enabled = true
  264. # host:port where to start http server for endpoint
  265. bind-to = "127.0.0.1:3129"
  266. # prefix of http path
  267. http-path = "/"
  268. # prefix for metrics for prometheus
  269. metric-prefix = "mtg"