Giter Site home page Giter Site logo

mtg's Introduction

mtg

Highly-opinionated (ex-bullshit-free) MTPROTO proxy for Telegram.

CI codecov Go Reference

If you use v1.0 or upgrade broke you proxy, please read the chapter Version 2

Rationale

There are several available proxies for Telegram MTPROTO available. Here are the most notable:

You can use any of these. They work great and all implementations have feature parity now. This includes support of adtag, replay attack protection, domain fronting, faketls, and so on. mtg has a similar goal: to give a possibility to connect to Telegram in a restricted, censored environment. But it does it slightly differently in details that probably matter.

  • Resource-efficient

    It has to be resource-efficient. It does not mean that you will see the smallest memory usage. It means that it will try to use allocated resources in zero-waste mode, reusing as much memory as possible and so on.

  • Easily deployable

    I strongly believe that Telegram proxies should follow the way of ShadowSocks: promoted channels is a strange way of doing business I suppose. I think the only viable way is to have a proxy that can be restored anywhere easily.

  • A single secret

    I think that multiple secrets solve no problems and just complex software. I also believe that in the case of throwout proxies, this the feature is a useless luxury.

  • No adtag support

    Please read Version 2 chapter.

  • No management WebUI

    This is an implementation of a simple lightweight proxy. I won't do that.

  • Proxy chaining

    mtg has the support of SOCKS5 proxies. So, in theory, you can run this proxy as a frontend and route traffic via v2ray, Gost, Trojan, or any other project you like.

  • Native blocklist support

    Previously, this was delegated to the FireHOL project or similar ones which track attacks and publish a list of potentially dangerous IPs. mtg has native support of such blocklists.

  • Can be used as a library

    mtg v2 was redesigned in a way so it can be embedded into your software (written in Golang) with a minimum effort + you can replace some parts with those you want.

Version 2

If you use version 1.x before, you are probably noticed some major backward non-compatible details:

  1. Configuration file
  2. Removed support of adtag

For the configuration file, please check out the full example in this repository. It has a lot of comments and most of the options are optional. We do have only secret and bind-to sections mandatory. Other sections in the example configuration file are filled with default values.

Adtag support was removed completely. This was done to debloat mtg and keep it simple and obvious. Hopefully, this goal is achieved and the source code is clean and straightforward enough.

I always was quite skeptical about adtag. In my POV, a proxy as a fat big connectivity point for hundreds of clients is an illusion. If you work in a censored environment, the first thing that authority does is IP blocking. For us, it means, those big proxies that can benefit from having a pinned channel are going to be blocked in a minute.

Proxy has to be intimate. It has to be shared within a small group as a family or maybe your college friends. It has to have a small number of connections and never publicly announced its presence. It has to fly under the radar. If the proxy is detected, you need to be able to give a rebirth on a new IP address as soon as possible. I do no think that having some special channel for such a use case makes any sense.

But other details like replay attack protection, domain fronting, accurate FakeTLS implementation, IP blacklisting, and proxy chaining matter here. If you work in censored perimeter like GFW-protected country, you probably want to have an MTPROTO proxy as a frontend that transports traffic via cloaked tunnels made by Trojan, Shadowsocks, v2ray, or Gost. That's why you have to have the support of chaining as a first-class citizen.

Yes, this is possible and doable with optional adtag support. But the truth is that the MTPROTO proxy for Telegram is just a thing that either work as a normal client (direct mode) or doing some RPC calls in TL language (adtag support). I understand the intention of the developers and I understand that they were under high pressure fighting with RKN and doing TON after that. Nothing is ideal. But for the proxy, it means that source code is full of complex non-trivial code which is required only to support a feature that we barely need.

So, to have a reasonable MTPROTO proxy, adtag support was removed. This is a rare chance in my career where software v2 debloats a previous version. It feels so good :)

Version 1 and 2

I do continue to support both versions 1 and 2. But in a different mode.

Version 1 is now officially in maintenance mode. It means that I won't make any new features or improvements there. You can consider a feature freeze there. No bugs are going to be fixed there except for critical ones. PRs are welcome though. The goal is to keep it working. It will get some periodical updates like updates to the new Golang version of dependencies version bump, but that's mostly it.

If you want to have mtg with adtag support, please use version 1.

Version 2 is going to have all my love, active support, bug fixing, etc. It is under active development and maintenance.

This project has several main branches

  1. master branch contains a bleeding edge. It may potentially have some features which will break your source code.
  2. stable branch contains dumps of a master branch when we consider it 'stable'. This is a branch you probably want to pick.
  3. v2 has a development of the v2.x version. In theory, it is the same as master but this will change when we have v3.x.
  4. v1 has a version 1.x.

Getting started

Download a tool

Download binaries

Binaries can be downloaded from the release page. Also, you can download docker image.

For the current version, please download like

docker pull nineseconds/mtg:2

For version 1:

docker pull nineseconds/mtg:1

You may also check both Docker Hub and Github Registry. Please do not choose latest or stable if you want to avoid surprises. Always choose some version tag.

Also, if you have go installed, you can always download this tool with go get:

go install github.com/9seconds/mtg/v2@latest

Build from sources

git clone https://github.com/9seconds/mtg.git
cd mtg
make static

or for the docker image:

make docker

Generate secret

If you already have a secret in Base64 format or that, which starts with ee, you can skip this chapter. Otherwise:

$ mtg generate-secret google.com
7ibaERuTSGPH1RdztfYnN4tnb29nbGUuY29t

or

$ mtg generate-secret --hex google.com
ee473ce5d4958eb5f968c87680a23854a0676f6f676c652e636f6d

equivalent commands with docker:

$ docker run --rm nineseconds/mtg:2 generate-secret google.com
7ibaERuTSGPH1RdztfYnN4tnb29nbGUuY29t

$ docker run --rm nineseconds/mtg:2 generate-secret --hex google.com
ee473ce5d4958eb5f968c87680a23854a0676f6f676c652e636f6d

This secret is a keystone for a proxy and your password for a client. You need to keep it secured.

We recommend choosing a hostname wisely. Here we have a google.com but in reality, all providers can easily detect that this is not a Google. Google has a list of networks it officially uses and your IP address won't probably belong to it. It is a great idea to hide behind some domain that has some relation to this IP address.

For example, you've bought a VPS from Digital Ocean. Then it might be a good idea to generate a secret for digitalocean.com then.

Simple run mode

mtg supports 2 modes: simple and normal. Simple mode allows starting proxy with a small subset of configuration options you usually want to modify. This is quite good for oneliners that you can copy-paste and do not bother about external files whatsoever.

Let's take a look:

Usage: mtg simple-run <bind-to> <secret>

Run proxy without config file.

Arguments:
  <bind-to>    A host:port to bind proxy to.
  <secret>     Proxy secret.

Flags:
  -h, --help                           Show context-sensitive help.
  -v, --version                        Print version.

  -d, --debug                          Run in debug mode.
  -c, --concurrency=8192               Max number of concurrent connection to proxy.
  -b, --tcp-buffer="4KB"               Size of TCP buffer to use.
  -i, --prefer-ip="prefer-ipv6"        IP preference. By default we prefer IPv6 with fallback to IPv4.
  -p, --domain-fronting-port=443       A port to access for domain fronting.
  -n, --doh-ip=9.9.9.9                 IP address of DNS-over-HTTP to use.
  -t, --timeout=10s                    Network timeout to use
  -a, --antireplay-cache-size="1MB"    A size of anti-replay cache to use.

So, if you want to startup a proxy with CLI only, you can do something like

$ mtg simple-run -n 1.1.1.1 -t 30s -a 512kib 127.0.0.1:3128 7hBO-dCS4EBzenlKbdLFxyNnb29nbGUuY29t

The rest of the configuration will be taken from default values. But a simple run is fine if you do not have any special requirements or granular tuning. If you want it, please checkout the configuration files.

Prepare a configuration file

Please checkout an example configuration file. All options except of secret and bind-to are optional. You can safely have this minimal configuration file:

secret = "ee473ce5d4958eb5f968c87680a23854a0676f6f676c652e636f6d"
bind-to = "0.0.0.0:443"

This is enough to run the whole application. All other options already have sensible defaults for the app at almost any scale.

Oh, the configuration is done in TOML format.

Run a proxy

Put a binary and a config into your webserver. Just for example, a binary goes to /usr/local/bin/mtg and configuration to /etc/mtg.toml.

Now you can create a systemd unit:

$ cat /etc/systemd/system/mtg.service
[Unit]
Description=mtg - MTProto proxy server
Documentation=https://github.com/9seconds/mtg
After=network.target

[Service]
ExecStart=/usr/local/bin/mtg run /etc/mtg.toml
Restart=always
RestartSec=3
DynamicUser=true
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl enable mtg
$ sudo systemctl start mtg

or you can run a docker image

docker run -d -v $PWD/config.toml:/config.toml -p 443:3128 --name mtg-proxy --restart=unless-stopped nineseconds/mtg:2

where 443 is a host port (a port you want to connect to from a client), and 3128 is the one you have in your config in the bind-to section.

Access a proxy

Now you can generate some useful links:

