From e32a4039fde59eda1f04807ad078ece66e0ceb9e Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Wed, 28 Sep 2022 17:53:34 +0800 Subject: [PATCH] feat: gfwlist fetch --- assets/gfwlist.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 assets/gfwlist.py diff --git a/assets/gfwlist.py b/assets/gfwlist.py new file mode 100755 index 0000000..a089c39 --- /dev/null +++ b/assets/gfwlist.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import re + +source = [ + 'curl -sL https://github.com/Loukky/gfwlist-by-loukky/raw/master/gfwlist.txt | base64 -d | ' + 'sed \'/^$\\|@@/d\' | sed \'s#!.\\+##;s#|##g;s#@##g;s#http:\\/\\/##;s#https:\\/\\/##;\' | ' + 'sed \'/^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$/d\' | grep \'^[0-9a-zA-Z\\.-]\\+$\' | ' + 'grep "\\." | sed \'s#^\\.\\+##\'', + 'curl -sL https://github.com/gfwlist/gfwlist/raw/master/gfwlist.txt | base64 -d | ' + 'sed \'/^$\\|@@/d\' | sed \'s#!.\\+##;s#|##g;s#@##g;s#http:\\/\\/##;s#https:\\/\\/##;\' | ' + 'sed \'/^[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$/d\' | grep \'^[0-9a-zA-Z\\.-]\\+$\' | ' + 'grep "\\." | sed \'s#^\\.\\+##\'', + 'curl -sL https://github.com/hq450/fancyss/raw/master/rules/gfwlist.conf | ' + 'sed \'s/ipset=\\/\\.//g;s/\\/gfwlist//g;/^server/d\'', + 'curl -sL https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/gfw.txt', +] + +domains = set() +for script in source: + raw = os.popen(script).read().split('\n') + domains.update(filter(None, raw)) +regex = r'^(?=^.{3,255}$)[a-zA-Z0-9][a-zA-Z0-9\-]{0,62}(.[a-zA-Z0-9][a-zA-Z0-9\-]{0,62})+$' +domains = {x for x in domains if re.search(regex, str(x)) is not None} +print('\n'.join(sorted(domains)))