def updown(): form = UpDownForm() vpn = VpnServer() if form.validate_on_submit(): if form.up.data and vpn.tunnel_up(form.tunnel_name.data): flash(u'隧道连接成功!', 'success') if form.down.data and vpn.tunnel_down(form.tunnel_name.data): flash(u'隧道断开成功!', 'success') return redirect(url_for('sts.index'))
def console(): form = ConsoleForm() vpn = VpnServer() if form.validate_on_submit(): if form.stop.data and vpn.stop: flash(u'VPN 服务停止成功!', 'success') if form.start.data and vpn.start: flash(u'VPN 服务启动成功!', 'success') if form.re_load.data and vpn.reload: flash(u'VPN 服务配置生效完成!', 'success') return render_template('sts/console.html', status=vpn.status, form=form)
def tunnel_up(tunnel_name): vpn = VpnServer() return jsonify({ 'result': vpn.tunnel_up(tunnel_name), 'stdout': vpn.c_stdout })
def vpn_traffic(tunnel_name): vpn = VpnServer() return jsonify(vpn.tunnel_traffic(tunnel_name) or [])
def tunnel_up(tunnel_name): vpn = VpnServer() return jsonify({'result': vpn.tunnel_up(tunnel_name), 'stdout': vpn.c_stdout})