lokinet/vendor/libtuntap-master/bindings/python/__init__.py

25 lines
521 B
Python
Raw Normal View History

2018-06-23 12:18:31 +00:00
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