使用 ufw (UncomplicatedFirewall) 作为 api [英] Using ufw (UncomplicatedFirewall) as an api

查看:27
本文介绍了使用 ufw (UncomplicatedFirewall) 作为 api的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 ufw 是用 python 编写的.可以通过python使用ufw作为api吗?

I know that ufw is written in python. Is it possible to use ufw as an api via python?

推荐答案

当然,ufw 可执行文件只是同名 python 包的薄包装.我不知道任何文档,但是您可以查看源代码并查看一切如何工作.使用 which ufw 找到 ufw 脚本位置和包位置,方法是启动 python 解释器,导入 ufw 模块并询问它的导入路径:

Sure, the ufw executable is just a thin wrapper around a python package with the same name. I'm not aware of any documentation, but you can just poke around the source and have a look how everything works. Find the ufw script location using which ufw and the package location by starting the python interpreter, importing the ufw module and asking it for its import path:

simon@mymachine:~$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ufw
>>> ufw.__file__
'/usr/lib/python2.6/dist-packages/ufw/__init__.pyc'
>>> 

这篇关于使用 ufw (UncomplicatedFirewall) 作为 api的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