Skip to content
Snippets Groups Projects
Commit b2662336 authored by Symphorien Gibol's avatar Symphorien Gibol
Browse files

tun device creation

parent fee5be53
No related branches found
No related tags found
No related merge requests found
python-pytun==2.2.1
wheel==0.24.0
#!/usr/bin/python3
from pytun import TunTapDevice
import selectors
import socket
tun = TunTapDevice()
tun.addr = '10.8.0.1'
tun.dstaddr = '10.8.0.2'
tun.netmask = '255.255.255.0'
tun.mtu = 400
tun.up()
PEER = "10.4.25.25"
PORT = 1456
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', PORT))
sel = selectors.DefaultSelector()
sel.register(tun, selectors.EVENT_READ, "tun")
sel.register(s, selectors.EVENT_READ, "sms")
while 1:
for key, events in sel.select():
if key.data=="tun":
s.sendto(tun.read(tun.mtu), (PEER, PORT))
elif key.data == "sms":
tun.write(s.read(tun.mtu))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment