Use ipv4 when querying IP lookup service

Also, replace broken IP lookup service with some others
This commit is contained in:
Sergey Prokhorov 2019-08-26 20:12:24 +02:00
parent 30f8c3dbf3
commit ae618ea478
No known key found for this signature in database
GPG key ID: 1C570244E4EF3337
2 changed files with 6 additions and 3 deletions

View file

@ -261,8 +261,10 @@ http_get(Url) ->
{ok, Vsn} = application:get_key(mtproto_proxy, vsn),
UserAgent = "MTProtoProxy/" ++ Vsn ++ " (+https://github.com/seriyps/mtproto_proxy)",
Headers = [{"User-Agent", UserAgent}],
%% XXX: ipfamily only works on OTP >= 20.3.4; see OTP 2dc08b47e6a5ea759781479593c55bb5776cd828
{ok, {{_, 200, _}, _, Body}} =
httpc:request(get, {Url, Headers}, [{timeout, 3000}], []),
httpc:request(get, {Url, Headers}, [{timeout, 3000}],
[{socket_opts, [{ipfamily, inet}]}]),
{ok, Body}.
random_choice(L) ->

View file

@ -31,8 +31,9 @@
%% 2nd one will be tried and so on
{ip_lookup_services,
["http://ipv4.seriyps.ru/",
"https://digitalresistance.dog/myIp",
"http://ipv4.myexternalip.com/raw"]},
"http://v4.ident.me/",
"http://ipv4.icanhazip.com/",
"https://digitalresistance.dog/myIp"]},
%% {external_ip, "YOUR.SERVER.EXTERNAL.IP"},
%% Interface to listen for incoming connections