Skip to content

Instantly share code, notes, and snippets.

View fengjijiao's full-sized avatar
🎯
Focusing

follow fengjijiao

🎯
Focusing
View GitHub Profile
@fengjijiao
fengjijiao / netstat-install.sh
Last active May 3, 2022 23:21
simply to install netstat
#!/bin/bash
wget -O netstat https://github.com/fengjijiao/netstat-http-api/releases/download/0.0.1/netstat-linux-amd64
chmod +x netstat
mv netstat /usr/local/bin
mkdir -p /usr/local/etc/netstat
wget -O /usr/local/etc/netstat/config.yaml https://raw.githubusercontent.com/fengjijiao/netstat-http-api/main/config.yaml
cat << EOT > /etc/systemd/system/netstat.service
[unit]
Description=netstat
@fengjijiao
fengjijiao / nginx-install.sh
Last active May 6, 2022 01:16
simply to install nginx for centos7
#!/usr/bash
NGINX_VERSION=1.20.2
NGINX_DOWNLOAD_URL="http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
NGINX_SAVED_COMPRESSED_FILENAME=nginx.tar.gz
NGINX_COMPILE_DIR=/usr/local/nginx_compile
NGINX_INSTALL_DIR=/usr/local/nginx
NGINX_BIN=${NGINX_INSTALL_DIR}/bin/nginx
NGINX_LOG_DIR=/var/log/nginx
NGINX_RUN_DIR=/var/run/nginx
NGINX_PID=$NGINX_RUN_DIR/nginx.pid
@fengjijiao
fengjijiao / main.go
Created April 23, 2022 06:30 — forked from jiahuif/main.go
golang: tunnel tcp over socks5
package main
import (
"flag"
"io"
"net"
"time"
log "github.com/sirupsen/logrus"
"golang.org/x/net/proxy"
@fengjijiao
fengjijiao / socks5_proxy.go
Created April 23, 2022 04:04 — forked from ometa/socks5_proxy.go
Golang HTTP Client using SOCKS5 proxy and DialContext
// Golang example that creates an http client that leverages a SOCKS5 proxy and a DialContext
func NewClientFromEnv() (*http.Client, error) {
proxyHost := os.Getenv("PROXY_HOST")
baseDialer := &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}
var dialContext DialContext
@fengjijiao
fengjijiao / install-ikev2.sh
Created March 20, 2022 03:38 — forked from yf-hk/install-ikev2.sh
Setup Strongswan IKEv2 VPN server on Debian 10 with Let's Encrypt
#!/bin/bash
apt update && apt upgrade -y
apt install strongswan strongswan-pki libcharon-extra-plugins net-tools wget -y
DEBIAN_FRONTEND=noninteractive apt-get -y install iptables-persistent
HOST_NAME="vpn.example.com"
read -e -i "$HOST_NAME" -p "VPN host name: " HOST_NAME
HOST_NAME="${input:-$HOST_NAME}"
LOCAL_SUBNET="172.19.240.0/20"
@fengjijiao
fengjijiao / data-url.js
Created March 2, 2022 01:32 — forked from jens1101/data-url.js
Save Blob as file in JavaScript
// In this file we use a data URL to represent a Blob. This basically base64
// encodes the Blob and puts that string in a URL. This has better compatibility
// with old browsers, but is limited to ~2MB.
const blob = getBlobFromSomewhere()
const reader = new FileReader()
reader.onload = function (event) {
const a = document.createElement('a')
a.href = event.target.result
@fengjijiao
fengjijiao / README.md
Created February 19, 2022 12:31 — forked from bwann/README.md
Tunnelling SSH over SSL/TLS

How to tunnel SSH over SSL/TLS

laptop ssh -> laptop stunnel -> evil network -> internet -> your server -> your server ssh

Server (your shell server/home box/work box/whatever)

Sets up a stunnel process listening externally on port 2443/tcp, forwards to localhost 22/tcp

  • Install stunnel, e.g. yum install stunnel
  • Install server config snippet to /etc/stunnel/stunnel.conf
@fengjijiao
fengjijiao / nftables-nat-masquerade-configure.conf
Created February 4, 2022 10:15
nftables nat masquerade configure
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0; policy accept;
}
chain forward {
type filter hook forward priority 0; policy accept;
3.217.79.163/32
3.217.93.44/32
13.64.0.0/28
13.82.0.0/28
13.84.0.0/28
13.90.0.0/28
13.105.49.96/27
13.105.49.128/27
18.213.123.130/32
20.64.0.0/28
@fengjijiao
fengjijiao / doc.txt
Created February 1, 2022 04:50 — forked from MartinBrugnara/doc.txt
DigitalOcean, assign public ipv6 to wireguard clients
# /etc/sysctl.d/wireguard.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.default.forwarding=1
net.ipv6.conf.eth0.proxy_ndp=1
#/etc/wireguard/wg0.conf (DO virtual machine)
[Interface]
# The server interface does not actually need an ipv6.
# The 2 following must be repeated for each used addres [0, 1]