mtg icon indicating copy to clipboard operation
mtg copied to clipboard

Cannot detect public IP address: ifconfig.co is unreachable for both IPv4 and IPv6

Open cherts opened this issue 8 months ago • 9 comments

Hi

Using the ifconfig.co service to check IP addresses is hardcoded, and that's not a good idea!

On some servers, this site is unavailable, and when launching mtg doctor, we get an error.

It would be better to use multiple IP address checking services, for example

https://api4.ipify.org
https://ipv4.icanhazip.com
https://v4.api.ipinfo.io/ip
https://ipv4.myexternalip.com/raw
https://4.ident.me
https://check-host.net/ip

Thank's

cherts avatar Mar 25 '26 13:03 cherts

This is possible, sure. But I'm very curious where is ifconfig.co blocked, can you share? Just for self-education

9seconds avatar Mar 25 '26 15:03 9seconds

This is possible, sure. But I'm very curious where is ifconfig.co blocked, can you share? Just for self-education

Adguard dns, есть список блокировки трекеров и там заблокирован этот сайт: ShadowWhisperer Tracking List ||ifconfig.co^

6apakyda avatar Mar 25 '26 18:03 6apakyda

Если это AdGuard или какой другой внешний сервис, просто добавьте их ip в hosts. Кроме того, если AdGuard крутится в виде AdGuard Home, домен можно внести в белый список

9seconds avatar Mar 25 '26 18:03 9seconds

Я просто как пример привёл. Понятно, что проще нам добавить в список исключений ifconfig.co или просто вбить руками свой ip в ссылку, чем Вам загружать код ненужными вещами.

6apakyda avatar Mar 25 '26 19:03 6apakyda

I'm running MTG on a server hosted by Hetzner, and ifconfig.co is blocked there. I think there are many providers, especially in Russia, where one or another IP checker service might be blocked. So, you need to check against a list of such services.

cherts avatar Mar 26 '26 06:03 cherts

There's also a problem with the output of mtg access /etc/mtg/config.toml if the MTG can't determine the IP address Only the secret part of the JSON configuration is output ipv4 is not output!

# mtg doctor /etc/mtg/config.toml
Deprecated options
  ✅ All good
Time skewness
  ✅ Time drift is -1.321364ms, but tolerate-time-skewness is 5s
Validate native network connectivity
  ✅ DC 1
  ✅ DC 2
  ✅ DC 3
  ✅ DC 4
  ✅ DC 5
  ✅ DC 203
Validate fronting domain connectivity
  ✅ xxxx.xxxx:443 is reachable
Validate SNI-DNS match
  ‼️ cannot detect public IP address: ifconfig.co is unreachable for both IPv4 and IPv6
# mtg access /etc/mtg/config.toml
{
  "secret": {
    "hex": "eeXXXXXXXXXXX",
    "base64": "XXXXXXX"
  }
}

cherts avatar Mar 26 '26 06:03 cherts

По мне лучше тогда добавить пункт в конфиге, где можно руками вбить свой IP, а не гадать какой сервис разблокирован

6apakyda avatar Mar 26 '26 07:03 6apakyda

@6apakyda думаю, это хорошая идея

9seconds avatar Mar 26 '26 07:03 9seconds

PR: #418

Добавил два опциональных параметра в конфиг: public-ipv4 и public-ipv6. Если задан — используется вместо ifconfig.co. Если не задан — текущее поведение (автодетект через ifconfig.co) сохраняется.

Работает и в mtg doctor (SNI-DNS проверка), и в mtg access (генерация ссылок). В mtg access приоритет: CLI флаг → конфиг → автодетект.

dolonet avatar Mar 28 '26 21:03 dolonet