From d12a787acaa14cd19faedc53a233be8e0f2ac55b Mon Sep 17 00:00:00 2001 From: Nikolay Shopik Date: Thu, 11 May 2017 16:29:32 +0300 Subject: [PATCH] detect and ignore teredo/6to4 (#57) --- blockcheck.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/blockcheck.py b/blockcheck.py index 6b1b47c..fbdadc1 100755 --- a/blockcheck.py +++ b/blockcheck.py @@ -105,6 +105,7 @@ isup_fmt = 'http://isup.me/{}' disable_isup = False #If true, presume that all sites are available disable_report = False disable_ipv6 = False +force_ipv6 = False force_dpi_check = False # End configuration @@ -790,8 +791,14 @@ def check_ipv6_availability(): if (v6addr): v6 = _get_url("http://ipv6.icanhazip.com/", ip=v6addr[0]) if len(v6[1]): - print(": IPv6 доступен!") - return v6[1].strip() + v6src = v6[1].strip() + if force_ipv6 or (not ipaddress.IPv6Address(v6src).teredo + and not ipaddress.IPv6Address(v6src).sixtofour): + print(": IPv6 доступен!") + return v6src + else: + print (": обнаружен туннель Teredo или 6to4, игнорируем.") + return False print(": IPv6 недоступен.") return False @@ -977,6 +984,7 @@ if __name__ == "__main__": .format(isup_server)) parser.add_argument('--force-dpi-check', action='store_true', help='Выполнить проверку DPI, даже если провайдер не блокирует сайты.') parser.add_argument('--disable-ipv6', action='store_true', help='Отключить поддержку IPv6.') + parser.add_argument('--force-ipv6', action='store_true', help='Игнорировать обнаружение туннелей.') parser.add_argument('--debug', action='store_true', help='Включить режим отладки (и --no-report).') args = parser.parse_args() @@ -994,6 +1002,9 @@ if __name__ == "__main__": if args.disable_ipv6: disable_ipv6 = True + + if args.force_ipv6: + force_ipv6 = True if args.debug: debug = True