pytun

Python TUN/TAP tunnel module
Download

pytun Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Gawen Arab
  • Publisher web site:
  • http://gawen.me/

pytun Tags


pytun Description

pytun is a Python module to manage tun/tap IP tunnel in the same way you would manipulate a file handler.For now, it is only compatible with Linux, probably Unix, maybe Mac OS X, and in the future Windows,How to useFirst of all, clone this repos or use easy_install or pip.pip install pytuneasy_install pytunQuite easy. Use the open() function.import pytuntun = pytun.open() # Open a TUN mode tunnelFor a TAP tunnel, add the "tap" argument.tun = pytun.open("tap")tun is the handler for the newly created tunnel and is manipulated like a file.To read/write, use the standard methods recv() and send(buf)buf = tun.recv()tun.send(buf)tun is also select() compatible to make your network reactor asynchronous.import selectfds = select.select(, , )Finally, you can close the tunnel using the method close().tun.close()The tunnel automatically closes when the object is not referenced anymore and the garbage collector destroys the handler.Product's homepage


pytun Related Software