lokinet/vendor/libtuntap-master/bindings/python/__init__.py
2018-06-23 05:18:31 -07:00

25 lines
521 B
Python

from _pytuntap import *
import io
class TunTapFileIO(io.FileIO):
def __init__(self, tuntap):
super(TunTapFileIO, self).__init__(tuntap.native_handle, 'rb+')
def read(self, size):
return memoryview(bytearray(super(TunTapFileIO, self).read(size)))
def readinto():
raise NotImplementedError
def readall():
raise NotImplementedError
def writelines():
raise NotImplementedError
def _file(self):
return TunTapFileIO(self)
Tap.file = _file
Tun.file = _file