Skip to content

Instantly share code, notes, and snippets.

View danieldin95's full-sized avatar

Daniel Ding danieldin95

View GitHub Profile
@movsb
movsb / tunnel.go
Created December 6, 2019 14:50
An HTTP Tunnel Proxy, which implements the CONNECT method. Written in Golang, within 100 lines of code.
package main
import (
"io"
"log"
"net"
"net/http"
"sync"
)
@tfrench
tfrench / leader_election.py
Last active April 13, 2023 07:28
etcd v3 leader election using Python
"""etcd3 Leader election."""
import sys
import time
from threading import Event
import etcd3
LEADER_KEY = '/leader'
LEASE_TTL = 5
SLEEP = 1
### dhcp example
ovs-appctl ofproto/trace br-int in_port=7,udp,dl_src=fa:16:3e:f4:bd:de,dl_dst=ff:ff:ff:ff:ff:ff,nw_dst=255.255.255.255,udp_dst=67,udp_src=68
Megaflow: recirc_id=0,udp,tun_id=0,in_port=7,dl_src=fa:16:3e:f4:bd:de,dl_dst=ff:ff:ff:ff:ff:ff,nw_ecn=0,nw_frag=no,tp_src=68,tp_dst=67
Datapath actions: tnl_push(tnl_port(2),header(size=50,type=4,eth(dst=52:54:00:9b:2f:62,src=1e:36:0f:9e:1d:41,dl_type=0x0800),ipv4(src=11.0.0.21,dst=11.0.0.26,proto=17,tos=0,ttl=64,frag=0x4000),udp(src=0,dst=4789,csum=0x0),vxlan(flags=0x8000000,vni=0x138a)),out_port(4)),tnl_push(tnl_port(2),header(size=50,type=4,eth(dst=2a:da:01:b8:5f:46,src=1e:36:0f:9e:1d:41,dl_type=0x0800),ipv4(src=11.0.0.21,dst=11.0.0.28,proto=17,tos=0,ttl=64,frag=0x4000),udp(src=0,dst=4789,csum=0x0),vxlan(flags=0x8000000,vni=0x138a)),out_port(4))
###vxlan packet
ovs-appctl ofproto/trace br-int in_port=4,
@jarek-przygodzki
jarek-przygodzki / centos-install-kernel-debuginfo.sh
Created February 16, 2017 20:23
CentOS 7 - How to install kernel-debuginfo
yum --enablerepo=base-debuginfo install -y kernel-debuginfo-$(uname -r)
@fortitudepub
fortitudepub / gist:be8618f595dbfacc503e043a3887e181
Created September 9, 2016 07:58
ovs simple nat extracted from system-traffic.at
# ns0
ip netns del natns0
ip netns add natns0
ip netns exec natns0 ip link set lo up
ip link add natp0 type veth peer name natp0p
ip link set natp0 netns natns0
ip link set natp0p up
ip netns exec natns0 ip link set natp0 up
ip netns exec natns0 ip link set natp0 address 80:88:88:88:88:88
ip netns exec natns0 ip addr add 10.1.1.1/24 dev natp0
@zonque
zonque / sctptest.c
Last active November 20, 2024 15:30
Simple client/server test for SCTP
/*
* Compile:
*
* gcc sctptest.c -o server -lsctp -Wall
* ln -s server client
*
* Invoke:
*
* ./client
* ./server
@tejainece
tejainece / cgo1.go
Last active October 26, 2024 04:18
Examples of calling C code from Golang
package main
//#include<stdio.h>
//void inC() {
// printf("I am in C code now!\n");
//}
import "C"
import "fmt"
func main() {
@vishvananda
vishvananda / tunnel.sh
Created October 22, 2013 03:16
Script to set up an ipsec tunnel between two machines For Example: ./tunnel.sh 10.10.10.1 10.10.10.2 192.168.0.1 192.168.0.2 would set up an ipsec tunnel over 10.10.10.1 address using 192.168.0.1 as a virtual address passwordless sudo required for user on remote machine
#!/bin/bash
if [ "$4" == "" ]; then
echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
echo "creates an ipsec tunnel between two machines"
exit 1
fi
SRC="$1"; shift
DST="$1"; shift