$ mtg access /etc/mtg.toml
{
  "ipv4": {
    "ip": "x.y.z.a",
    "port": 3128,
    "tg_url": "tg://proxy?...",
    "tg_qrcode": "https://api.qrserver.com/v1/create-qr-code?data...",
    "tme_url": "https://t.me/proxy?...",
    "tme_qrcode": "https://api.qrserver.com/v1/create-qr-code?data..."
  },
  "secret": {
    "hex": "...",
    "base64": "..."
  }
}

or if you are using docker:

$ docker exec mtg-proxy /mtg access /config.toml

Metrics

Out of the box, mtg works with statsd and Prometheus. Please check configuration file example to get how to set this integration up.

Here goes a list of metrics with their types but without a prefix.

Name Type Tags Description
client_connections gauge ip_family Count of processing client connections.
telegram_connections gauge telegram_ip, dc Count of connections to Telegram servers.
domain_fronting_connections gauge ip_family Count of connections to fronting domain.
iplist_size gauge ip_list A size of either allowlist or blocklist in use.
telegram_traffic counter telegram_ip, dc, direction Count of bytes, transmitted to/from Telegram.
domain_fronting_traffic counter direction Count of bytes, transmitted to/from fronting domain.
domain_fronting counter Count of domain fronting events.
concurrency_limited counter Count of events, when client connection was rejected due to concurrency limit.
ip_blocklisted counter ip_list Count of events when client connection was rejected because IP was found in the blocklist.
replay_attacks counter Count of detected replay attacks.

Tag meaning:

Name Values Description
ip_family ipv4, ipv6 A version of the IP protocol.
dc A number of the Telegram DC for a connection.
telegram_ip IP address of the Telegram server.
direction to_client, from_client A direction of the traffic flow.
ip_list allowlist, blocklist A type of the IP list.

mtg's People

Contributors

9seconds avatar a68366 avatar ahohnmyc avatar arashnm80 avatar arch-btw avatar biozz avatar boypt avatar dank-del avatar dariubs avatar eternity-yarr avatar hdid avatar im-kulikov avatar k900 avatar pexcn avatar rhoggs-bot-test-account avatar rlex avatar savely-krasovsky avatar shhaayyaan avatar strangecamelcaselogin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtg's Issues

"Cannot pump sockets" in log

Hello!
Works fine, but the stderr log is full of messages "Cannot pump sockets", "Cannot read stream ciphered data".
Run it under CentOS 7 without docker in secret only mode at VPS based in England (log in verbose mode). Tried both to download ready to run file at "Releases" and build it ("Master" branch) - issue exists in both cases.

