You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 5, 2026. It is now read-only.
feat: add secret labels and per-secret metrics (#60)
Associate human-readable labels with configured secrets and surface
per-secret connection metrics in logs and stats endpoints.
- `-S SECRET:LABEL` syntax (backward compatible, label is optional)
- Per-secret active/total connection counters in /stats and /metrics
- Matched secret label logged at handshake (no raw secrets in logs)
- Docker: SECRET_LABEL_N env vars and inline label support
- Works for both ME relay and direct-to-DC modes
Closes#60
-`nobody` is the username. `mtproto-proxy` calls `setuid()` to drop privilegies.
144
144
-`443` is the port, used by clients to connect to the proxy.
145
145
-`8888` is the local port for statistics (requires `--http-stats`). Like `curl http://localhost:8888/stats`. Stats are accessible from private networks (loopback, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) but not from public IPs.
146
-
-`<secret>` is the secret generated at step 3. Also you can set multiple secrets: `-S <secret1> -S <secret2>`.
146
+
-`<secret>` is the secret generated at step 3. Also you can set multiple secrets: `-S <secret1> -S <secret2>`. Each secret can have an optional label: `-S <secret>:family -S <secret>:friends`. Labels appear in logs and stats instead of raw secrets, making it easy to identify which secret a connection used.
147
147
-`--aes-pwd proxy-secret` points to the `proxy-secret` file downloaded at step 1, which contains the encryption key used for MTProto key exchange with Telegram DCs.
148
148
-`proxy-secret` and `proxy-multi.conf` are obtained at steps 1 and 2.
149
149
-`1` is the number of workers. You can increase the number of workers, if you have a powerful server.
@@ -463,9 +463,11 @@ docker run -d \
463
463
-`SECRET`: Proxy secret(s) — 32 hex characters each (auto-generated if not provided)
Returns metrics in [Prometheus exposition format](https://prometheus.io/docs/instrumenting/exposition_formats/), ready for scraping. Available on the same `--http-stats` port, restricted to private networks.
494
+
Returns metrics in [Prometheus exposition format](https://prometheus.io/docs/instrumenting/exposition_formats/), ready for scraping. Available on the same `--http-stats` port, restricted to private networks. Includes per-secret connection metrics when [secret labels](#secret-labels) are configured.
493
495
494
496
### Using Docker Compose
495
497
@@ -529,6 +531,34 @@ SECRET_2=friends_secret_hex
529
531
SECRET_3=public_secret_hex
530
532
```
531
533
534
+
#### Secret Labels
535
+
536
+
Labels let you identify which secret a connection is using — useful for revoking leaked
@@ -2418,7 +2499,7 @@ int f_parse_option (int val) {
2418
2499
}
2419
2500
}
2420
2501
if (val=='S') {
2421
-
tcp_rpcs_set_ext_secret (secret);
2502
+
tcp_rpcs_set_ext_secret (secret, label);
2422
2503
secret_count++;
2423
2504
} else {
2424
2505
memcpy (proxy_tag, secret, sizeof (proxy_tag));
@@ -2446,7 +2527,7 @@ int f_parse_option (int val) {
2446
2527
2447
2528
voidmtfront_prepare_parse_options (void) {
2448
2529
parse_option ("http-stats", no_argument, 0, 2000, "allow http server to answer on stats queries");
2449
-
parse_option ("mtproto-secret", required_argument, 0, 'S', "16-byte secret in hex mode");
2530
+
parse_option ("mtproto-secret", required_argument, 0, 'S', "16-byte secret in hex, optionally followed by :LABEL (e.g. -S abcdef01234567890abcdef012345678:myapp)");
2450
2531
parse_option ("proxy-tag", required_argument, 0, 'P', "16-byte proxy tag in hex mode to be passed along with all forwarded queries");
2451
2532
parse_option ("domain", required_argument, 0, 'D', "adds allowed domain or host:port for TLS-transport mode, disables other transports; can be specified more than once");
2452
2533
parse_option ("max-special-connections", required_argument, 0, 'C', "sets maximal number of accepted client connections per worker");
0 commit comments