Git Product home page Git Product logo

pytap2's Introduction

GitHub stats

Top Langs

pytap2's People

Contributors

johnthagen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pytap2's Issues

Deprecation of ifconfig in favour of the default iproute2 package?

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:

  • is this something you would like done?
  • has this been attempted before? if so are there any known incompatibilities?

Implementation method idea:

  1. We could use the which ip and look at the returncode to determine if the iproute2 package is installed.
    • if it is we can use the new methods / commands.
    • else do an which ifconfig
    • if that's installed then use the old ifconfig methods
    • else raise an exception letting the user know they need to either install net-tools or iproute2 (recommend iproute2)

ifconfig error

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

Wrong device name if name is not default

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

Any idea why OpenWRT gives me this error trying to use pytap2 ? OSError: [Errno 81] File descriptor in bad state

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.