Skip to content

Instantly share code, notes, and snippets.

@Sg4Dylan
Created May 8, 2020 01:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sg4Dylan/8c48f83231180183d2cd10da45708f01 to your computer and use it in GitHub Desktop.
Save Sg4Dylan/8c48f83231180183d2cd10da45708f01 to your computer and use it in GitHub Desktop.
将 gfwlist 转换为 Unbound 的 forward-zone 格式
# -*- 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