Skip to content

Instantly share code, notes, and snippets.

View BarryDeng's full-sized avatar
🙃
On studying

Sa1ka BarryDeng

🙃
On studying
View GitHub Profile
@BarryDeng
BarryDeng / vpn-hotspot.sh
Created September 14, 2023 12:06 — forked from ShapeShifter499/vpn-hotspot.sh
vpn hotspot script
#!/storage/xbin/bash
# This script should help forward VPN over any tethered connection on a Android device. Turn on tethering, then enable VPN, then run this script.
# Inital variable setup
tethering=0
# Setup iptables before forwarding VPN
iptables -A POSTROUTING -o tun0 -j MASQUERADE -t nat
@BarryDeng
BarryDeng / print_iptables.py
Created December 28, 2021 10:00
Print iptables rules of filter and nat table separating arguments by comma.
#!/usr/bin/env python3
import subprocess
import re
// Client side implementation of UDP client-server model
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <time.h>
// Server side implementation of UDP client-server model
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"sync"
"time"
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"sync"
"time"
package main
import (
"io/ioutil"
"fmt"
"sync"
"time"
"net"
"log"
"flag"
@BarryDeng
BarryDeng / lxc_vethfinder.sh
Created November 19, 2019 03:11
Find which veth interface is attached to the LXC/LXD container
#!/bin/bash
container=$1
interface=$2
iflink=$(lxc exec $1 cat /sys/class/net/$2/iflink)
veth=$(grep -l $iflink /sys/class/net/veth*/ifindex)
veth=$(echo $veth|sed -e 's;^.*net/\(.*\)/ifindex$;\1;')
echo $veth
#!/bin/bash
HOST_PER_NODE=2
SWITCH_NUM=3
FIREWALL_NUM=3
WEBSERVER_NUM=1
HOST_TEMPLATE_NAME="host"
SWITCH_TEMPLATE_NAME="ovs"
ROUTER_TEMPLATE_NAME="router"
#!/bin/bash
HOST_PER_NODE=2
SWITCH_NUM=3
FIREWALL_NUM=3
WEBSERVER_NUM=1
HOST_TEMPLATE_NAME="host"
SWITCH_TEMPLATE_NAME="ovs"
WEBSERVER_TEMPLATE_NAME="webserver"