{"level":"warn","ts":1551001510.551488,"logger":"conn.stream-cipher","msg":"Cannot pump sockets","connection_id":"60e8701b-0070-4acc-8d63-08c4084d7fd1","local_address":"185.133.192.131:2309","remote_address":"37.204.77.54:38868","purpose":"client","faked_local_addr":"185.133.192.131:2309","error":"Cannot read stream ciphered data: read tcp 185.133.192.131:2309->37.204.77.54:38868: i/o timeout","errorVerbose":"read tcp 185.133.192.131:2309->37.204.77.54:38868: i/o timeout\n/home/mtg_proto/mtg-master/wrappers/streamcipher.go:24: Cannot read stream ciphered data"}
{"level":"warn","ts":1551001510.5516129,"logger":"conn.stream-cipher","msg":"Cannot pump sockets","connection_id":"60e8701b-0070-4acc-8d63-08c4084d7fd1","local_address":"[2a06:8ec0:3::1:12d7]:22251","remote_address":"[2001:67c:4e8:f002::a]:443","purpose":"telegram","faked_local_addr":"[2a06:8ec0:3::1:12d7]:22251"
,"error":"Cannot read stream ciphered data: read tcp [2a06:8ec0:3::1:12d7]:22251->[2001:67c:4e8:f002::a]:443: use of closed network connection","errorVerbose
":"read tcp [2a06:8ec0:3::1:12d7]:22251->[2001:67c:4e8:f002::a]:443: use of closed network connection\n/home/mtg_proto/mtg-master/wrappers/streamcipher.go:24: Cannot read stream ciphered data"}
{"level":"warn","ts":1551001634.9258738,"logger":"conn.stream-cipher","msg":"Cannot pump sockets","connection_id":"b7cddd0d-371a-4fc8-a2e9-f7f997fe7bc5","local_address":"185.133.192.131:2309","remote_address":"37.204.77.54:38886","purpose":"client","faked_local_addr":"185.133.192.131:2309","error":"Cannot read stream ciphered data: read tcp 185.133.192.131:2309->37.204.77.54:38886: i/o timeout","errorVerbose":"read tcp 185.133.192.131:2309->37.204.77.54:38886: i/o timeout\n/home/mtg_proto/mtg-master/wrappers/streamcipher.go:24: Cannot read stream ciphered data"}
{"level":"warn","ts":1551001634.9259834,"logger":"conn.stream-cipher","msg":"Cannot pump sockets","connection_id":"b7cddd0d-371a-4fc8-a2e9-f7f997fe7bc5","local_address":"[2a06:8ec0:3::1:12d7]:26165","remote_address":"[2001:67c:4e8:f002::a]:443","purpose":"telegram","faked_local_addr":"[2a06:8ec0:3::1:12d7]:26165"
,"error":"Cannot read stream ciphered data: read tcp [2a06:8ec0:3::1:12d7]:26165->[2001:67c:4e8:f002::a]:443: use of closed network connection","errorVerbose
":"read tcp [2a06:8ec0:3::1:12d7]:26165->[2001:67c:4e8:f002::a]:443: use of closed network connection\n/home/mtg_proto/mtg-master/wrappers/streamcipher.go:24: Cannot read stream ciphered data"}
{"level":"warn","ts":1551001759.0788708,"logger":"conn.stream-cipher","msg":"Cannot pump sockets","connection_id":"04f00825-beaa-4b48-882a-fa3577ea412c","local_address":"185.133.192.131:2309","remote_address":"37.204.77.54:38894","purpose":"client","faked_local_addr":"185.133.192.131:2309","error":"Cannot read stream ciphered data: read tcp 185.133.192.131:2309->37.204.77.54:38894: i/o timeout","errorVerbose":"read tcp 185.133.192.131:2309->37.204.77.54:38894: i/o timeout\n/home/mtg_proto/mtg-master/wrappers/streamcipher.go:24: Cannot read stream ciphered data"}

Unable to build

I try to build this way:

go get -v -u github.com/mtProtoProxy/mtg

At the end I get this:

go/src/src/github.com/mtProtoProxy/mtg/main.go:144:31: not enough arguments in call to config.NewConfig
have (bool, bool, uint32, uint32, net.IP, net.IP, net.IP, net.IP, uint16, uint16, uint16, uint16, uint16, string, string, string, string, map[string]string, []byte, []byte)
want (bool, bool, uint32, uint32, net.IP, net.IP, net.IP, net.IP, uint16, uint16, uint16, uint16, uint16, string, string, string, string, map[string]string, string, bool, []byte, []byte)
go/src/src/github.com/mtProtoProxy/mtg/main.go:191:12: undefined: stats.Start

===

Am I doing something wrong or there is a bug?

SYS: Centos 7

error running

hi matser
how can i fix it?

root@0x9a:~/mtg# ./run-mtg.sh
Using default tag: latest
latest: Pulling from nineseconds/mtg
Digest: sha256:8d78d690a0aa139521db17140720946d21ce150d254b5c39cbea02c948dad6a0
Status: Image is up to date for nineseconds/mtg:latest
31a26a9b2ea6
222813751c4a91dcaa26cb00051f216b1fd40b915f1fcb4901d1c102874b916c
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:402: container init caused "open /proc/sys/net/ipv4/tcp_rmem: no such file or directory"": unknown.

Async stats

Current stats implementation is blocking. Even if we use atomic. Let's go OTP way and create goroutines for updating stats.

Cannot start with adtag at all, without it works with some warns

Without adtag works but with erros in log:

{
  "level": "error",
  "ts": 1531255859.299111,
  "logger": "main",
  "msg": "Cannot initialize client connection",
  "connection_id": "57c86d29-b0a8-48d5-94cc-2c81482319b7",
  "error": "Cannot parse obfuscated frame: Unknown protocol: Unknown handshake protocol",
  "errorVerbose": "/home/vagrant/safe/go/src/github.com/9seconds/mtg/mtproto/connection_options.go:79: Unknown handshake protocol\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/obfuscated2/obfuscated2.go:40: Unknown protocol\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/client/direct.go:45: Cannot parse obfuscated frame"
}

With it can't connect at all:

{
  "level": "error",
  "ts": 1531256123.8771994,
  "logger": "main",
  "msg": "Cannot initialize server connection",
  "connection_id": "6f294179-cdfa-43b0-bcf4-d53e1c49eae2",
  "error": "Cannot handshake telegram: Cannot read RPC nonce response: Cannot read frame padding: EOF",
  "errorVerbose": "EOF\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:52: Cannot read frame padding\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/telegram/middle.go:71: Cannot read RPC nonce response\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:103: Cannot handshake telegram"
}

My VPS is under NAT so I provide port, local and public addressed. I use precompiled binary from Releases.

IP адрес

Добрый день
Возможно ли чтобы ip адрес клиента не отправлялся на сервер телеграм. Чтобы все клиенты представлялись ip адресом сервера mtprotoproxy. Если не правильно выразился пожалуйста поправьте.

Humanize statistics

Even if we have clear statistics some numbers are not easily readable by humans (iterm2 helps but not everyone has it). Let's use go-humanize or something like that for marshaling such items.

Not connected

log:

{
"ipv4": {
"tg_url": "tg://proxy?port=8946&secret=dd5524ee2e3a7015045f12934417b947f0&server=x.x.x.x",
"tme_url": "https://t.me/proxy?port=8946&secret=dd5524ee2e3a7015045f12934417b947f0&server=x.x.x.x",
"tg_qrcode": "https://api.qrserver.com/v1/create-qr-code?data=tg%3A%2F%2Fproxy%3Fport%3D8946%26secret%3Ddd5524ee2e3a7015045f12934417b947f0%26server%3Dx.x.x.x&format=svg&qzone=4",
"tme_qrcode": "https://api.qrserver.com/v1/create-qr-code?data=tg%3A%2F%2Fproxy%3Fport%3D8946%26secret%3Ddd5524ee2e3a7015045f12934417b947f0%26server%3Dx.x.x.x&format=svg&qzone=4"
},
"ipv6": {
"tg_url": "",
"tme_url": "",
"tg_qrcode": "",
"tme_qrcode": ""
},
"secret_for_mtproxybot": "5524ee2e3a7015045f12934417b947f0"
}
{"level":"error","ts":1541425163.1271372,"logger":"main","msg":"Cannot initialize client connection","connection_id":"e6e5d5e4-bff4-4e9d-a494-524308aebd48","error":"Cannot extract frame: Cannot extract obfuscated header: read tcp x.x.x.x:8946->x.x.x.x:22870: i/o timeout","errorVerbose":"read tcp x.x.x.x:8946->x.x.x.x:22870: i/o timeout\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/obfuscated2/frame.go:87: Cannot extract obfuscated header\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/client/direct.go:36: Cannot extract frame"}
{"level":"error","ts":1541425163.77422,"logger":"main","msg":"Cannot initialize client connection","connection_id":"61db5fa5-50fc-4f6f-b261-347e5381df68","error":"Cannot extract frame: Cannot extract obfuscated header: read tcp x.x.x.x:8946->x.x.x.x:22879: i/o timeout","errorVerbose":"read tcp x.x.x.x:8946->x.x.x.x:22879: i/o timeout\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/obfuscated2/frame.go:87: Cannot extract obfuscated header\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/client/direct.go:36: Cannot extract frame"}
{"level":"error","ts":1541425163.7894843,"logger":"main","msg":"Cannot initialize client connection","connection_id":"5a8ab790-681f-4e6b-b8ff-02a844a6b4d0","error":"Cannot extract frame: Cannot extract obfuscated header: read tcp x.x.x.x:8946->x.x.x.x:22880: i/o timeout","errorVerbose":"read tcp x.x.x.x:8946->x.x.x.x:22880: i/o timeout\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/obfuscated2/frame.go:87: Cannot extract obfuscated header\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/client/direct.go:36: Cannot extract frame"}

What is wrong?how to fix it?

обновление с сохранением секрета

а как правильно докер обновлять, я каждый раз секрет везде переставляю, наверно можно как-то по феншую делать, а то если несколько устройств менять на каждом утомительно
запускаю я его в secure mode на 443 порту вот так:
docker run --name mtg --restart=always -p 443:443 -p 3129:3129 -d nineseconds/mtg:latest dd$(openssl rand -hex 16) --secure-only --public-ipv4 ххх.xxx.xxx.xxх --bind-port 443
где ххх - ip адрес vps'ки
в документации этот вопрос вроде не освещён

Multiple ports

Are there any ways to listen on multiple ports? If not, than let is be feature request.

Cannot parse obfuscated frame: Unknown protocol: Unknown handshake protocol

version: '2'
services:
  mtg:
    image: nineseconds/mtg:latest
    restart: always
    ports:
     - "8848:8848/tcp"
    environment:
     - MTG_PORT=8848
    command: 4cf9XX44c

same with dd4cf9XX44c and mtg:stable, but it works for my apps, it's "old app" errors?

mtg_1 | {"level":"error","ts":1540717142.1215146,"logger":"main","msg":"Cannot initialize client connection","connection_id":"f613f242-23b1-4508-8c47-94f2b408b2a8","error":"Cannot parse obfuscated frame: Unknown protocol: Unknown handshake protocol","errorVerbose":"github.com/9seconds/mtg/mtproto/connection_options.go:86: Unknown handshake protocol\ngithub.com/9seconds/mtg/obfuscated2/obfuscated2.go:40: Unknown protocol\ngithub.com/9seconds/mtg/client/direct.go:43: Cannot parse obfuscated frame"} mtg_1 | {"level":"error","ts":1540717142.6385324,"logger":"main","msg":"Cannot initialize client connection","connection_id":"cba5e4ef-4286-454f-99ea-b4a071f6208a","error":"Cannot parse obfuscated frame: Unknown protocol: Unknown handshake protocol","errorVerbose":"github.com/9seconds/mtg/mtproto/connection_options.go:86: Unknown handshake protocol\ngithub.com/9seconds/mtg/obfuscated2/obfuscated2.go:40: Unknown protocol\ngithub.com/9seconds/mtg/client/direct.go:43: Cannot parse obfuscated frame"}

Export stats

I cannot manage all known monitoring systems available so we need to support either collectd or statsd. All these tools support export to Prometheus, Graphite etc so I think it makes sense to export to those aggregators first.

adtag problems

Добрый день!
При попытке запуска в докере с указанием adtag в лог валится ошибка:
{"level":"error","ts":1549551762.0736535,"logger":"main","msg":"Cannot initialize server connection","connection_id":"0da214ef-e6db-40d9-a66c-f22152d2f272","error":"Cannot handshake telegram: Cannot read RPC handshake response: Cannot read frame padding: Cannot read from socket: EOF","errorVerbose":"EOF\ngithub.com/9seconds/mtg/wrappers/blockcipher.go:37: Cannot read from socket\ngithub.com/9seconds/mtg/wrappers/mtproto_frame.go:52: Cannot read frame padding\ngithub.com/9seconds/mtg/telegram/middle.go:100: Cannot read RPC handshake response\ngithub.com/9seconds/mtg/proxy/proxy.go:118: Cannot handshake telegram"}
Клиенты при этом не подключаются.
Запускать пытался вот так:
docker run --name mtg-latest --restart=unless-stopped -p 8888:3128 -p 3129:3129 -d nineseconds/mtg:latest -s <ddsecret> <adtag>
При запуске без adtag все прекрасно работает. Пробовал на stable и latest.
Может быть опять какие-то изменения в API, как этом issue?

Rework stats

I do not like the mess I did there. I need to sit and rework the whole module, to avoid global locks in statsd client.

Enforce secure mode

Seems like RKN now banning proxies based on protocol fingerprint.
Iran was fast at figuring it out: TelegramMessenger/MTProxy#35
Secure mode with random padding helps (at least for now)
Might be good idea to set secure mode by default and allow disabling it via ENV/config.

Slowly connect

hi master i'm use
4096mb/DDR4
3000MHZ CPU 2

my connection is 400 but connection is very slowly how can up it!?

Why would it cause error when using ADTag ?

My command line parameters :

./mtg-freebsd-amd64 -b 0.0.0.0 -p 5258 -s ddMY_KEY MY_ADTAG
{
  "ipv4": {
    "tg_url": "tg://proxy?port=5258&secret=ddMY_KEY&server=1.70.171.49",
    "tme_url": "https://t.me/proxy?port=5258&secret=ddMY_KEY&server=1.70.171.49",
    "tg_qrcode": "https://api.qrserver.com/v1/create-qr-code?data=tg%3A%2F%2Fproxy%3Fport%3D5258%26secret%3DddMY_KEY%26server%3D1.70.171.49&format=svg&qzone=4",
    "tme_qrcode": "https://api.qrserver.com/v1/create-qr-code?data=tg%3A%2F%2Fproxy%3Fport%3D5258%26secret%3DddMY_KEY%26server%3D1.70.171.49&format=svg&qzone=4"
  },
  "ipv6": {
    "tg_url": "",
    "tme_url": "",
    "tg_qrcode": "",
    "tme_qrcode": ""
  },
  "secret_for_mtproxybot": "MY_KEY"
}

If I use the command without the Adtag , the proxy run well and all my client could connect through the mtg proxy server . But , if I run the command with the Adtag , I got the bellow errors :

{"level":"error","ts":1555787930.6312413,"logger":"main","msg":"Cannot initialize server connection","connection_id":"f9f96d1c-ad40-46dc-93ce-86257d9485f5","error":"Cannot handshake telegram: Cannot read RPC handshake response: Cannot read frame padding: Cannot read from socket: EOF","errorVerbose":"EOF\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/blockcipher.go:37: Cannot read from socket\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:52: Cannot read frame padding\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/telegram/middle.go:100: Cannot read RPC handshake response\n/home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:118: Cannot handshake telegram"}

in the issue #65 https://github.com/9seconds/mtg/issues/65 , the reason was caused by time sync , but I checked my time , it was all right and I run NTP as background service.

So ,how could I resolve the problem ?

my system is FreeBSD 12.0 .

Base cleanup

Well, it is time to make a general cleanup and simplify the structure of the application. The initial version was done with another idea in mind and now looks awkward and clunky.

--version reports incorrect version

FYI:

lex@tga-1 ⇣⇡ ❯ wget https://github.com/9seconds/mtg/releases/download/0.15/mtg-linux-amd64
lex@tga-1 ⇣⇡ ❯ chmod 0750 mtg-linux-amd64
lex@tga-1 ⇣⇡ ❯ ./mtg-linux-amd64 --version
0.12-14-gac33abb (go version go1.11.1 linux/amd64) [Wed, 10 Oct 2018 10:48:20 +0000]

Public IP detection is broken

IP [my ipv6] is not IPv4

Public IP detection is broken because DNS records of v4.ifconfig.co/v6.ifconfig.co both contains IPv4 and IPv6 addresses now:

$ host v4.ifconfig.co 1.1.1.1
Using domain server:
Name: 1.1.1.1
Address: 1.1.1.1#53
Aliases:

v4.ifconfig.co has address 104.28.3.88
v4.ifconfig.co has address 104.28.2.88
v4.ifconfig.co has IPv6 address 2400:cb00:2048:1::681c:358
v4.ifconfig.co has IPv6 address 2400:cb00:2048:1::681c:258
$ host v6.ifconfig.co 1.1.1.1
Using domain server:
Name: 1.1.1.1
Address: 1.1.1.1#53
Aliases:

v6.ifconfig.co has address 104.28.3.88
v6.ifconfig.co has address 104.28.2.88
v6.ifconfig.co has IPv6 address 2400:cb00:2048:1::681c:358
v6.ifconfig.co has IPv6 address 2400:cb00:2048:1::681c:25

Constantly out of memory

I have experienced 3 out of memory error this day. My machine has 1GB memory and is dedicated to run this proxy. And I am the only user of it.

Parameter I used: -d -v -s

Log:

fatal error: runtime: out of memory

runtime stack:
runtime.throw(0x96f8dc, 0x16)
        /snap/go/2890/src/runtime/panic.go:608 +0x72
runtime.sysMap(0xc004000000, 0x68000000, 0xda7a38)
        /snap/go/2890/src/runtime/mem_linux.go:156 +0xc7
runtime.(*mheap).sysAlloc(0xd8e640, 0x68000000, 0x0, 0x0)
        /snap/go/2890/src/runtime/malloc.go:619 +0x1c7
runtime.(*mheap).grow(0xd8e640, 0x3393a, 0x0)
        /snap/go/2890/src/runtime/mheap.go:920 +0x42
runtime.(*mheap).allocSpanLocked(0xd8e640, 0x3393a, 0xda7a48, 0x0)
        /snap/go/2890/src/runtime/mheap.go:848 +0x337
runtime.(*mheap).alloc_m(0xd8e640, 0x3393a, 0xc000040101, 0xc000000001)
        /snap/go/2890/src/runtime/mheap.go:692 +0x119
runtime.(*mheap).alloc.func1()
        /snap/go/2890/src/runtime/mheap.go:759 +0x4c
runtime.(*mheap).alloc(0xd8e640, 0x3393a, 0xc000010101, 0x8a6600)
        /snap/go/2890/src/runtime/mheap.go:758 +0x8a
runtime.largeAlloc(0x672724d1, 0x101, 0x136)
        /snap/go/2890/src/runtime/malloc.go:1019 +0x97
runtime.mallocgc.func1()
        /snap/go/2890/src/runtime/malloc.go:914 +0x46
runtime.systemstack(0x0)
        /snap/go/2890/src/runtime/asm_amd64.s:351 +0x66
runtime.mstart()
        /snap/go/2890/src/runtime/proc.go:1229

goroutine 5482 [running]:
runtime.systemstack_switch()
        /snap/go/2890/src/runtime/asm_amd64.s:311 fp=0xc000201c08 sp=0xc000201c00 pc=0x457800
runtime.mallocgc(0x672724d1, 0x8a7d80, 0x1, 0xc000201ce0)
        /snap/go/2890/src/runtime/malloc.go:913 +0x896 fp=0xc000201ca8 sp=0xc000201c08 pc=0x40d9d6
runtime.makeslice(0x8a7d80, 0x672724d1, 0x672724d1, 0x4, 0x8, 0xc00045ae00)
        /snap/go/2890/src/runtime/slice.go:70 +0x77 fp=0xc000201cd8 sp=0xc000201ca8 pc=0x442947
bytes.makeSlice(0x672724d1, 0x0, 0x0, 0x0)
        /snap/go/2890/src/bytes/buffer.go:231 +0x6d fp=0xc000201d18 sp=0xc000201cd8 pc=0x46d19d
bytes.(*Buffer).grow(0xc00030bce0, 0x67271fd1, 0x8)
        /snap/go/2890/src/bytes/buffer.go:144 +0x15a fp=0xc000201d68 sp=0xc000201d18 pc=0x46cb0a
bytes.(*Buffer).Grow(0xc00030bce0, 0x67271fd1)
        /snap/go/2890/src/bytes/buffer.go:163 +0x3a fp=0xc000201d90 sp=0xc000201d68 pc=0x46ccba
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediate).Read(0xc000135ec0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate.go:60 +0x43a
 fp=0xc000201ed0 sp=0xc000201d90 pc=0x846e5a
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediateSecure).Read(0xc000135ec0, 0x9897d8, 0xc00024b
330, 0xc00009c900, 0xc00003ef68, 0xc00003ef68)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate_secure.go:19
 +0x31 fp=0xc000201f10 sp=0xc000201ed0 pc=0x847601
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e340, 0xc000135ec0, 0x7fc0
6d64e380, 0xc00013ed80, 0xc00024b330, 0xc000310da4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83 fp=0xc000201fa8 s
p=0xc000201f10 pc=0x851d53
runtime.goexit()
        /snap/go/2890/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc000201fb0 sp=0xc000201fa8 pc=0x4598e1
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:95 +0x8f6

goroutine 1 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d635d60, 0x72, 0x0)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0000b9018, 0x72, 0xc00009c900, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0000b9018, 0xffffffffffffff00, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Accept(0xc0000b9000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:384 +0x1a0
net.(*netFD).accept(0xc0000b9000, 0xc00000e288, 0x0, 0x0)
        /snap/go/2890/src/net/fd_unix.go:238 +0x42
net.(*TCPListener).accept(0xc0000982d8, 0xc0000cd9f0, 0xc0000cd9f8, 0x18)
        /snap/go/2890/src/net/tcpsock_posix.go:139 +0x2e
net.(*TCPListener).Accept(0xc0000982d8, 0x9880e0, 0xc00025e920, 0x9fcae0, 0xc00000e288)
        /snap/go/2890/src/net/tcpsock.go:260 +0x47
github.com/9seconds/mtg/proxy.(*Proxy).Serve(0xc00025e920, 0xc00025e920, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:36 +0xae
main.main()
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/main.go:208 +0x9a7

goroutine 38 [select]:
github.com/9seconds/mtg/stats.(*Stats).start(0xc000020800)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/stats/stats.go:108 +0x156
created by github.com/9seconds/mtg/stats.Init
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/stats/init.go:24 +0xe8

goroutine 39 [IO wait, 386 minutes]:
internal/poll.runtime_pollWait(0x7fc06d635f00, 0x72, 0x0)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0000b8a18, 0x72, 0xc000062200, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0000b8a18, 0xffffffffffffff00, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Accept(0xc0000b8a00, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:384 +0x1a0
net.(*netFD).accept(0xc0000b8a00, 0xd89120, 0x30, 0x30)
        /snap/go/2890/src/net/fd_unix.go:238 +0x42
net.(*TCPListener).accept(0xc000098280, 0x50, 0x7fc06d691000, 0x0)
        /snap/go/2890/src/net/tcpsock_posix.go:139 +0x2e
net.(*TCPListener).AcceptTCP(0xc000098280, 0x40dcb8, 0x30, 0x9250a0)
        /snap/go/2890/src/net/tcpsock.go:247 +0x47
net/http.tcpKeepAliveListener.Accept(0xc000098280, 0x9250a0, 0xc000135b60, 0x8cd520, 0xd79e40)
        /snap/go/2890/src/net/http/server.go:3232 +0x2f
net/http.(*Server).Serve(0xc0004360d0, 0x9f9ca0, 0xc000098280, 0x0, 0x0)
        /snap/go/2890/src/net/http/server.go:2826 +0x22f
net/http.(*Server).ListenAndServe(0xc0004360d0, 0xc0004360d0, 0xe)
        /snap/go/2890/src/net/http/server.go:2764 +0xb6
net/http.ListenAndServe(0xc000454970, 0xe, 0x0, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/http/server.go:3004 +0x74
github.com/9seconds/mtg/stats.startServer(0xc00011e690, 0x9f4c20, 0xc0004c05a0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/stats/server.go:37 +0xf8
created by github.com/9seconds/mtg/stats.Init
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/stats/init.go:25 +0x12c

goroutine 37 [chan receive]:
github.com/9seconds/mtg/stats.(*prometheusExporter).run(0xc0002b8380)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/stats/prometheus.go:26 +0xb8
created by github.com/9seconds/mtg/stats.Init
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/stats/init.go:22 +0xb8

goroutine 15 [chan receive]:
github.com/9seconds/mtg/ntp.AutoUpdate()
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/ntp/ntp.go:42 +0xac
created by main.main
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/main.go:197 +0x964

goroutine 50 [chan receive, 26 minutes]:
github.com/9seconds/mtg/telegram.(*middleTelegramCaller).autoUpdate(0xc0000d8790)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/telegram/middle_caller.go:55 +0x77
created by github.com/9seconds/mtg/telegram.NewMiddleTelegram
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/telegram/middle.go:136 +0x10a

goroutine 5452 [IO wait, 1 minutes]:
internal/poll.runtime_pollWait(0x7fc06d655538, 0x72, 0xc00018d988)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4c18, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4c18, 0xc000518500, 0x4, 0x280)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4c00, 0xc000518500, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4c00, 0xc000518500, 0x4, 0x280, 0x1520d391c7b8, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc00000e240, 0xc000518500, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc0000b48c0, 0xc000518500, 0x4, 0x280, 0xc000518500,
0x280, 0x280)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/wrappers.(*StreamCipher).Read(0xc0002f0b40, 0xc000518500, 0x4, 0x280, 0x280,
 0x280, 0xc000518500)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/streamcipher.go:22 +0x56
io.(*LimitedReader).Read(0xc000250d60, 0xc000518500, 0x280, 0x280, 0x0, 0x203000, 0xc00018dc68)
        /snap/go/2890/src/io/io.go:448 +0x63
bytes.(*Buffer).ReadFrom(0xc0005005b0, 0x9f3ba0, 0xc000250d60, 0x7fc06d64e158, 0xc0005005b0, 0x1)
        /snap/go/2890/src/bytes/buffer.go:206 +0xb4
io.copyBuffer(0x9f3760, 0xc0005005b0, 0x9f3ba0, 0xc000250d60, 0x0, 0x0, 0x0, 0x8f9980, 0x7fc06d64e40
1, 0xc000250d60)
        /snap/go/2890/src/io/io.go:388 +0x303
io.Copy(0x9f3760, 0xc0005005b0, 0x9f3ba0, 0xc000250d60, 0x9068e0, 0x0, 0x7fc06d64e440)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3760, 0xc0005005b0, 0x7fc06d64e440, 0xc0002f0b40, 0x4, 0x6, 0x0, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediate).Read(0xc00013e360, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate.go:42 +0x222
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediateSecure).Read(0xc00013e360, 0xc000153100, 0xfc,
 0x700, 0xfc, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate_secure.go:19
 +0x31
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e340, 0xc00013e360, 0x7fc0
6d64e380, 0xc00013e450, 0xc00024aa60, 0xc0000289f4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:95 +0x8f6

goroutine 5481 [chan receive]:
github.com/9seconds/mtg/proxy.(*Proxy).accept.func2(0x9fa0a0, 0xc00009ca80, 0x7fc06d64e2f0, 0xc00013
ed80, 0x7fc06d5fa5c8, 0xc000135ec0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:84 +0x4c
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:83 +0x74f

goroutine 5451 [chan receive, 1 minutes]:
github.com/9seconds/mtg/proxy.(*Proxy).accept.func2(0x9fa0a0, 0xc0002f0a80, 0x7fc06d64e2f0, 0xc00013
e450, 0x7fc06d5fa5c8, 0xc00013e360)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:84 +0x4c
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:83 +0x74f

goroutine 5459 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d655398, 0x72, 0xc0000e7528)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4418, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4418, 0xc00055d200, 0x401, 0x401)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4400, 0xc00055d200, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4400, 0xc00055d200, 0x401, 0x401, 0x153113678837, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc000098018, 0xc00055d200, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc000500ee0, 0xc00055d200, 0x401, 0x401, 0x401, 0x401
, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/utils.ReadCurrentData(0x7fc06d64e2b0, 0xc000500ee0, 0xc000500ee0, 0x7fc06d64
e2b0, 0xc000500ee0, 0x0, 0x4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/utils/read_current_data.go:13 +0x107
github.com/9seconds/mtg/wrappers.(*BlockCipher).Read(0xc00009c5c0, 0xc0004540ac, 0x4, 0x4, 0x8a7d80,
 0x1, 0xc0004540ac)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/blockcipher.go:35 +0xf9
io.(*LimitedReader).Read(0xc0001c6240, 0xc0004540ac, 0x4, 0x4, 0x4, 0x4, 0x10)
        /snap/go/2890/src/io/io.go:448 +0x63
io.copyBuffer(0x9f3be0, 0xc0001c61e0, 0x9f3ba0, 0xc0001c6240, 0xc0004540ac, 0x4, 0x4, 0x8f9980, 0x7f
c06d5fa601, 0xc0001c6240)
        /snap/go/2890/src/io/io.go:402 +0x125
io.Copy(0x9f3be0, 0xc0001c61e0, 0x9f3ba0, 0xc0001c6240, 0x9176c0, 0x0, 0x7fc06d5fa678)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3be0, 0xc0001c61e0, 0x7fc06d5fa678, 0xc00009c5c0, 0x4, 0x4, 0x1, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoFrame).Read(0xc00027abe0, 0x96a200, 0xb, 0xc0000e7c00, 0x6
, 0x6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:51 +0x192
github.com/9seconds/mtg/wrappers.(*MTProtoProxy).Read(0xc00013e420, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_proxy.go:36 +0x1e6
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e3a0, 0xc00013e420, 0x7fc0
6d64e3e0, 0xc000134cf0, 0xc0002287f0, 0xc000310606)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
github.com/9seconds/mtg/proxy.(*Proxy).accept(0xc00025e920, 0x9fcae0, 0xc00000e020)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:96 +0x9aa
created by github.com/9seconds/mtg/proxy.(*Proxy).Serve
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:39 +0x18e

goroutine 3494 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d635470, 0x72, 0xc000485988)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4118, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4118, 0xc00052ec00, 0x4, 0x280)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4100, 0xc00052ec80, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4100, 0xc00052ec80, 0x4, 0x280, 0x152f92b58175, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc00000e018, 0xc00052ec80, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc00030a0e0, 0xc00052ec80, 0x4, 0x280, 0xc00052ec80,
0x280, 0x280)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/wrappers.(*StreamCipher).Read(0xc00009c100, 0xc00052ec80, 0x4, 0x280, 0x280,
 0x280, 0xc00052ec80)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/streamcipher.go:22 +0x56
