Przeglądaj źródła

Update README

tags/v2.0.0-rc1
9seconds 5 lat temu
rodzic
commit
4f048a3b82
1 zmienionych plików z 251 dodań i 194 usunięć
  1. 251
    194
      README.md

+ 251
- 194
README.md Wyświetl plik

@@ -1,14 +1,16 @@
1 1
 # mtg
2 2
 
3
-Bullshit-free MTPROTO proxy for Telegram
3
+Highly-opionated (ex-bullshit-free) MTPROTO proxy for
4
+[Telegram](https://telegram.org/).
4 5
 
5
-[![Build Status](https://travis-ci.org/9seconds/mtg.svg?branch=master)](https://travis-ci.org/9seconds/mtg)
6
-[![Go Report Card](https://goreportcard.com/badge/github.com/9seconds/mtg)](https://goreportcard.com/report/github.com/9seconds/mtg)
7
-[![Docker Build Status](https://img.shields.io/docker/build/nineseconds/mtg.svg)](https://hub.docker.com/r/nineseconds/mtg/)
6
+[![CI](https://github.com/9seconds/mtg/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/9seconds/mtg/actions/workflows/ci.yaml)
7
+[![codecov](https://codecov.io/gh/9seconds/mtg/branch/master/graph/badge.svg?token=JfdDyGVpT4)](https://codecov.io/gh/9seconds/mtg)
8
+[![Go Reference](https://pkg.go.dev/badge/github.com/9seconds/mtg.svg)](https://pkg.go.dev/github.com/9seconds/mtg)
8 9
 
9
-**Please see a guide on upgrading to 1.0 at the end of this README.**
10
+**If you use v1.0 or upgrade broke you proxy, please read the chapter
11
+[Version 2](#version-2)**
10 12
 
11
-# Rationale
13
+## Rationale
12 14
 
13 15
 There are several available proxies for Telegram MTPROTO available. Here
14 16
 are the most notable:
@@ -17,267 +19,322 @@ are the most notable:
17 19
 * [Python](https://github.com/alexbers/mtprotoproxy)
18 20
 * [Erlang](https://github.com/seriyps/mtproto_proxy)
19 21
 
20
-Almost all of them follow the way how official proxy was built. This
21
-includes support of multiple secrets, support of promoted channels, etc.
22
+You can use any of these. They work great and all implementations have
23
+feature parity now. This includes support of adtag, replay attack
24
+protection, domain fronting, faketls, and so on. mtg has a similar
25
+goal: to give a possibility to connect to Telegram in a restricted,
26
+censored environment. But it does it slightly differently in details
27
+that probably matter.
22 28
 
23
-mtg is an implementation in golang which is intended to be:
29
+* **Resource-efficient**
30
+
31
+  It has to be resource-efficient. It does not mean that you will see
32
+  the smallest memory usage. It means that it will try to use allocated
33
+  resources in zero-waste mode, reusing as much memory as possible and
34
+  so on.
24 35
 
25
-* **Lightweight**
26
-  It has to consume as few resources as possible but not by losing
27
-  maintainability.
28 36
 * **Easily deployable**
37
+
29 38
   I strongly believe that Telegram proxies should follow the way of
30
-  ShadowSocks: promoted channels is a strange way of doing business
31
-  I suppose. I think the only viable way is to have a proxy with
32
-  minimum configuration which should work everywhere.
39
+  [ShadowSocks](https://shadowsocks.org): promoted channels is a strange
40
+  way of doing business I suppose. I think the only viable way is to
41
+  have a proxy that can be restored anywhere easily.
42
+
33 43
 * **A single secret**
34
-  I think that multiple secrets solve no problems and just complexify
44
+
45
+  I think that multiple secrets solve no problems and just complex
35 46
   software. I also believe that in the case of throwout proxies, this
36
-  feature is a useless luxury.
37
-* **Minimum docker image size**
38
-  Official image is less than 3.5 megabytes. Literally.
39
-* **No management WebUI**
40
-  This is an implementation of a simple lightweight proxy. I won't do that.
47
+  the feature is a useless luxury.
41 48
 
42
-This proxy supports 2 modes of work: direct connection to Telegram and
43
-promoted channel mode. If you do not need promoted channels, I would
44
-recommend you to go with direct mode: this way is more robust.
49
+* **No adtag support**
45 50
 
46
-To run a proxy in direct mode, all you need to do is just provide a
47
-secret. If you do not provide ADTag as a second parameter, promoted
48
-channels mode won't be activated.
51
+  Please read [Version 2](#version-2) chapter.
49 52
 
50
-To get promoted channel, please contact
51
-[@MTProxybot](https://t.me/MTProxybot) and provide generated adtag as a
52
-second parameter.
53
+* **No management WebUI**
53 54
 
55
+  This is an implementation of a simple lightweight proxy. I won't do that.
54 56
 
55
-# Source code organization
57
+* **Proxy chaining**
58
+
59
+  mtg has the support of [SOCKS5](https://en.wikipedia.org/wiki/SOCKS)
60
+  proxies. So, in theory, you can run this proxy as a frontend
61
+  and route traffic via [v2ray](https://www.v2ray.com/),
62
+  [Gost](https://docs.ginuerzh.xyz/gost/),
63
+  [Trojan](https://trojan-gfw.github.io/trojan/), or any other project
64
+  you like.
65
+
66
+* **Native blocklist support**
67
+
68
+  Previously, this was delegated to the [FireHOL](https://firehol.org/)
69
+  project or similar ones which track attacks and publish a list of
70
+  potentially dangerous IPs. mtg has native support of such blocklists.
71
+
72
+* **Can be used as a library**
56 73
 
57
-There are 2 main branches:
74
+  mtg v2 was redesigned in a way so it can be embedded into your
75
+  software (written in Golang) with a minimum effort + you can replace
76
+  some parts with those you want.
58 77
 
59
-1. `master` branch contains potentially unstable features
60
-2. `stable` branch contains stable version. Usually you want to use this branch.
78
+### Version 2
61 79
 
62
-# How to build
80
+If you use version 1.x before, you are probably noticed some major
81
+backward non-compatible details:
63 82
 
64
-```console
65
-make
66
-```
83
+1. Configuration file
84
+2. Removed support of adtag
67 85
 
68
-If you want to build for another platform:
86
+For the configuration file, please check out the full example in this
87
+repository. It has a lot of comments and most of the options are
88
+optional. We do have only `secret` and `bind-to` sections mandatory.
89
+Other sections in the example configuration file are filled with default
90
+values.
69 91
 
70
-```console
71
-make crosscompile
72
-```
92
+Adtag support was removed completely. This was done to debloat mtg and
93
+keep it simple and obvious. Hopefully, this goal is achieved and the
94
+source code is clean and straightforward enough.
73 95
 
74
-If you want to build Docker image (called `mtg`):
96
+I always was quite skeptical about adtag. In my POV, a proxy as a fat
97
+big connectivity point for hundreds of clients is an illusion. If you
98
+work in a censored environment, the first thing that authority does is
99
+IP blocking. For us, it means, those big proxies that can benefit from
100
+having a pinned channel are going to be blocked in a minute.
75 101
 
76
-```console
77
-make docker
78
-```
102
+Proxy has to be intimate. It has to be shared within a small group as
103
+a family or maybe your college friends. It has to have a small number
104
+of connections and never publicly announced its presence. It has to fly
105
+under the radar. If the proxy is detected, you need to be able to give
106
+a rebirth on a new IP address as soon as possible. I do no think that
107
+having some special channel for such a use case makes any sense.
79 108
 
80
-# Docker image
109
+But other details like replay attack protection, domain fronting,
110
+accurate FakeTLS implementation, IP blacklisting, and proxy
111
+chaining matter here. If you work in censored perimeter like
112
+[GFW](https://en.wikipedia.org/wiki/Great_Firewall)-protected
113
+country, you probably want to have an MTPROTO proxy as
114
+a frontend that transports traffic via cloaked tunnels
115
+made by [Trojan](https://trojan-gfw.github.io/trojan/),
116
+[Shadowsocks](https://shadowsocks.org), [v2ray](https://www.v2ray.com/),
117
+or [Gost](https://docs.ginuerzh.xyz/gost/). That's why you have to have
118
+the support of chaining as a first-class citizen.
81 119
 
82
-Docker follows the same policy as the source code organization:
120
+Yes, this is possible and doable with optional adtag support. But the
121
+truth is that the MTPROTO proxy for Telegram is just a thing that either
122
+work as a normal client (direct mode) or doing some RPC calls in [TL
123
+language](https://core.telegram.org/mtproto/TL) (adtag support). I
124
+understand the intention of the developers and I understand that they
125
+were under high pressure fighting with [RKN](https://rkn.gov.ru/) and
126
+doing TON after that. Nothing is ideal. But for the proxy, it means that
127
+source code is full of complex non-trivial code which is required only
128
+to support a feature that we barely need.
83 129
 
84
-- `latest` mirrors the master branch
85
-- `stable` mirrors the stable branch
86
-- tags are for tagged releases
130
+So, to have a reasonable MTPROTO proxy, adtag support was removed. This
131
+is a rare chance in my career where software v2 debloats a previous
132
+version. It feels so good :)
87 133
 
88
-```console
89
-docker pull nineseconds/mtg:latest
90
-```
134
+### Version 1 and 2
91 135
 
92
-```console
93
-docker pull nineseconds/mtg:stable
94
-```
136
+I do continue to support both versions 1 and 2. But in a different mode.
95 137
 
96
-```console
97
-docker pull nineseconds/mtg:0.10
98
-```
138
+Version 1 is now officially in maintenance mode. It means that I won't
139
+make any new features or improvements there. You can consider a feature
140
+freeze there. No bugs are going to be fixed there except for critical
141
+ones. PRs are welcome though. The goal is to keep it working. It will
142
+get some periodical updates like updates to the new Golang version of
143
+dependencies version bump, but that's mostly it.
99 144
 
100
-# Ansible role
145
+**If you want to have mtg with _adtag support_, please use version 1**.
101 146
 
102
-You can find unofficial Ansible role for mtg here: https://github.com/rlex/ansible-role-mtg
103
-Also, there is another project on Ansible Galaxy: https://galaxy.ansible.com/ivansible/lin_mtproxy
147
+Version 2 is going to have all my love, active support, bug fixing, etc.
148
+It is under active development and maintenance.
104 149
 
105
-# Configuration
150
+This project has several main branches
106 151
 
107
-To run this tool you need to configure as less as possible. Telegram
108
-clients support 3 different secret types:
152
+1. [`master`](https://github.com/9seconds/mtg/tree/master) branch
153
+   contains a bleeding edge. It may potentially have some features
154
+   which will break your source code.
155
+2. [`stable`](https://github.com/9seconds/mtg/tree/stable) branch contains
156
+   dumps of a master branch when we consider it 'stable'. This is a
157
+   branch you probably want to pick.
158
+3. [`v2`](https://github.com/9seconds/mtg/tree/v2) has a development
159
+   of the v2.x version. In theory, it is the same as `master` but this
160
+   will change when we have v3.x.
161
+4. [`v1`](https://github.com/9seconds/mtg/tree/v1) has a version 1.x.
162
+
163
+## Getting started
109 164
 
110
-* Simple - basically, it is just a flow of frames ciphered by AES-CTR stream
111
-  cipher.
112
-* Secured - the same stream as simple but with some random noise to prevent
113
-  statistical analysis of traffic flow.
114
-* FakeTLS - this mode envelops telegram stream in TLS so it looks (in theory)
115
-  the same as any TLS1.3 traffic from DPI point of view.
165
+### Download a tool
166
+
167
+#### Download binaries
168
+
169
+Binaries can be downloaded from the release page. Also, you can download
170
+docker image.
116 171
 
117
-If you do not have preferences, go with FakeTLS or at least secured.
118
-Simple mode is a little bit naive and traffic flow can be easily
119
-identified as Telegram one.
172
+For the current version, please download like
120 173
 
121
-Unlike the rest of implementation, mtg is quite strict about the
122
-execution mode: if you run a proxy instance with FakeTLS secret, you
123
-can't connect to it with simple or secured clients. You can't connect
124
-to the proxy with secured secret with FakeTLS key. It forces one mode
125
-of working. So, unfortunately, there is no way how to connect to the
126
-deployed proxy with another secret (if you know how to construct and
127
-convert them). But at the same time, old clients can't connect so they
128
-won't expose the type of the service.
174
+```console
175
+docker pull nineseconds/mtg:2
176
+```
129 177
 
130
-First, you need to generate a secret:
178
+For version 1:
131 179
 
132 180
 ```console
133
-$ mtg generate-secret simple
134
-52a493bdfb90eea55739eabff2d92a14
181
+docker pull nineseconds/mtg:1
135 182
 ```
136 183
 
184
+You may also check both [Docker
185
+Hub](https://hub.docker.com/r/nineseconds/mtg/tags) and [Github
186
+Registry](https://github.com/users/9seconds/packages/container/package/mtg).
187
+Please do not choose `latest` or `stable` if you want to avoid
188
+surprises. Always choose some version tag.
189
+
190
+Also, if you have `go` installed, you can always download this tool with `go get`:
191
+
137 192
 ```console
138
-$ mtg generate-secret secured
139
-ddf05fb7acb549be047a7c585116581418
193
+go get github.com/9seconds/mtg/v2
140 194
 ```
141 195
 
196
+#### Build from sources
197
+
142 198
 ```console
143
-$ mtg generate-secret -c google.com tls
144
-ee852380f362a09343efb4690c4e17862e676f6f676c652e636f6d
199
+git clone https://github.com:9seconds/mtg.git
200
+cd mtg
201
+make static
145 202
 ```
146 203
 
147
-Or, if you prefer docker:
204
+or for the docker image:
148 205
 
149 206
 ```console
150
-$ docker run --rm nineseconds/mtg generate-secret tls -c bing.com
151
-eedf71035a8ed48a623d8e83e66aec4d0562696e672e636f6d
207
+make docker
152 208
 ```
153 209
 
154
-## Antireplay cache
210
+### Generate secret
155 211
 
156
-To prevent replay attacks, we have internal storage of first frames
157
-messages for connected clients. These frames are generated randomly
158
-by design and we have the negligible possibility of duplication
159
-(probability is 1/(2^64)) but it could be quite effective to prevent
160
-replays.
212
+If you already have a secret in Base64 format or that, which starts with `ee`,
213
+you can skip this chapter. Otherwise:
161 214
 
162
-It is possible to disable this cache. To do that, please explicitly set
163
-its size to 0.
215
+```console
216
+$ mtg generate-secret google.com
217
+7ibaERuTSGPH1RdztfYnN4tnb29nbGUuY29t
218
+```
164 219
 
220
+or
165 221
 
166
-## FakeTLS
222
+```console
223
+$ mtg generate-secret --hex google.com
224
+ee473ce5d4958eb5f968c87680a23854a0676f6f676c652e636f6d
225
+```
167 226
 
168
-If you run this a proxy in faketls mode, this proxy will try to hide
169
-itself cloaking a host provided as a part of the generated secret. It
170
-means that if you cloak google.com then you can curl this proxy and
171
-you'll get a google.com response back.
227
+This secret is a keystone for a proxy and your password for a client.
228
+You need to keep it secured.
172 229
 
173
-mtg proxies L3 traffic. In other words, only TCP, without interfering in
174
-TLS, HTTP or any other high-level protocol.
230
+We recommend choosing a hostname wisely. Here we have a _google.com_
231
+but in reality, all providers can easily detect that this is not a
232
+Google. Google has a list of networks it officially uses and your IP
233
+address won't probably belong to it. It is a great idea to hide behind
234
+some domain that has some relation to this IP address.
175 235
 
236
+For example, you've bought a VPS from [Digital
237
+Ocean](https://www.digitalocean.com/). Then it might be a good idea to
238
+generate a secret for _digitalocean.com_ then.
176 239
 
177
-## Environment variables
240
+### Prepare a configuration file
178 241
 
179
-It is possible to configure this tool using environment variables. You
180
-can configure any flag but not secret or adtag. Here is the list of
181
-supported environment variables:
242
+Please checkout an example configuration file. All options except of
243
+`secret` and `bind-to` are optional. You can safely have this minimal
244
+configuration file:
182 245
 
183
-| Environment variable          | Corresponding flags          | Default value                     | Description                                                                                                                                                                                                                                                                     |
184
-|-------------------------------|------------------------------|-----------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
185
-| `MTG_DEBUG`                   | `-d`, `--debug`              | `false`                           | Run in debug mode. Usually, you need to run in this mode  only if you develop this tool or its maintainer is asking you to provide  logs with such verbosity.                                                                                                                   |
186
-| `MTG_VERBOSE`                 | `-v`, `--verbose`            | `false`                           | Run in verbose mode. This is way less chatty than debug mode.                                                                                                                                                                                                                   |
187
-| `MTG_BIND`                    | `-b`, `--bind`               | `0.0.0.0:3128`                    | Which host/port pair should we bind to (listen on).                                                                                                                                                                                                                             |
188
-| `MTG_IPV4`                    | `-4`, `--public-ipv4`        | [Autodetect](https://ifconfig.co) | IPv4 address:port of this proxy. This is required if you NAT your proxy or run it in a docker container. In that case, you absolutely need to specify public IPv4 address of the proxy, otherwise either URLs will be broken or proxy could not access Telegram middle proxies. |
189
-| `MTG_IPV6`                    | `-6`, `--public-ipv6`        | [Autodetect](https://ifconfig.co) | IPv6 address:port of this proxy. This is required if you NAT your proxy or run it in a docker container. In that case, you absolutely need to specify public IPv6 address of the proxy, otherwise either URLs will be broken or proxy could not access Telegram middle proxies. |
190
-| `MTG_STATS_BIND`              | `-t`, `--stats-bind`         | `127.0.0.1:3129`                  | Which hist:port should we bind the internal statistics HTTP server (Prometheus).                                                                                                                                                                                                |
191
-| `MTG_STATS_NAMESPACE`         | `--stats-namespace`          | `mtg`                             | Which namespace should be used for prometheus metrics.                                                                                                                                                                                                                          |
192
-| `MTG_STATSD_ADDR`             | `--statsd-addr`              |                                   | host:port of statsd service. No defaults, by default we do not send anything there.                                                                                                                                                                                             |
193
-| `MTG_STATSD_PREFIX`           | `--statsd-prefix`            | `mtg`                             | Which bucket prefix we should use. For example, if you set `mtg`, then metric `traffic.ingress` would be send as `mtg.traffic.ingress`.                                                                                                                                         |
194
-| `MTG_STATSD_TAGS_FORMAT`      | `--statsd-tags-format`       |                                   | Which tags format we should use. By default, we are using default vanilla statsd tags format but if you want to send directly to InfluxDB or Datadog, please specify it there. Possible options are `influxdb` and `datadog`.                                                   |
195
-| `MTG_STATSD_TAGS`             | `--statsd-tags`              |                                   | Which tags should we send to statsd with our metrics. Please specify them as `key=value` pairs.                                                                                                                                                                                 |
196
-| `MTG_BUFFER_WRITE`            | `-w`, `--write-buffer`       | `32KB`                            | The size of TCP write buffer in bytes. Write buffer is the buffer for messages which are going from client to Telegram.                                                                                                                                                         |
197
-| `MTG_BUFFER_READ`             | `-r`, `--read-buffer`        | `32KB`                            | The size of TCP read buffer in bytes. Read buffer is the buffer for messages from Telegram to client.                                                                                                                                                                           |
198
-| `MTG_ANTIREPLAY_MAXSIZE`      | `--anti-replay-max-size`     | `128MB`                           | Max size of antireplay cache.                                                                                                                                                                                                                                                   |
199
-| `MTG_CLOAK_PORT`              | `--cloak-port`               | `443`                             | Which port we should use to connect to cloaked host in FakeTLS mode.                                                                                                                                                                                                            |
200
-| `MTG_MULTIPLEX_PERCONNECTION` | `--multiplex-per-connection` | `50`                              | How many client connections can share a single Telegram connection in adtag mode                                                                                                                                                                                                |
201
-| `MTG_NTP_SERVERS`             | `--ntp-server`               | default pool                      | A list of NTP servers to use.                                                                                                                                                                                                                                                   |
202
-| `MTG_PREFER_DIRECT_IP`        | `--prefer-ip`                | `ipv6`                            | Which IP protocol to prefer if possible. Works mostly in direct mode.                                                                                                                                                                                                           |
246
+```toml
247
+secret = "ee473ce5d4958eb5f968c87680a23854a0676f6f676c652e636f6d"
248
+bind-to = "0.0.0.0:443"
249
+```
203 250
 
251
+This is enough to run the whole application. All other
252
+options already have sensible defaults for the app at almost any scale.
204 253
 
205
-Usually you want to modify only read/write buffer sizes. If you feel
206
-that proxy is slow, try to increase both sizes giving more priority to
207
-read buffer.
254
+Oh, the configuration is done in [TOML format](https://toml.io/en/).
208 255
 
209
-Unfortunately, MTPROTO proxy protocol does not allow us to use splice
210
-or any other neat tricks how to eliminate the need of copying data into
211
-userspace.
256
+### Run a proxy
212 257
 
213
-# How to run the tool
258
+Put a binary and a config into your webserver. Just for example,
259
+a binary goes to `/usr/local/bin/mtg` and configuration to `/etc/mtg.toml`.
214 260
 
215
-Now run the tool:
261
+Now you can create a systemd unit:
216 262
 
217 263
 ```console
218
-$ mtg run <secret>
264
+$ cat /etc/systemd/system/mtg.service
265
+[Unit]
266
+Description=mtg
267
+
268
+[Service]
269
+ExecStart=/usr/local/bin/mtg run /etc/mtg.toml
270
+Restart=always
271
+RestartSec=3
272
+
273
+[Install]
274
+WantedBy=multi-user.target
275
+$ sudo systemctl daemon-reload
276
+$ sudo systemctl enable mtg
277
+$ sudo systemctl start mtg
219 278
 ```
220 279
 
221
-How to run the tool with ADTag:
280
+or you can run a docker image
222 281
 
223 282
 ```console
224
-$ mtg run <secret> <adtag>
283
+docker run -d -v /etc/mtg.toml:/config.toml -p 443:3128 --restart=unless-stopped nineseconds/mtg:2
225 284
 ```
226 285
 
227
-This tool will listen on port 3128 by default with the given secret.
286
+where _443_ is a host port (a port you want to connect to from a
287
+client), and _3128_ is the one you have in your config in the `bind-to`
288
+section.
228 289
 
290
+### Access a proxy
229 291
 
230
-# oneliner to run this proxy
231
-
232
-Please ensure that docker is installed. After that just execute
292
+Now you can generate some useful links:
233 293
 
234 294
 ```console
235
-curl -sfL --compressed https://raw.githubusercontent.com/9seconds/mtg/master/run.sh | bash
295
+$ mtg access /etc/mtg.toml
296
+{
297
+  "ipv4": {
298
+    "ip": "x.y.z.a",
299
+    "port": 3128,
300
+    "tg_url": "tg://proxy?...",
301
+    "tg_qrcode": "https://api.qrserver.com/v1/create-qr-code?data...",
302
+    "tme_url": "https://t.me/proxy?...",
303
+    "tme_qrcode": "https://api.qrserver.com/v1/create-qr-code?data..."
304
+  },
305
+  "secret": {
306
+    "hex": "...",
307
+    "base64": "..."
308
+  }
309
+}
236 310
 ```
237 311
 
238
-
239
-# statsd integration
240
-
241
-mtg provides an integration with statsd, you can enable it with command
242
-line interface. To enable it, you have to provide IP address of statsd
243
-service.
244
-
245
-Out of the box, mtg supports 2 additional dialects: [InfluxDB](https://www.influxdata.com/blog/getting-started-with-sending-statsd-metrics-to-telegraf-influxdb/)
246
-and [Datadog](https://docs.datadoghq.com/developers/dogstatsd/).
247
-
248
-All metrics are gauges. Here is the list of metrics and their meaning:
249
-
250
-| Metric name            | Unit    | Description                                |
251
-|------------------------|---------|--------------------------------------------|
252
-| `connections`          | number  | The number of active connections.          |
253
-| `telegram_connections` | number  | The number of active telegram connections. |
254
-| `crashes`              | number  | An amount of crashes in client handlers.   |
255
-| `traffic.egress`       | bytes   | Traffic from the start of application.     |
256
-| `replay_attacks`       | number  | The number of prevented replay attacks.    |
257
-
258
-All metrics are prefixed with given prefix. Default prefix is `mtg`.
259
-Also, metrics provide tags (ipv4/ipv6, dc indexes etc).
260
-
261
-
262
-# Prometheus integration
263
-
264
-[Prometheus](https://prometheus.io) integration comes out of
265
-the box, you do not need to setup anything special.
266
-
267
-
268
-# Upgrade to 1.0
269
-
270
-Version 1.0 breaks compatibility with previous versions so please read
271
-this chapter carefully:
272
-
273
-1. mtg now uses subcommands. Please use `mtg run` instead of just
274
-   `mtg` to run a proxy.
275
-2. Options which set host and port separately were removed in a
276
-   favor of fused `host:port` options.
277
-3. Own stats server was removed. Prometheus endpoint is moved to
278
-   default stats endpoint.
279
-4. It is possible to connect to this proxy only with a secret which
280
-   was used to run it. So, no backward compatibility of clients.
281
-5. Multiplexing involves connectivity with middle proxies and involves
282
-   the most complex code path of this proxy. To avoid potential bugs,
283
-   we still recommend using direct mode.
312
+## Metrics
313
+
314
+Out of the box, mtg works with
315
+[statsd](https://github.com/statsd/statsd) and
316
+[Prometheus](https://prometheus.io/). Please check configuration file
317
+example to get how to set this integration up.
318
+
319
+Here goes a list of metrics with their types but without a prefix.
320
+
321
+| Name                        | Type    | Tags                             | Description                                                                                |
322
+|-----------------------------|---------|----------------------------------|--------------------------------------------------------------------------------------------|
323
+| client_connections          | gauge   | `ip_family`                      | Count of processing client connections.                                                    |
324
+| telegram_connections        | gauge   | `telegram_ip`, `dc`              | Count of connections to Telegram servers.                                                  |
325
+| domain_fronting_connections | gauge   | `ip_family`                      | Count of connections to fronting domain.                                                   |
326
+| telegram_traffic            | counter | `telegram_ip`, `dc`, `direction` | Count of bytes, transmitted to/from Telegram.                                              |
327
+| domain_fronting_traffic     | counter | `direction`                      | Count of bytes, transmitted to/from fronting domain.                                       |
328
+| domain_fronting             | counter | –                                | Count of domain fronting events.                                                           |
329
+| concurrency_limited         | counter | –                                | Count of events, when client connection was rejected due to concurrency limit.             |
330
+| ip_blocklisted              | counter | –                                | Count of events when client connection was rejected because IP was found in the blacklist. |
331
+| replay_attacks              | counter | –                                | Count of detected replay attacks.                                                          |
332
+
333
+Tag meaning:
334
+
335
+| Name        | Values                 | Description                                   |
336
+|-------------|------------------------|-----------------------------------------------|
337
+| ip_family   | ipv4, ipv6             | A version of the IP protocol.                 |
338
+| dc          |                        | A number of the Telegram DC for a connection. |
339
+| telegram_ip |                        | IP address of the Telegram server.            |
340
+| direction   | to_client, from_client | A direction of the traffic flow.              |

Ładowanie…
Anuluj
Zapisz