|
|
@@ -113,11 +113,49 @@ head -c 512 /dev/urandom | md5sum | cut -f 1 -d ' '
|
|
113
|
113
|
|
|
114
|
114
|
## Secure mode
|
|
115
|
115
|
|
|
116
|
|
-If you want to support new secure mode, please prepend `dd` to the
|
|
117
|
|
-secret. For example, secret `cf18fa8ea0267057e2c61a5f7322a8e7` should
|
|
118
|
|
-be `ddcf18fa8ea0267057e2c61a5f7322a8e7`. But pay attention that some
|
|
119
|
|
-old clients won't support this mode. If this is not your case, I would
|
|
120
|
|
-suggest to go with this mode.
|
|
|
116
|
+Secure mode is not the best name and of course, it creates a lot of
|
|
|
117
|
+confusion. To explain what it means, we need to tell you some bits on
|
|
|
118
|
+dd-secrets.
|
|
|
119
|
+
|
|
|
120
|
+MTPROTO proxy protocol requires 16-byte secret. You usually
|
|
|
121
|
+propagate it as a 32 characters hexadecimal string like
|
|
|
122
|
+`282831900f371ca182feb0e4e1e1aeef` (if you decode this string
|
|
|
123
|
+to bytes, you will get a real secret which is used in the
|
|
|
124
|
+protocol). Everything went quite good until the moment when
|
|
|
125
|
+developers found an evidence that [protocol is quite weak to
|
|
|
126
|
+DPI](https://github.com/TelegramMessenger/MTProxy/issues/35) and some
|
|
|
127
|
+enthusiasts even created simple proofs of concepts on [detecting MTPROTO
|
|
|
128
|
+traffic](https://github.com/darkk/poormansmtproto).
|
|
|
129
|
+
|
|
|
130
|
+Telegram team has introduced a patch called dd-secrets. If you have
|
|
|
131
|
+a secret `282831900f371ca182feb0e4e1e1aeef` then your dd-secret is
|
|
|
132
|
+`dd282831900f371ca182feb0e4e1e1aeef`. That is, you just add dd prefix
|
|
|
133
|
+to the secret, prepend it with dd. In that case, original secret
|
|
|
134
|
+`282831900f371ca182feb0e4e1e1aeef` is used but client and server start
|
|
|
135
|
+to act a little bit different: they start to add random noise to the
|
|
|
136
|
+packets so they can't be detected by their length. In order to keep
|
|
|
137
|
+backward compatibility, all proxies a quite liberal to the secrets to
|
|
|
138
|
+use: if the client uses plain secret, without dd prefix, they fall back
|
|
|
139
|
+to the normal behavior. If dd-secret is used (proxy can extract this
|
|
|
140
|
+information on the handshake), then more secured, the hardened behavior
|
|
|
141
|
+is used.
|
|
|
142
|
+
|
|
|
143
|
+Yes, it can look like a hack but it is as it is.
|
|
|
144
|
+
|
|
|
145
|
+Now going back to the secure mode: if you do not pass `-s` flag to the
|
|
|
146
|
+mtg, then it checks what mode is requested by the client. If the client
|
|
|
147
|
+uses plain secret, without dd prefix, then proxy falls back to the
|
|
|
148
|
+original behavior and do not play with paddings. If dd-secret is used
|
|
|
149
|
+and client demands this mode, then proxy start to add that random noise
|
|
|
150
|
+to the packets. But if you pass `-s`, then only clients with dd-secrets
|
|
|
151
|
+can connect. How to migrate existing clients then? If a client is new
|
|
|
152
|
+enough, you can just prepend the secret with dd string in the settings.
|
|
|
153
|
+If it is an old guy, then nothing to do, sorry.
|
|
|
154
|
+
|
|
|
155
|
+Why this mode matters? We do not have evidence but there is quite a big
|
|
|
156
|
+suspicion that some ISPs start to filter MTPROTO traffic. If they detect
|
|
|
157
|
+the IP address which acts as a proxy, they block it and no clients can
|
|
|
158
|
+use this proxy. This is an attempt to prevent such a situation.
|
|
121
|
159
|
|
|
122
|
160
|
Oneliners to generate such secrets:
|
|
123
|
161
|
|
|
|
@@ -131,10 +169,6 @@ or
|
|
131
|
169
|
echo dd$(head -c 512 /dev/urandom | md5sum | cut -f 1 -d ' ')
|
|
132
|
170
|
```
|
|
133
|
171
|
|
|
134
|
|
-If you want to enforce the usage of secure mode, please pass `-s` or
|
|
135
|
|
-`--secure-only` flags. In that case, clients which do not use dd-secrets
|
|
136
|
|
-are going to be disconnected from the proxy.
|
|
137
|
|
-
|
|
138
|
172
|
|
|
139
|
173
|
## Environment variables
|
|
140
|
174
|
|
|
|
@@ -192,13 +226,13 @@ This tool will listen on port 3128 by default with the given secret.
|
|
192
|
226
|
# One-line runner
|
|
193
|
227
|
|
|
194
|
228
|
```console
|
|
195
|
|
-docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16)
|
|
|
229
|
+docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16)
|
|
196
|
230
|
```
|
|
197
|
231
|
|
|
198
|
232
|
or in secret mode:
|
|
199
|
233
|
|
|
200
|
234
|
```console
|
|
201
|
|
-docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16)
|
|
|
235
|
+docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16)
|
|
202
|
236
|
```
|
|
203
|
237
|
|
|
204
|
238
|
You will have this tool up and running on port 3128. Now curl
|