Skip to content

Instantly share code, notes, and snippets.

View phlinhng's full-sized avatar

phlinhng

  • Tsinghua University
  • Formosa
View GitHub Profile
[Unit]
Description=MTG - Bullshit-free MTPROTO proxy for Telegram
Documentation=https://github.com/9seconds/mtg
After=network.target nss-lookup.target
Wants=network-online.target
[Service]
Type=simple
User=root
ExecStart=/usr/local/bin/mtg run <secret> --bind 0.0.0.0:8443
@phlinhng
phlinhng / copy_cert.sh
Last active June 27, 2020 08:52
scp ssl cert files to other servers
#!/bin/bash
site="www.your-ssl.com"
path="/root/.acme.sh/acme-v02.api.letsencrypt.org/sites/${site}"
touch server.key server.crt
sudo cat "${path}/${site}.key" > "/root/server.key"
sudo cat "${path}/${site}.crt" > "/root/server.crt"
if [ -s "server.key" ] && [ -s "server.crt" ]; then
@phlinhng
phlinhng / http.conf
Last active July 5, 2020 00:02
v2board + nginx (path: /etc/nginx/sites-enabled/v2board.conf)
server {
listen 80;
listen [::]:80;
root /var/www/v2board/public; # 改成你自己的路径
index index.php index.html;
server_name sspanel.host; # 改成你自己的域名
location / {
try_files $uri $uri/ /index.php$is_args$query_string;
}
@phlinhng
phlinhng / cloudflare_optimise.md
Last active March 5, 2021 01:34
Cloudflare 三网优化节点测试结果 (2020.04)

Cloudflare 三網優化

移動友好

172.64.32.0/24 (香港)

聯通友好

172.69.72.0/22 (澳門)
172.64.0.0/13 (美國 聖何塞)

電信友好

# -*- 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)
@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
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 / 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
#!/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 / 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
}