Skip to content

Instantly share code, notes, and snippets.

View fengjijiao's full-sized avatar
🎯
Focusing

follow fengjijiao

🎯
Focusing
View GitHub Profile
https://unix.stackexchange.com/questions/125382/migrate-socat-init-script-to-systemd
For socat, I use a pure systemd approach. This is an example for a serial loopback:
[Unit]
Description=Socat Serial Loopback
#Before=my-other.service
[Service]
Type=simple
@fengjijiao
fengjijiao / stream-server.go
Created June 14, 2022 08:27 — forked from wrfly/stream-server.go
go-gin | http stream server
package main
import (
"bytes"
"fmt"
"io"
"net/http"
"time"
"github.com/gin-gonic/gin"
@fengjijiao
fengjijiao / ipip.sh
Created May 4, 2022 02:01 — forked from perfecto25/ipip.sh
IPIP Tunnel Maker
#!/bin/bash
# this script creates an IPIP Tunnel
# tested for CENTOS 6 & 7
#----------------------------
# CONFIGURATION
#----------------------------
# name of tunnel
name='tun_test'
@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 / 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]
#!/usr/bin/sh
apt-get install -y libglib2.0-0 curl gnupg > /dev/null
cat <<EOF | gpg --import
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGCXz3sBEAC0MuPb6suILUH2uzCFrd6McTPNr+QM8fCK0KQ81ezrRiM/Kzbw
mCK/Dp8oXs85+3hX5bWfSWgnat4Lflsju7WU7c/VnmR4e263/5/dAt00SL0I14Se
skVCOIx3OVaEpjWBZYLTBPf6oE7MY7Y0sQROVeAh+MYJM9E0YE6pDtxNYFWmbVEq
9NjFn4YdgGSlDrHmUv2BiWDfNcuRqAkHCmgWHt4BGI6wfX6UvX2rMkybWOl9OsyA