Skip to content

Instantly share code, notes, and snippets.

View phlinhng's full-sized avatar

phlinhng

  • Tsinghua University
  • Formosa
View GitHub Profile
@phlinhng
phlinhng / cfworkers_reverse_proxy.js
Last active July 16, 2021 02:35
fw: universal reverse proxy template
// 需要反代的地址
const upstream = 'api.github.com'
// 反代地址的子路径
const upstreamPath = '/'
// 反代网站的移动端域名
const upstreamMobile = 'api.github.com'
// 是否使用 https
const useHttps = true
let github2jsdelivr = (_url) => {
regex = {"blob": /(.+)github.com\/(.+)\/(.+)\/blob\/(.+)\/(.+)/,
"tree": /(.+)github.com\/(.+)\/(.+)\/blob\/(.+)\/(.+)/};
if(_url.match(regex.tree)){
return _url.replace(regex.tree, "$1cdn.jsdelivr.net/gh/$2/$3@$4/$5");
}else if(_url.match(regex.blob)){
return _url.replace(regex.blob, "$1cdn.jsdelivr.net/gh/$2/$4@$4/$5");
}else{
return _url;
}
@phlinhng
phlinhng / trojan.json
Last active June 19, 2021 06:49
将服务端的 trojan-go 与 v2ray-core 组合实现按目的地中转 ( 目前 trojan-go 作为 server 不支持前置代理,写开心的 )
{
"run_type": "server",
"local_addr": "127.0.0.1",
"local_port": 443,
"remote_addr": "1.1.1.1",
"remote_port": 80,
"log_level": 3,
"password": [
"your_awesome_password"
],
@phlinhng
phlinhng / Caddyfile
Last active June 19, 2021 06:49
trojan-go with caddy as remote web server & https redirector
must.have.sni.com:80 {
redir https://must.have.sni.com{uri}
}
must.have.sni.com:8080 {
bind 127.0.0.1
root /var/www/html
index index.html
tls off
}
#!/bin/bash
# censys.io (https://support.censys.io/hc/en-us/articles/360038378552-Frequently-Asked-Questions)
echo "74.120.14.0/24" >> /tmp/cen_ips
echo "162.142.125.0/24" >> /tmp/cen_ips
echo "167.248.133.0/24" >> /tmp/cen_ips
echo "192.35.168.0/23" >> /tmp/cen_ips
for cenip in `cat /tmp/cen_ips`; do ufw deny from $cenip to any comment 'censys scanners'; done
@phlinhng
phlinhng / swap-1G.sh
Last active May 26, 2021 14:12
Create swap file for linux VPS
dd if=/dev/zero of=/swapfile bs=1024 count=1048576 # allocate space
chmod 600 /swapfile # set permission
mkswap /swapfile # make swap
swapon /swapfile # enable swap
echo "/swapfile swap swap defaults 0 0" | tee -a /etc/fstab # make swap permanent
sysctl -w "vm.swappiness=10" # set swap percentage
echo "vm.swappiness=10" | tee -a /etc/sysctl.conf # make systctl permanent
sysctl -w "net.ipv6.conf.enp0s31f6.disable_ipv6=1" # change enp0s1f6 to your main interface i.e. eth0
echo "net.ipv6.conf.enp0s31f6.disable_ipv6=1" >> /etc/sysctl.conf # save sysctl conf
echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf # disable ipv6 dns record
@phlinhng
phlinhng / go-to-fhs.md
Created August 16, 2020 13:52
V2Ray 从原有 go.sh 遷移至 install-realese.sh 教程
  1. 转移配置文件目录至新目录 /usr/local/etc/v2ray
mkdir -p /usr/local/etc/v2ray
mv /etc/v2ray/config.json /usr/local/etc/v2ray/config.json
  1. 移除旧脚本安装的 v2ray-core(由于旧脚本停用,只能手动移除)
systemctl stop v2ray
systemctl disable v2ray
rm -f /etc/systemd/system/v2ray.service
# -*- coding: utf-8 -*-
# 暴力美學 2.0 - 以空間換時間
from itertools import permutations
candA, candB, candC = [], [], []
for item in permutations(range(1,10)):
if(item[2] != 9): # 排除第3位是9的
candA.append(item)