mtg icon indicating copy to clipboard operation
mtg copied to clipboard

Mtg work as simple-run, but not work as classic run with same options

Open xintrea opened this issue 6 months ago • 1 comments

Hello!

I have small server with Debian 12.13.

At this server running SOCKS5 Tor-server at port 127.0.0.1:9050.

If I'm run mtg on this server in simple-run mode, the Telegram client is connect from server port 8081:

/opt/mtg/mtg simple-run 0.0.0.0:8081 eeb1...7275 -s socks5://127.0.0.1:9050

Ok, next I'm, create config file with same options:

/opt/mtg/data/config.toml

secret =     "eeb1...7275"

bind-to = "0.0.0.0:8081"

proxies = [
    "socks5://127.0.0.1:9050"
]

And run mtg in classic run mode:

/opt/mtg/mtg run /opt/mtg/data/config.toml

But in this mode the Telegram client is NOT connect from server port 8081.

In both running mode, in console not print any log message.

Why mtg not work in classic run mode?

xintrea avatar May 19 '26 14:05 xintrea

The proxies key belongs under [network], not at the top level. In your config there's no [network] section header above proxies = [...], so the TOML parser puts it at top level — where the schema has no such field — and the value is silently dropped (internal/config/parse.go uses toml.Unmarshal without strict mode). mtg then starts with no SOCKS5 hop and dials Telegram DCs directly; if your server can't reach Telegram directly (which is likely the reason you put Tor in front in the first place), nothing visibly happens.

Working config:

secret  = "eeb1...7275"
bind-to = "0.0.0.0:8081"

[network]
proxies = ["socks5://127.0.0.1:9050"]

See example.config.toml#L165-L235 for the full [network] block.

simple-run doesn't have this footgun because -s socks5://... is mapped directly into conf.Network.Proxies in code (internal/cli/simple_run.go), bypassing the TOML schema entirely — that's why the same proxy URL works in one mode and silently no-ops in the other.

This is the same silent-ignore behaviour @bam80 flagged in #517; closing the gap there (strict TOML parsing) would turn cases like this into a startup error instead of a head-scratcher.

dolonet avatar May 20 '26 13:05 dolonet