conffiles.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:guifiadmin 作者: guifi-org 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号