mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
521 B
Python
25 lines
521 B
Python
6 years ago
|
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
|