io.(*LimitedReader).Read(0xc000215120, 0xc00052ec80, 0x280, 0x280, 0x0, 0x203000, 0xc000485c68)
        /snap/go/2890/src/io/io.go:448 +0x63
bytes.(*Buffer).ReadFrom(0xc0000d6380, 0x9f3ba0, 0xc000215120, 0x7fc06d64e158, 0xc0000d6380, 0x1)
        /snap/go/2890/src/bytes/buffer.go:206 +0xb4
io.copyBuffer(0x9f3760, 0xc0000d6380, 0x9f3ba0, 0xc000215120, 0x0, 0x0, 0x0, 0x8f9980, 0x7fc06d64e40
1, 0xc000215120)
        /snap/go/2890/src/io/io.go:388 +0x303
io.Copy(0x9f3760, 0xc0000d6380, 0x9f3ba0, 0xc000215120, 0x9068e0, 0x0, 0x7fc06d64e440)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3760, 0xc0000d6380, 0x7fc06d64e440, 0xc00009c100, 0x4, 0x6, 0x0, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediate).Read(0xc000083f50, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate.go:42 +0x222
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediateSecure).Read(0xc000083f50, 0xc000332300, 0xb4,
 0x700, 0xb4, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate_secure.go:19
 +0x31
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e340, 0xc000083f50, 0x7fc0
6d64e380, 0xc000134690, 0xc00028c230, 0xc000310664)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:95 +0x8f6

