Fork of PyTap that supports Python 3.
The ifconfig command line utility must be installed for pytap2 to operate.
To install ifconfig on Debian/Ubuntu:
$ sudo apt install net-tools
To install ifconfig on RHEL/Rocky Linux/Fedora:
$ sudo yum install net-tools
You can install, upgrade, and uninstall pytap2 with these commands:
$ pip install pytap2
$ pip install --upgrade pytap2
$ pip uninstall pytap2
Using as a context manager automatically brings up the device and closes it at the
end of the with block.
from pytap2 import TapDevice
with TapDevice() as device:
device.ifconfig(mtu=1300)
device.write(b'0000')Or manually call up() and close().
from pytap2 import TapDevice
device = TapDevice()
device.up()
device.ifconfig(mtu=1300)
device.write(b'0000')
device.close()The fileno() method is defined, so that the device object can be passed directly
to select().
- Support Python 3.12.
- Drop Python 3.7 and support Python 3.11
- Support Mypy type checking for users
- Drop Python 3.6 and support Python 3.10.
- Document dependency on
ifconfig
- Drop Python 3.5 and support Python 3.9.
- Switch to GitHub Actions for CI.
- Drop Python 2.7.
- Drop Python 3.4 and support Python 3.8.
- Include license file.
Support Python 3.7.
Allow disabling packet information header (IFF_NO_PI) and default read() to read entire
MTU worth of data plus the packet information header if present.
Add fileno() method to support select() calls.
Context manager support added.
Allow read() to be called with a specific number of bytes to read.
Initial release that supports Python 2 and 3.