Created
May 8, 2020 01:19
-
-
Save Sg4Dylan/8c48f83231180183d2cd10da45708f01 to your computer and use it in GitHub Desktop.
将 gfwlist 转换为 Unbound 的 forward-zone 格式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
""" | |
Convert https://raw.githubusercontent.com/petronny/gfwlist2pac/master/gfwlist.pac for unbound. | |
""" | |
import re | |
with open("gfwlist.conf", 'w') as wp: | |
for line in open("gfwlist.pac"): | |
if re.match(r" {12}\".*\",?\n", line) != None: | |
domain_valid = line.split('"')[1] | |
zone_line = 'forward-zone:\n' | |
zone_line += f' name: "{domain_valid}"\n' | |
zone_line += f' forward-tls-upstream: yes\n' | |
zone_line += f' forward-addr: 1.1.1.1@853\n' | |
zone_line += f' forward-addr: 149.112.112.112@853\n' | |
zone_line += f' forward-addr: 8.8.8.8@853\n' | |
wp.writelines(zone_line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment