From 6e8e8b63b26507310bbe550d5fbd6851f598f6e1 Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Tue, 2 Mar 2021 17:03:25 +0500 Subject: [PATCH] add check if returned ipv6 address is correct --- mtprotoproxy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mtprotoproxy.py b/mtprotoproxy.py index a26bf72..fc2eddf 100755 --- a/mtprotoproxy.py +++ b/mtprotoproxy.py @@ -195,7 +195,7 @@ def init_config(): # the next host to forward bad clients conf_dict.setdefault("MASK_HOST", conf_dict["TLS_DOMAIN"]) - + # set the home domain for the proxy, has an influence only on the log message conf_dict.setdefault("MY_DOMAIN", False) @@ -2086,6 +2086,10 @@ def init_ip_info(): my_ip_info["ipv4"] = get_ip_from_url(IPV4_URL1) or get_ip_from_url(IPV4_URL2) my_ip_info["ipv6"] = get_ip_from_url(IPV6_URL1) or get_ip_from_url(IPV6_URL2) + # the server can return ipv4 address instead of ipv6 + if my_ip_info["ipv6"] and ":" not in my_ip_info["ipv6"]: + my_ip_info["ipv6"] = None + if my_ip_info["ipv6"] and (config.PREFER_IPV6 or not my_ip_info["ipv4"]): print_err("IPv6 found, using it for external communication")