goroutine 5439 [chan receive]:
github.com/9seconds/mtg/proxy.(*Proxy).accept.func2(0x9fa0a0, 0xc0002f0940, 0x7fc06d64e2f0, 0xc00013
e5a0, 0x7fc06d5fa5c8, 0xc00013e2a0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:84 +0x4c
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:83 +0x74f

goroutine 5465 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d5fe5e8, 0x72, 0xc000205528)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4b98, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4b98, 0xc00045e900, 0x401, 0x401)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4b80, 0xc00045e900, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4b80, 0xc00045e900, 0x401, 0x401, 0x1531332f04bc, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc0000982c8, 0xc00045e900, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc00030b9d0, 0xc00045e900, 0x401, 0x401, 0x401, 0x401
, 0xc000000000)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/utils.ReadCurrentData(0x7fc06d64e2b0, 0xc00030b9d0, 0xc00030b9d0, 0x7fc06d64
e2b0, 0xc00030b9d0, 0x0, 0x4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/utils/read_current_data.go:13 +0x107
github.com/9seconds/mtg/wrappers.(*BlockCipher).Read(0xc00009cbc0, 0xc00024b340, 0x4, 0x4, 0x8a7d80,
 0x1, 0xc00024b340)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/blockcipher.go:35 +0xf9
io.(*LimitedReader).Read(0xc00025f760, 0xc00024b340, 0x4, 0x4, 0x4, 0x4, 0x10)
        /snap/go/2890/src/io/io.go:448 +0x63
io.copyBuffer(0x9f3be0, 0xc00025f720, 0x9f3ba0, 0xc00025f760, 0xc00024b340, 0x4, 0x4, 0x8f9980, 0x7f
c06d5fa601, 0xc00025f760)
        /snap/go/2890/src/io/io.go:402 +0x125
io.Copy(0x9f3be0, 0xc00025f720, 0x9f3ba0, 0xc00025f760, 0x9176c0, 0x0, 0x7fc06d5fa678)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3be0, 0xc00025f720, 0x7fc06d5fa678, 0xc00009cbc0, 0x4, 0x4, 0x1, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoFrame).Read(0xc0001c6340, 0x96a200, 0xb, 0xc000205c00, 0x6
, 0x6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:51 +0x192
github.com/9seconds/mtg/wrappers.(*MTProtoProxy).Read(0xc00013ed80, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_proxy.go:36 +0x1e6
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e3a0, 0xc00013ed80, 0x7fc0
6d64e3e0, 0xc000135ec0, 0xc00024b330, 0xc000310da6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
github.com/9seconds/mtg/proxy.(*Proxy).accept(0xc00025e920, 0x9fcae0, 0xc00000e288)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:96 +0x9aa
created by github.com/9seconds/mtg/proxy.(*Proxy).Serve
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:39 +0x18e

goroutine 5453 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d5fee08, 0x72, 0xc0004c9528)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0000b8398, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0000b8398, 0xc00055cd00, 0x401, 0x401)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0000b8380, 0xc00055cd80, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0000b8380, 0xc00055cd80, 0x401, 0x401, 0x153112b55642, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc000098178, 0xc00055cd80, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc000513e30, 0xc00055cd80, 0x401, 0x401, 0x401, 0x401
, 0x400)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/utils.ReadCurrentData(0x7fc06d64e2b0, 0xc000513e30, 0xc000513e30, 0x7fc06d64
e2b0, 0xc000513e30, 0x203000, 0x4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/utils/read_current_data.go:13 +0x107
github.com/9seconds/mtg/wrappers.(*BlockCipher).Read(0xc0002f0980, 0xc00045401c, 0x4, 0x4, 0x8a7d80,
 0x1, 0xc00045401c)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/blockcipher.go:35 +0xf9
io.(*LimitedReader).Read(0xc0001c6160, 0xc00045401c, 0x4, 0x4, 0x4, 0x4, 0x10)
        /snap/go/2890/src/io/io.go:448 +0x63
io.copyBuffer(0x9f3be0, 0xc0001c6140, 0x9f3ba0, 0xc0001c6160, 0xc00045401c, 0x4, 0x4, 0x8f9980, 0x7f
c06d5fa601, 0xc0001c6160)
        /snap/go/2890/src/io/io.go:402 +0x125
io.Copy(0x9f3be0, 0xc0001c6140, 0x9f3ba0, 0xc0001c6160, 0x9176c0, 0xc0001c6100, 0x7fc06d5fa678)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3be0, 0xc0001c6140, 0x7fc06d5fa678, 0xc0002f0980, 0x4, 0xc000163980, 0x3, 0x6)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoFrame).Read(0xc00025f420, 0x96a200, 0xb, 0xc0004c9c00, 0x6
, 0x6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:51 +0x192
github.com/9seconds/mtg/wrappers.(*MTProtoProxy).Read(0xc00013e5a0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_proxy.go:36 +0x1e6
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e3a0, 0xc00013e5a0, 0x7fc0
6d64e3e0, 0xc00013e2a0, 0xc00028d140, 0xc000310d36)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
github.com/9seconds/mtg/proxy.(*Proxy).accept(0xc00025e920, 0x9fcae0, 0xc00000e028)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:96 +0x9aa
created by github.com/9seconds/mtg/proxy.(*Proxy).Serve
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:39 +0x18e

goroutine 3486 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d635a20, 0x72, 0xc000489528)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4398, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4398, 0xc000590400, 0x401, 0x401)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4380, 0xc000590480, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4380, 0xc000590480, 0x401, 0x401, 0x152f812aa913, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc000098028, 0xc000590480, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc0000b4000, 0xc000590480, 0x401, 0x401, 0x401, 0x401
, 0x400)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/utils.ReadCurrentData(0x7fc06d64e2b0, 0xc0000b4000, 0xc0000b4000, 0x7fc06d64
e2b0, 0xc0000b4000, 0x203000, 0x4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/utils/read_current_data.go:13 +0x107
github.com/9seconds/mtg/wrappers.(*BlockCipher).Read(0xc00009c240, 0xc000228c1c, 0x4, 0x4, 0x8a7d80,
 0x1, 0xc000228c1c)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/blockcipher.go:35 +0xf9
io.(*LimitedReader).Read(0xc000214ec0, 0xc000228c1c, 0x4, 0x4, 0x4, 0x4, 0x10)
        /snap/go/2890/src/io/io.go:448 +0x63
io.copyBuffer(0x9f3be0, 0xc000214ea0, 0x9f3ba0, 0xc000214ec0, 0xc000228c1c, 0x4, 0x4, 0x8f9980, 0x7f
c06d5fa601, 0xc000214ec0)
        /snap/go/2890/src/io/io.go:402 +0x125
io.Copy(0x9f3be0, 0xc000214ea0, 0x9f3ba0, 0xc000214ec0, 0x9176c0, 0xc000214e00, 0x7fc06d5fa678)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3be0, 0xc000214ea0, 0x7fc06d5fa678, 0xc00009c240, 0x4, 0xc000312480, 0x3, 0x6)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoFrame).Read(0xc000250200, 0x96a200, 0xb, 0xc000489c00, 0x6
, 0x6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:51 +0x192
github.com/9seconds/mtg/wrappers.(*MTProtoProxy).Read(0xc000134690, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_proxy.go:36 +0x1e6
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e3a0, 0xc000134690, 0x7fc0
6d64e3e0, 0xc000083f50, 0xc00028c230, 0xc000310666)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
github.com/9seconds/mtg/proxy.(*Proxy).accept(0xc00025e920, 0x9fcae0, 0xc00000e018)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:96 +0x9aa
created by github.com/9seconds/mtg/proxy.(*Proxy).Serve
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:39 +0x18e

goroutine 5476 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d5fe928, 0x72, 0xc0000e3988)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4018, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4018, 0xc0005b0200, 0x4, 0x280)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4000, 0xc0005b0280, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4000, 0xc0005b0280, 0x4, 0x280, 0x1530ecdedc3c, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc00000e020, 0xc0005b0280, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc0000b5340, 0xc0005b0280, 0x4, 0x280, 0xc0005b0280,
0x280, 0x280)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/wrappers.(*StreamCipher).Read(0xc00009c280, 0xc0005b0280, 0x4, 0x280, 0x280,
 0x280, 0xc0005b0280)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/streamcipher.go:22 +0x56
