johnthagen / pytap2 Goto Github PK
View Code? Open in Web Editor NEWObject oriented interface to Linux Tun/Tap devices for Python 3
Home Page: https://pypi.org/project/pytap2/
License: MIT License
Object oriented interface to Linux Tun/Tap devices for Python 3
Home Page: https://pypi.org/project/pytap2/
License: MIT License
Hi pytap2 maintainers,
I noticed a discussion about this dependency on ifconfig here here:
meshtastic/python#467
I'm happy to make a start on adding a PR with the methods to use ip instead of ifconfig in order to slowly deprecate that dependency on net-tools
Couple of questions:
Implementation method idea:
which ip
and look at the returncode to determine if the iproute2 package is installed.
which ifconfig
Hi All,
On a deban RPI3, I tested the first proposed code:
root@host:~# cat test.py
from pytap2 import TapDevice
with TapDevice() as device:
device.ifconfig(mtu=1300)
device.write(b'0000')
And I got an error:
root@host:~# python3 test.py
sh: 1: ifconfig: not found
Traceback (most recent call last):
File "test.py", line 3, in <module>
with TapDevice() as device:
File "/usr/local/lib/python3.7/dist-packages/pytap2/__init__.py", line 90, in __enter__
self.up()
File "/usr/local/lib/python3.7/dist-packages/pytap2/__init__.py", line 213, in up
raise IfconfigError()
pytap2.IfconfigError
This error was discover in the context of meshtatsic project: meshtastic/python#104
Any thing I can do ?
Thanks
KiwiHC16
Hi,
thanks for producing this great library. I'm sure it took of multiple days of my bridging project. I did find some issue though when passing a tap device name into the constructor, i.e. TapDevice(name='tap0')
the result is that self._name is tap00 . I think the reason is found in line
https://github.com/johnthagen/pytap2/blob/master/src/pytap2/__init__.py#L58
it should rather read:
self._name = name
I'm still a little bit puzzled how the assembled format string is used further down but I'll leave exploring that for another time.
Best Regards,
Kilian
Hi
Anyone can help understanding why using pytap2 on OpenWRT would gives this error ?
from pytap2 import TapDevice
with TapDevice() as device:
device.ifconfig(mtu=1300)
device.write(b'0000')
(tmp) root@OpenWrt:/tmp/tmp# python3 do.py
Traceback (most recent call last):
File "/tmp/tmp/do.py", line 3, in <module>
with TapDevice() as device:
File "/tmp/tmp/lib/python3.9/site-packages/pytap2/__init__.py", line 75, in __init__
ifs = fcntl.ioctl(
OSError: [Errno 81] File descriptor in bad state
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.