This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""tun_routing.py""" | |
import logging as LOGGER | |
import subprocess | |
from ipaddress import IPv4Address | |
from itertools import count | |
from typing import Union | |
# pip install pypacker | |
from pypacker.layer3.ip import IP as IPv4Packet | |
from pypacker.layer3.ip import IP_PROTO_UDP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""tun.py | |
*CAP_NET_ADMIN capability is required to create TUN interfaces.* | |
Based on: https://github.com/povilasb/iptun/blob/master/iptun/tun.py | |
""" | |
import logging as LOGGER | |
import os | |
import struct | |
import subprocess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from typing import Any, Callable, Optional, TypeVar | |
T = TypeVar('T') | |
def partial(function: Callable[..., T], *a_: Any, __name__: Optional[str] = None, **k_: Any) -> Callable[..., T]: | |
""" | |
Curry a function. |