io.(*LimitedReader).Read(0xc00027be40, 0xc0005b0280, 0x280, 0x280, 0x0, 0x203000, 0xc0000e3c68)
        /snap/go/2890/src/io/io.go:448 +0x63
bytes.(*Buffer).ReadFrom(0xc000512f50, 0x9f3ba0, 0xc00027be40, 0x7fc06d64e158, 0xc000512f50, 0x1)
        /snap/go/2890/src/bytes/buffer.go:206 +0xb4
io.copyBuffer(0x9f3760, 0xc000512f50, 0x9f3ba0, 0xc00027be40, 0x0, 0x0, 0x0, 0x8f9980, 0x7fc06d64e40
1, 0xc00027be40)
        /snap/go/2890/src/io/io.go:388 +0x303
io.Copy(0x9f3760, 0xc000512f50, 0x9f3ba0, 0xc00027be40, 0x9068e0, 0x0, 0x7fc06d64e440)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3760, 0xc000512f50, 0x7fc06d64e440, 0xc00009c280, 0x4, 0x6, 0x0, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediate).Read(0xc000134cf0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate.go:42 +0x222
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediateSecure).Read(0xc000134cf0, 0xc000558700, 0x1a4
, 0x700, 0x1a4, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate_secure.go:19
 +0x31
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e340, 0xc000134cf0, 0x7fc0
6d64e380, 0xc00013e420, 0xc0002287f0, 0xc000310604)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:95 +0x8f6

goroutine 3493 [chan receive, 91 minutes]:
github.com/9seconds/mtg/proxy.(*Proxy).accept.func2(0x9fa0a0, 0xc00009c0c0, 0x7fc06d64e2f0, 0xc00013
4690, 0x7fc06d5fa5c8, 0xc000083f50)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:84 +0x4c
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:83 +0x74f

goroutine 5440 [IO wait]:
internal/poll.runtime_pollWait(0x7fc06d5fe6b8, 0x72, 0xc0004c5988)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4218, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4218, 0xc0005b0000, 0x4, 0x280)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4200, 0xc0005b0000, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4200, 0xc0005b0000, 0x4, 0x280, 0x1530ec2a178f, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc00000e028, 0xc0005b0000, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc000513dc0, 0xc0005b0000, 0x4, 0x280, 0xc0005b0000,
0x280, 0x280)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/wrappers.(*StreamCipher).Read(0xc00009c9c0, 0xc0005b0000, 0x4, 0x280, 0x280,
 0x280, 0xc0005b0000)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/streamcipher.go:22 +0x56
