Giter VIP home page Giter VIP logo

pytun's Introduction

pytun

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 MacOsX, and in the future Windows.

pytun is under the MIT license.

How to use

First of all, clone this repos or use easy_install or pip.

pip install pytun
easy_install pytun

Quite easy. Use the open() function.

import pytun

tun = pytun.open()  # Open a TUN mode tunnel

For 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([size = 1500]) and send(buf)

buf = tun.recv()
tun.send(buf)

tun is also select() compatible to make your network reactor asynchronous.

import select

fds = select.select([tun, ...], [...], [...])

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.

pytun's People

Contributors

gawen avatar hkumarmk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.