Skip to content

Instantly share code, notes, and snippets.

@pagxir
pagxir / residence.pac
Last active June 1, 2024 10:30
proxy auto config for split domain into oversea and big local network.
const _net_count = 15641;
const _net_list = [
{"net": 0x01000000, "prefix": 24}, {"net": 0x01000400, "prefix": 22}, {"net": 0x01001000, "prefix": 20}, {"net": 0x01004000, "prefix": 18},
{"net": 0x01008000, "prefix": 17}, {"net": 0x01010100, "prefix": 24}, {"net": 0x01014000, "prefix": 18}, {"net": 0x01018000, "prefix": 17},
{"net": 0x01020300, "prefix": 24}, {"net": 0x01028000, "prefix": 17}, {"net": 0x01040000, "prefix": 24}, {"net": 0x01048000, "prefix": 17},
{"net": 0x01050000, "prefix": 16}, {"net": 0x01060000, "prefix": 15}, {"net": 0x01090000, "prefix": 16}, {"net": 0x010a0a00, "prefix": 24},
{"net": 0x010a8000, "prefix": 17}, {"net": 0x010b0000, "prefix": 16}, {"net": 0x01100000, "prefix": 13}, {"net": 0x01200000, "prefix": 13},
{"net": 0x01280000, "prefix": 14}, {"net": 0x012c0000, "prefix": 16}, {"net": 0x012e0000, "prefix": 15}, {"net": 0x01340000, "prefix": 14},
{"net": 0x01400000, "prefix": 14}, {"net": 0x01480000, "prefix": 13}, {"net": 0x016
@pagxir
pagxir / ifup-tun0-lede.sh
Created May 12, 2018 06:00
toyvpn setup script for lede
#!/bin/sh
PATH=/usr/sbin:$PATH
tun_dev=tun0
ip address add 10.24.0.1/24 dev ${tun_dev}
ip link set dev ${tun_dev} up
ip -6 addr add 2001:c0a8:2b01:3576::1/64 dev ${tun_dev}
ip -6 route add default dev ${tun_dev} metric 256 proto static
@pagxir
pagxir / ifup-tun0-old.sh
Last active September 23, 2017 04:02
toy to vpn client startup config script
#!/bin/bash
PATH=${PATH}:/sbin:/usr/sbin
ip6tables -F FORWARD
iptables -t raw -F PREROUTING
#iptables -t raw -A PREROUTING -j NOTRACK
iptables -t raw -F OUTPUT
@pagxir
pagxir / nginx.conf
Created June 25, 2017 02:22
ssl redirect proxy server config for nginx
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
resolver 8.8.8.8;
root /usr/share/nginx/www;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name www.cachefiles.net;
Version: 2.5
uid resource held maxheld barrier limit failcnt
3291: kmemsize 19102813 21286912 2147483646 2147483646 0
lockedpages 0 0 999999 999999 0
privvmpages 79971 245015 262144 262144 40
shmpages 963 979 131072 131072 0
dummy 0 0 9223372036854775807 9223372036854775807 0
numproc 53 81 999999 999999 0
physpages 102669 1864041 0 214
@pagxir
pagxir / timeout.sh
Last active May 3, 2017 16:22
execute a shell command with timeout
timeout() {
exec 4<&1;
(sh -c 'echo $PPID'; exec $@ 3<&1 1<&4 4>&-) | (cat; echo END;) | (read PID; read -t 3 || kill $PID)
exec 4>&-;
}
timeout wget http://www.baidu.com/
# commiter: [email protected]
bind '"\x1b[6~":history-search-forward'
bind '"\x1b[5~":history-search-backward'
@pagxir
pagxir / iptable_forwardto.sh
Last active April 28, 2017 03:06
use iptables redirect host port to remote <host:port>
forward_port() {
HOST=$(echo -n $2|sed 's/:.*//')
PORT=$(echo -n $2|sed 's/.*://')
LOCAL=$(ip route get $HOST|head -n 1|sed 's/.*[^0-9] //')
iptables -t nat -A PREROUTING -p tcp --dport $1 -d $LOCAL -m comment --comment "CACHEFILES" -j DNAT --to $FORWARD_TARGET
iptables -t nat -A POSTROUTING -p tcp --dport $PORT -d $HOST -m comment --comment "CACHEFILES" -j SNAT --to $LOCAL
@pagxir
pagxir / iptables.ash
Last active September 7, 2024 23:38
share vpn over tethering for android 4.4+
#!/system/bin/sh
# log -t IPTABLES -- $@
# iptables -w -t mangle -A INPUT -i tun0 -j MARK --set-mark 0x3006a
IPTABLES="/system/bin/iptables.oem iptables"
need_arg=0;
last_cmd="";
IIF=""