io.(*LimitedReader).Read(0xc00027bde0, 0xc0005b0000, 0x280, 0x280, 0x0, 0x203000, 0xc0004c5c68)
        /snap/go/2890/src/io/io.go:448 +0x63
bytes.(*Buffer).ReadFrom(0xc000512e00, 0x9f3ba0, 0xc00027bde0, 0x7fc06d64e158, 0xc000512e00, 0x1)
        /snap/go/2890/src/bytes/buffer.go:206 +0xb4
io.copyBuffer(0x9f3760, 0xc000512e00, 0x9f3ba0, 0xc00027bde0, 0x0, 0x0, 0x0, 0x8f9980, 0x7fc06d64e40
1, 0xc00027bde0)
        /snap/go/2890/src/io/io.go:388 +0x303
io.Copy(0x9f3760, 0xc000512e00, 0x9f3ba0, 0xc00027bde0, 0x9068e0, 0x0, 0x7fc06d64e440)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3760, 0xc000512e00, 0x7fc06d64e440, 0xc00009c9c0, 0x4, 0x6, 0x0, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediate).Read(0xc00013e2a0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate.go:42 +0x222
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediateSecure).Read(0xc00013e2a0, 0xc000558000, 0xf8,
 0x700, 0xf8, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate_secure.go:19
 +0x31
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e340, 0xc00013e2a0, 0x7fc0
6d64e380, 0xc00013e5a0, 0xc00028d140, 0xc000310d34)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:95 +0x8f6

goroutine 5449 [IO wait, 1 minutes]:
internal/poll.runtime_pollWait(0x7fc06d655468, 0x72, 0xc000191528)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0003a4e98, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0003a4e98, 0xc0005bdb00, 0x401, 0x401)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0003a4e80, 0xc0005bdb00, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0003a4e80, 0xc0005bdb00, 0x401, 0x401, 0x1520dd8bbd1f, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc000098220, 0xc0005bdb00, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc000132f50, 0xc0005bdb00, 0x401, 0x401, 0x401, 0x401
, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/utils.ReadCurrentData(0x7fc06d64e2b0, 0xc000132f50, 0xc000132f50, 0x7fc06d64
e2b0, 0xc000132f50, 0x0, 0x4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/utils/read_current_data.go:13 +0x107
github.com/9seconds/mtg/wrappers.(*BlockCipher).Read(0xc00009ca00, 0xc00024ad40, 0x4, 0x4, 0x8a7d80,
 0x1, 0xc00024ad40)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/blockcipher.go:35 +0xf9
io.(*LimitedReader).Read(0xc000251040, 0xc00024ad40, 0x4, 0x4, 0x4, 0x4, 0x10)
        /snap/go/2890/src/io/io.go:448 +0x63
io.copyBuffer(0x9f3be0, 0xc000251000, 0x9f3ba0, 0xc000251040, 0xc00024ad40, 0x4, 0x4, 0x8f9980, 0x7f
c06d5fa601, 0xc000251040)
        /snap/go/2890/src/io/io.go:402 +0x125
io.Copy(0x9f3be0, 0xc000251000, 0x9f3ba0, 0xc000251040, 0x9176c0, 0x0, 0x7fc06d5fa678)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3be0, 0xc000251000, 0x7fc06d5fa678, 0xc00009ca00, 0x4, 0x4, 0x1, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoFrame).Read(0xc00025fca0, 0x96a200, 0xb, 0xc000191c00, 0x6
, 0x6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:51 +0x192
github.com/9seconds/mtg/wrappers.(*MTProtoProxy).Read(0xc00013e450, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_proxy.go:36 +0x1e6
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e3a0, 0xc00013e450, 0x7fc0
6d64e3e0, 0xc00013e360, 0xc00024aa60, 0xc0000289f6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
github.com/9seconds/mtg/proxy.(*Proxy).accept(0xc00025e920, 0x9fcae0, 0xc00000e240)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:96 +0x9aa
created by github.com/9seconds/mtg/proxy.(*Proxy).Serve
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:39 +0x18e

goroutine 5421 [IO wait, 1 minutes]:
internal/poll.runtime_pollWait(0x7fc06d5fed38, 0x72, 0xc0005ef988)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0000b8018, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0000b8018, 0xc0002a3400, 0x4, 0x280)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0000b8000, 0xc0002a3400, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0000b8000, 0xc0002a3400, 0x4, 0x280, 0x151a776a4e00, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc000098020, 0xc0002a3400, 0x4, 0x280, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc0000d6a80, 0xc0002a3400, 0x4, 0x280, 0xc0002a3400,
0x280, 0x280)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/wrappers.(*StreamCipher).Read(0xc00009c180, 0xc0002a3400, 0x4, 0x280, 0x280,
 0x280, 0xc0002a3400)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/streamcipher.go:22 +0x56
io.(*LimitedReader).Read(0xc000215360, 0xc0002a3400, 0x280, 0x280, 0x0, 0x203000, 0xc0005efc68)
        /snap/go/2890/src/io/io.go:448 +0x63
bytes.(*Buffer).ReadFrom(0xc0000d7110, 0x9f3ba0, 0xc000215360, 0x7fc06d64e158, 0xc0000d7110, 0x1)
        /snap/go/2890/src/bytes/buffer.go:206 +0xb4
io.copyBuffer(0x9f3760, 0xc0000d7110, 0x9f3ba0, 0xc000215360, 0x0, 0x0, 0x0, 0x8f9980, 0x7fc06d64e40
1, 0xc000215360)
        /snap/go/2890/src/io/io.go:388 +0x303
io.Copy(0x9f3760, 0xc0000d7110, 0x9f3ba0, 0xc000215360, 0x9068e0, 0x0, 0x7fc06d64e440)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3760, 0xc0000d7110, 0x7fc06d64e440, 0xc00009c180, 0x4, 0x6, 0x0, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediate).Read(0xc000134b40, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate.go:42 +0x222
github.com/9seconds/mtg/wrappers.(*MTProtoIntermediateSecure).Read(0xc000134b40, 0xc000205c00, 0x94,
 0x700, 0x94, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_intermediate_secure.go:19
 +0x31
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e340, 0xc000134b40, 0x7fc0
6d64e380, 0xc000134f90, 0xc00028ce10, 0xc000310784)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:95 +0x8f6

goroutine 5418 [IO wait, 1 minutes]:
internal/poll.runtime_pollWait(0x7fc06d6353a0, 0x72, 0xc0005f3528)
        /snap/go/2890/src/runtime/netpoll.go:173 +0x66
internal/poll.(*pollDesc).wait(0xc0000b8298, 0x72, 0xffffffffffffff00, 0x9f50e0, 0xd4c6a0)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:85 +0x9a
internal/poll.(*pollDesc).waitRead(0xc0000b8298, 0xc00012e400, 0x401, 0x401)
        /snap/go/2890/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc0000b8280, 0xc00012e480, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/internal/poll/fd_unix.go:169 +0x179
net.(*netFD).Read(0xc0000b8280, 0xc00012e480, 0x401, 0x401, 0x151a81f5bcb6, 0xd88520, 0x0)
        /snap/go/2890/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc00000e008, 0xc00012e480, 0x401, 0x401, 0x0, 0x0, 0x0)
        /snap/go/2890/src/net/net.go:177 +0x68
