Add pc support
This commit is contained in:
parent
e8429d66ed
commit
537d14c8cd
4 changed files with 112 additions and 75 deletions
|
|
@ -4,7 +4,7 @@ from urllib.request import urlopen
|
|||
|
||||
from dnscrypt import parse, DNSoverHTTPS
|
||||
|
||||
SMARTDNS_GFW_CONF_FILE = '/etc/smartdns/conf.d/gfw.conf'
|
||||
SMARTDNS_GFW_CONF_FILE = '/etc/smartdns/conf.d/gfw-server.conf'
|
||||
|
||||
# https://github.com/DNSCrypt/dnscrypt-resolvers
|
||||
PUBLIC_RESOLVER_URL_LIST = [
|
||||
|
|
@ -70,14 +70,32 @@ def write_smartdns_config():
|
|||
f.write(conf_txt)
|
||||
|
||||
|
||||
def reload_smartdns():
|
||||
def reload_openwrt_smartdns():
|
||||
subprocess.run(["/etc/init.d/smartdns", "reload"])
|
||||
|
||||
|
||||
def main():
|
||||
def reload_pc_smartdns():
|
||||
subprocess.run(["systemctl", "restart", "smartdns.service"])
|
||||
|
||||
|
||||
def run_openwrt():
|
||||
write_smartdns_config()
|
||||
reload_smartdns()
|
||||
reload_openwrt_smartdns()
|
||||
|
||||
|
||||
def run_pc():
|
||||
write_smartdns_config()
|
||||
reload_pc_smartdns()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("where", choices=["openwrt", "pc"], help="运行环境:openwrt 或 pc")
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.where == "openwrt":
|
||||
run_openwrt()
|
||||
elif args.where == "pc":
|
||||
run_pc()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue