def tinc_client_openwrt_config_tar(client):
basedir = mkdtemp()
tinc_config_base = os.path.join(basedir, 'etc', 'tinc', client.gateway.nickname)
os.makedirs(tinc_config_base)
os.makedirs(os.path.join(tinc_config_base, 'hosts'))
with open(os.path.join(tinc_config_base, 'tinc.conf'), 'w') as conffile:
conffile.write(tinc_client_conf(client))
with open(os.path.join(tinc_config_base, 'tinc_up'), 'w') as conffile:
conffile.write(tinc_client_tinc_up(client))
with open(os.path.join(tinc_config_base, 'tinc_down'), 'w') as conffile:
conffile.write(tinc_client_tinc_down(client))
with open(os.path.join(tinc_config_base, 'hosts', client.gateway.nickname), 'w') as conffile:
conffile.write(tinc_gateway_host(client.gateway))
with open(os.path.join(tinc_config_base, 'hosts', client.member.username), 'w') as conffile:
conffile.write(tinc_client_host(client))
openwrt_config_base = os.path.join(basedir, 'etc', 'config')
os.makedirs(openwrt_config_base)
with open(os.path.join(openwrt_config_base, 'firewall'), 'w') as conffile:
conffile.write(tinc_client_openwrt_firewall_config(client))
with open(os.path.join(openwrt_config_base, 'tinc'), 'w') as conffile:
conffile.write(tinc_client_openwrt_tinc_config(client))
tarfile = make_archive('openwrt_config', 'gztar', root_dir=basedir)
with open(tarfile, 'rb') as tarfile:
return tarfile.read()
评论列表
文章目录