Skip to content

Instantly share code, notes, and snippets.

View abdelrahman-t's full-sized avatar
💭
killing the game.

Abdurrahman Murat abdelrahman-t

💭
killing the game.
View GitHub Profile
@abdelrahman-t
abdelrahman-t / tun_routing.py
Last active August 1, 2024 18:33
TUN tunneling/routing
"""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
@abdelrahman-t
abdelrahman-t / tun.py
Last active August 1, 2024 18:08
Create a TUN interface in Python
"""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
@abdelrahman-t
abdelrahman-t / functools_.py
Last active June 8, 2020 14:56
'functools.partial' re-implementation
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.