-1

The guy who wrote ufw is too smart for me. Is there any documentation for any of the python code?

Some things I'm trying to do are:

  • Allow/close ports by number
  • Get the currently set rules
  • Remove rules

Edit:

My question wasn't specific enough. Everyone here is assuming that I somehow want to reinvent my own interface to iptables, or make some kind of firewall application, when really, I'm just creating a simple ui for ufw that fits into my current application. However, the current state of the ufw python code base makes this a lot harder than it needs to be.

7
  • 6
    This question would be much more useful if you asked what specifically you're trying to do with ufw! Aug 15, 2013 at 15:02
  • I added the things I'm trying to do with ufw, but really, I just want some documentation on the python api. Aug 15, 2013 at 16:53
  • I just had a quick scan through UFW's source code. It looks quite standard level of a Python applictation. The docstrings give you a basic idea of what a method does and I find it quite easy to understand from just reading the source code. Please be more specific on what you're looking for or what you don't understand. Note that UFW is meant to be a end-user application, using the iptables backend. It is not intended to be integrated in your own application - it does not offer a really well-documented API (it's not a library in this sense).
    – gertvdijk
    Aug 16, 2013 at 8:17
  • I guess there's not really much use in it being open source then Aug 18, 2013 at 22:43
  • 1
    @notbad.jpeg There is no API to document. Again, UFW is a end-user application, not a library. And it seems to me you're missing the point about open source versus closed source application. That remark is completely misplaced here. If you need to implement your own firewall, look at how UFW handles it using iptables. That's your point to start if you're developing your software.
    – gertvdijk
    Aug 19, 2013 at 17:41

2 Answers 2

7

This illustrated tutorial has the answers to the three bulleted points in your question, but it doesn't answer the part of your question about about documentation for any of the Python code. Below is a screenshot of the gufw application from the default Ubuntu repositories that shows how easy it is to get the currently set rules in gufw. Gufw is a graphical front-end to ufw which is itself a front-end to iptables.

enter image description here

If you really want to get down to the code level with ufw, then you're ready to consider using iptables in order to get exactly what firewall rules you want by running commands in the terminal.

1

Here is a pretty comprehensive guide on iptables -- the backend of UFW:

http://www.frozentux.net/documents/iptables-tutorial/

Also, a short tutorial on UFW:

https://help.ubuntu.com/community/UFW

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.