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
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

example.config.toml 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. # A size of user-space buffer for TCP to use. Since we do 2 connections,
  23. # then we have tcp-buffer * (4 + 2) per each connection: read/write for
  24. # each connection + 2 copy buffers to pump the data between sockets.
  25. tcp-buffer = "4kb"
  26. # Sometimes you want to enforce mtg to use some types of
  27. # IP connectivity to Telegram. We have 4 modes:
  28. # - prefer-ipv6:
  29. # We can use both ipv4 and ipv6 but ipv6 has a preference
  30. # - prefer-ipv4:
  31. # We can use both ipv4 and ipv6 but ipv4 has a preference
  32. # - only-ipv6:
  33. # Only ipv6 connectivity is used
  34. # - only-ipv4:
  35. # Only ipv4 connectivity is used
  36. prefer-ip = "prefer-ipv6"
  37. # FakeTLS uses domain fronting protection. So it needs to know a port to
  38. # access.
  39. cloak-port = 443
  40. # network defines different network-related settings
  41. [network]
  42. # please be aware that mtg needs to do some external requests. For
  43. # example, if you do not pass public ips, it will request your public ip
  44. # address from some external service.
  45. #
  46. # As for 2.0, if you set a public-ip on your own, mtg won't issue any
  47. # network requests except of those required for Telegram.
  48. #
  49. # so, in order of doing them, it needs to do DNS lookup. mtg ignores DNS
  50. # resolver of the operating system and uses DOH instead. This is a host
  51. # it has to access.
  52. #
  53. # By default we use Quad9.
  54. doh-ip = "9.9.9.9"
  55. # mtg can work via proxies (for now, we support only socks5). Proxy
  56. # configuration is done via list. So, you can specify many proxies
  57. # there.
  58. #
  59. # Actually, if you supply an empty list, then no proxies are going to be
  60. # used. If you supply a single proxy, then mtg will use it exclusively.
  61. # If you supply >= 2, then mtg will load balance between them.
  62. #
  63. # If you add an empty string here, this is an equivalent of 'plain network',
  64. # with no proxy usage.
  65. #
  66. # Proxy configuration is done via ordinary URI schema:
  67. #
  68. # socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s
  69. #
  70. # Only socks5 proxy is used. user/password is optional. As you can
  71. # see, you can specify some parameters in GET query. These parameters
  72. # configure circuit breaker.
  73. #
  74. # open_threshold means a number of errors which should happen so we stop
  75. # use a proxy.
  76. #
  77. # half_open_timeout means a time period (in Golang duration notation)
  78. # after which we can retry with this proxy
  79. #
  80. # reset_failures_timeout means a time period when we flush out errors
  81. # when circuit breaker in closed state.
  82. #
  83. # Please see https://docs.microsoft.com/en-us/azure/architecture/patterns/circuit-breaker
  84. # on details about circuit breakers.
  85. proxies = [
  86. # "socks5://user:password@host:port?open_threshold=5&half_open_timeout=1m&reset_failures_timeout=10s"
  87. ]
  88. # public ip addresses of the server. Actually, it is required only to
  89. # generate a correct access file. if you use default values here, mtg
  90. # will try to resolve these IPs on its own.
  91. [network.public-ip]
  92. ipv4 = ""
  93. ipv6 = ""
  94. # FakeTLS can compare timestamps to prevent probes. Each message has
  95. # encrypted timestamp. So, mtg can compare this timestamp and decide if
  96. # we need to proceed with connection or not.
  97. #
  98. # Please ensure that you have some ntp active on this host. Otherwise,
  99. # you can endup with badly performing proxy.
  100. [probes.time]
  101. # You can enable/disable that. A good idea is always enable.
  102. enabled = true
  103. # Time can be skewed by many reasons. So, this is a time interval
  104. # when message is cosidered as a good one.
  105. allow-skewness = "5s"
  106. # Some countries do active probing on Telegram connections. This technique
  107. # allows to protect from such effort.
  108. #
  109. # mtg has a cache of some connection fingerprints. Actually, first bytes
  110. # of each connection. So, it stores them in some in-memory LRU+TTL cache.
  111. # You can configure this cache here.
  112. [probes.anti-replay]
  113. # You can enable/disable this feature.
  114. enabled = true
  115. # max size of such a cache. Please be aware that this number is
  116. # approximate we try hard to store data quite dense but it is possible
  117. # that we can go over this limit for 10-20% under some conditions and
  118. # architectures.
  119. max-size = "16mb"
  120. # we use stable bloom filters for anti-replay cache. This helps
  121. # to maintain a desired error ratio.
  122. error-rate = 0.0001
  123. # statsd statistics integration.
  124. [stats.statsd]
  125. # enabled/disabled
  126. enabled = false
  127. # host:port for UDP endpoint of statsd
  128. address = "127.0.0.1:8888"
  129. # prefix of metric for statsd
  130. metric-prefix = "mtg"
  131. # prometheus metrics integration.
  132. [stats.prometheus]
  133. # enabled/disabled
  134. enabled = true
  135. # host:port where to start http server for endpoint
  136. bind-to = "127.0.0.1:3129"
  137. # prefix of http path
  138. http-path = "/"
  139. # prefix for metrics for prometheus
  140. metric-prefix = "mtg"