Coder Social home page Coder Social logo

pyvpn's Introduction

pyvpn

python vpn server & client.

server: eth0: 192.168.0.192/24, listen on eth0 23456, communication with tcp tun0: 192.168.10.1/24

client: eth0: 192.168.2.108/24 tun0: 192.168.10.2/24 ioctl a tun device; set 192.168.0.1/24 to this tun; connect to heruilong1988.oicp.net 23456, establish connection, large conn with heartbeat

TUNSETIFF = 0x400454ca TUNSETOWNER = TUNSETIFF + 2 IFF_TUN = 0x0001 IFF_NO_PI = 0x1000

Open TUN device file.

tun = open('/dev/net/tun', 'r+b')

Tall it we want a TUN device named tun0.

ifr = struct.pack('16sH', 'tun%d', IFF_TUN | IFF_NO_PI) fcntl.ioctl(tun, TUNSETIFF, ifr)

Optionally, we want it be accessed by the normal user.

fcntl.ioctl(tun, TUNSETOWNER, 1000) print ifr return tun.fileno()

Usage: vpn -s 192.168.10.1 255.255.255.0

vpn -c 192.168.10.2 255.255.255.0 -r office.server.org 23456

1111 1111 1111 1111 1111 1111 0000 0000 1100 0000 1010 1000 0000 1010 0000 0010

pyvpn's People

Contributors

alexsunday avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pyvpn's Issues

parametes error 87

when i test on windows, run this statement always tell error 87 wrong parameters .
l, p = win32file.ReadFile(handle, 2000)

how to solve it?

encount error parameters error 87

when test in windows, the statement encount error 87? how to work around it?

win32file.DeviceIoControl(handle, TAP_IOCTL_CONFIG_TUN,
'\x0a\x03\x00\x01\x0a\x03\x00\x00\xff\xff\xff\x00', None)

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.