github.com/9seconds/mtg/wrappers.(*Conn).Read(0xc000128770, 0xc00012e480, 0x401, 0x401, 0x401, 0x401
, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/conn.go:87 +0x107
github.com/9seconds/mtg/utils.ReadCurrentData(0x7fc06d64e2b0, 0xc000128770, 0xc000128770, 0x7fc06d64
e2b0, 0xc000128770, 0x0, 0x4)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/utils/read_current_data.go:13 +0x107
github.com/9seconds/mtg/wrappers.(*BlockCipher).Read(0xc0002f0900, 0xc000229330, 0x4, 0x4, 0x8a7d80,
 0x1, 0xc000229330)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/blockcipher.go:35 +0xf9
io.(*LimitedReader).Read(0xc0002513c0, 0xc000229330, 0x4, 0x4, 0x4, 0x4, 0x10)
        /snap/go/2890/src/io/io.go:448 +0x63
io.copyBuffer(0x9f3be0, 0xc000251340, 0x9f3ba0, 0xc0002513c0, 0xc000229330, 0x4, 0x4, 0x8f9980, 0x7f
c06d5fa601, 0xc0002513c0)
        /snap/go/2890/src/io/io.go:402 +0x125
io.Copy(0x9f3be0, 0xc000251340, 0x9f3ba0, 0xc0002513c0, 0x9176c0, 0x0, 0x7fc06d5fa678)
        /snap/go/2890/src/io/io.go:364 +0x5a
io.CopyN(0x9f3be0, 0xc000251340, 0x7fc06d5fa678, 0xc0002f0900, 0x4, 0x4, 0x1, 0x0)
        /snap/go/2890/src/io/io.go:340 +0x86
github.com/9seconds/mtg/wrappers.(*MTProtoFrame).Read(0xc000251180, 0x96a200, 0xb, 0xc0005f3c00, 0x6
, 0x6)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_frame.go:51 +0x192
github.com/9seconds/mtg/wrappers.(*MTProtoProxy).Read(0xc000134f90, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/wrappers/mtproto_proxy.go:36 +0x1e6
github.com/9seconds/mtg/proxy.(*Proxy).middlePipe(0xc00025e920, 0x7fc06d64e3a0, 0xc000134f90, 0x7fc0
6d64e3e0, 0xc000134b40, 0xc00028ce10, 0xc000310786)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:131 +0x83
github.com/9seconds/mtg/proxy.(*Proxy).accept(0xc00025e920, 0x9fcae0, 0xc000098020)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:96 +0x9aa
created by github.com/9seconds/mtg/proxy.(*Proxy).Serve
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:39 +0x18e

goroutine 5475 [chan receive]:
github.com/9seconds/mtg/proxy.(*Proxy).accept.func2(0x9fa0a0, 0xc00009c040, 0x7fc06d64e2f0, 0xc00013
e420, 0x7fc06d5fa5c8, 0xc000134cf0)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:84 +0x4c
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:83 +0x74f

goroutine 5420 [chan receive, 1 minutes]:
github.com/9seconds/mtg/proxy.(*Proxy).accept.func2(0x9fa0a0, 0xc00009c080, 0x7fc06d64e2f0, 0xc00013
4f90, 0x7fc06d5fa5c8, 0xc000134b40)
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:84 +0x4c
created by github.com/9seconds/mtg/proxy.(*Proxy).accept
        /home/vagrant/safe/go/src/github.com/9seconds/mtg/proxy/proxy.go:83 +0x74f

Please give me further instruction to track this down.

What is the secure mode?

Is there a spec for the secure mode (with tag '0xdd')? What's the difference between this one and the abridged mode?

Prometheus выдает метрики без префиксов

На данный момент по /prometheus/ выдается что-то вроде:

# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 1.7208e-05
go_gc_duration_seconds{quantile="0.25"} 1.9649e-05
go_gc_duration_seconds{quantile="0.5"} 3.1934e-05
go_gc_duration_seconds{quantile="0.75"} 3.7506e-05
go_gc_duration_seconds{quantile="1"} 4.7894e-05
go_gc_duration_seconds_sum 0.000328102
go_gc_duration_seconds_count 11
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 19
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.11.1"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 1.81644e+06
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 2.9329432e+07
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 1.456191e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 343729
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 6.0251014312355185e-05
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 2.379776e+06
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 1.81644e+06
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 6.3315968e+07
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 3.366912e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 13662
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 0
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 6.668288e+07
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 1.5408163657060204e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 357391
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 1728
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 16384
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 53656
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 147456
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 4.194304e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 389305
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 425984
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 425984
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 7.1497976e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 7
# HELP mtg_connections Current number of connections to the proxy.
# TYPE mtg_connections gauge
mtg_connections{protocol="v4",type="abridged"} 0
mtg_connections{protocol="v4",type="intermediate"} 0
mtg_connections{protocol="v4",type="secure"} 2
mtg_connections{protocol="v6",type="abridged"} 0
mtg_connections{protocol="v6",type="intermediate"} 0
mtg_connections{protocol="v6",type="secure"} 0
# HELP mtg_crashes How many crashes happened.
# TYPE mtg_crashes gauge
mtg_crashes 0
# HELP mtg_speed Current throughput in bytes per second.
# TYPE mtg_speed gauge
mtg_speed{direction="egress"} 0
mtg_speed{direction="ingress"} 0
# HELP mtg_traffic Traffic passed through the proxy in bytes.
# TYPE mtg_traffic gauge
mtg_traffic{direction="egress"} 1006
mtg_traffic{direction="ingress"} 878
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.46
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 4096
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 15
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.7043456e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.54081612419e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 4.99564544e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes -1
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 0
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0

С go_memstats и прочими внутренними метриками без тегов.
Настройку префикса оно игнорирует.
Можно ли пофиксить это или сделать отдельный эндпоинт только с сервисными метриками mtg_* ?

Cannot initialize client connection

Sometimes I get in logs:

{"level":"error","ts":1558105435.3307085,"logger":"main","msg":"Cannot initialize client connection","connection_id":"f4cb4c45-xxxx-xxxx-xxxx-xxxx6eccxxxx","error":"Cannot extract frame: Cannot extract obfuscated header: read tcp xx.xx.xx.xx:8443->88.232.168.38:19552: i/o timeout","errorVerbose":"read tcp xx.xx.xx.xx:8443->88.232.168.38:19552: i/o timeout\n/root/mtg/obfuscated2/frame.go:87: Cannot extract obfuscated header\n/root/mtg/client/direct.go:38: Cannot extract frame"}

Also the interesting thing that 88.232.168.38 IP is the TurkTelekom. But I haven't any connections with Turkish networks. Maybe these are DPI probes from the Turkey?

UPD: Another one error from the log without any IP's:

{"level":"error","ts":1558105659.805035,"logger":"main","msg":"Cannot initialize client connection","connection_id":"d4fa3c04-xxxx-xxxx-xxxx-xxxx6b3bxxxx","error":"Cannot extract frame: Cannot extract obfuscated header: EOF","errorVerbose":"EOF\n/root/mtg/obfuscated2/frame.go:87: Cannot extract obfuscated header\n/root/mtg/client/direct.go:38: Cannot extract frame"}

Periodic verification of time drift

If a proxy works in promoted channel mode then it is crucial to have time synchronized. Unfortunately, almost everyone (even I personally) had a problem with drifted time so we need to notify users somehow on that.

From RPC protocol I would say that time drift has to be less than 1 second.

Avoid hardcoded proxies / Promoted channels

If we use Telegram API, we do not need to have all these hardcodes + now it is clear why do we need negative DCs

$ curl -s https://core.telegram.org/getProxyConfig -H "Accept: text/plain" --compressed

Unfortunately usage of force probability is totally unclear because this API call is not public: https://core.telegram.org/methods

🤦‍♂️

Outgoing IP address

Как заставить устанавливать исходящие соединения с нужного адреса (интерфейса)?
У сервера 2 провайдера: один блокирует телеграм, второй нет. Настроен source routing.
Обычно достаточно настроить SRC ip адрес (например tcp_outgoing_adress в squid). Ни -b ни -4 не помогают, трафик всегда выходит через default gateway, с его src ip.

Log config

Apparently, it is quite hard to investigate the problems if mtg does not log configuration

How to use ADTag with docker one-line runner code????????

So as the title shows I'm using the docker image and the one-line runner code you've provided to start my proxy:
$ docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable my-defined-secret
in this case the proxy starts with absolutely no problems.
The problem is that you haven't provided any information about how to implement adtag in this one-line runner code.
I tried to add my Adtag to the end of the code but then the the proxy server wouldn't start at all.
$ docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable my-defined-secret my-adtag

log file:
mtg-error-log.txt

so can you please illustrate the way to implement adtag?

Config file

Hello, is it possible to implement config file support, so i can launch it with something like

mtg -c /etc/mtg.conf

Right now i'm using systemd with EnvironmentFile, it's kind of ok but not the cleanest way for sure.

Prometheus integration

Statsd is fine but people are asking to have a native Prometheus integration without interim statsd service.

can't run docker exec -ti mtg "anything"

I read the Dockerfile and I know it's alpine but I can't even docker exec -ti mtg cat something or `docker exec -ti mtg apk add' something or run bash or anything.

What is preventing me from doing so?

Не подключается клиент при добавлении префикса dd

Добрый день!

mtg запущен вот так:
docker run --name mtg --restart=unless-stopped -p 8443:3128 -p 127.0.0.1:3129:3129 -d nineseconds/mtg -a 8443 <pass_here>

При добавлении в клиент префикса dd к ключу, клиент перестает соединяться с прокси. В чем может быть дело? Промежуточных прокси нет. Клиенты десктоп и мобильный, версии последние.

Согласно ридми это вррде бы(?) должно работать штатно.

Temporary unavailability on restart

Hey there,

After restarting the proxy it becomes unavailable for a couple of minutes. Telegram client app sees Connecting... and not a failed connection error. I should mention that my server does have connectivity with ipv6 telegram servers only, so I assume mtg tries to connect to ipv4 servers first, which can cause the problem.

Some time in the past mtg had MTG_USE_IPV6 environment variable option and everything was fine, btw.

Connection multiplexing

Right now we establish 1:1 connections to Telegram even in case of middle proxies which supports multiplexing. The idea is to try to multiplex M clients to N telegram connections. In that case we will have M*N connections instead of M^2.

Multi-secrets mode

I think it's a good idea to implement a multi-secrets mode. Although you have an opinion that one secret is enough there are a lot of situations when such mode would be useful. For example: private proxy for corporate use, each department has individual secret so if a secret leaked out, it's easier to change it for several users than for all corporation. This mode should be optional and must be disabled by default.

Process dead

image
Centos 6.10
mtg -p 443 -b 0.0.0.0 ...
The process always dies, for no reason, and it will be like this in a while.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.