This file contains hidden or 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
# pip install curio==0.9 | |
from curio import socket | |
import curio | |
async def amain(): | |
task1 = await curio.spawn(send_hi, 5000, 'client1') | |
task2 = await curio.spawn(send_hi, 6000, 'client2') | |
await task1.join() |
This file contains hidden or 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
[package] | |
authors = ["Povilas Balciunas <[email protected]>"] | |
name = "netsim-demo" | |
version = "0.1.0" | |
[dependencies] | |
futures = "0.1.17" | |
netsim = "0.2.2" | |
tokio-core = "0.1.17" | |
unwrap = "1.2.0" |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>PayloadContent</key> | |
<array> | |
<dict> | |
<key>PayloadCertificateFileName</key> | |
<string>root_ca.crt</string> | |
<key>PayloadContent</key> |
This file contains hidden or 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
from typing import Tuple | |
from curio import socket | |
import curio | |
import dnslib as dns | |
class Server: | |
def __init__(self) -> None: | |
self.port = 53 |
This file contains hidden or 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 socket | |
from pypacker.layer3.ip import IP | |
from pypacker.layer3.icmp import ICMP | |
def main() -> None: | |
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) | |
ip = IP(src_s='192.168.0.103', dst_s='8.8.8.8', p=1) +\ |
This file contains hidden or 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 os | |
from fcntl import ioctl | |
import struct | |
import time | |
import random | |
from threading import Thread | |
from pyroute2 import IPRoute | |
from pypacker.layer3.ip import IP | |
from pypacker.layer3.ip6 import IP6 |
This file contains hidden or 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 logging | |
def setup_logging(config: dict) -> None: | |
logger = logging.getLogger() | |
logger.setLevel(logging.__dict__[config['level']]) | |
handler = logging.FileHandler(config['file']) | |
handler.setFormatter(logging.Formatter( | |
'$asctime $levelname $filename:$lineno $message', | |
style='$', |
This file contains hidden or 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
from typing import Callable | |
import raven | |
_CLIENT = raven.Client() | |
def track_exceptions(func: Callable) -> Callable: | |
def tracked_call(*args, **kwargs): |
This file contains hidden or 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
use std::net::TcpStream; | |
use std::io::{Write, Read}; | |
fn main() { | |
let target_addr = "54.243.92.110:80"; // httpbin.org | |
let mut stream = TcpStream::connect(target_addr).unwrap(); | |
stream.write(b"GET /ip HTTP/1.1\r\nHost: httpbin.org\r\nConnection: close\r\n\r\n"); | |
let mut buff = [0; 65536]; | |
stream.read(&mut buff); |
This file contains hidden or 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
all: config-1 config-2 | |
.PHONY: all | |
config-%: % | |
@echo "building conf $^" | |
.PHONY: config-% | |
1: | |
.PHONY: 1 |