Skip to content

Instantly share code, notes, and snippets.

View fengjijiao's full-sized avatar
🎯
Focusing

follow fengjijiao

🎯
Focusing
View GitHub Profile
@fengjijiao
fengjijiao / port_forward_ipv4_ipv6.sh
Created April 22, 2020 06:14 — forked from dmazzer/port_forward_ipv4_ipv6.sh
Forwarding IPv4 Ports to IPv6 Hosts
#!/bin/bash
# UDP:
socat UDP4-LISTEN:5683,fork,su=nobody UDP6:[aaaa::212:4b00:615:a1f7]:5683
# TCP:
socat TCP4-LISTEN:22,fork,su=nobody TCP6:[2a01:198:79d:1::8]:22
# UDP, IPv6
socat UDP6-LISTEN:5683,fork,su=nobody UDP6:[aaaa::212:4b00:615:a1f7]:5683
@fengjijiao
fengjijiao / cipher.go
Created June 28, 2020 06:17 — forked from dakait/cipher.go
AES-256 GCM Encryption/Decryption Example in Golang
package secure
import (
"crypto/aes"
"crypto/cipher"
"encoding/hex"
"fmt"
"crypto/sha512"
)
@fengjijiao
fengjijiao / bdr_proto.proto
Created July 9, 2020 07:20 — forked from spikebike/bdr_proto.proto
example for protobuf, go, and the repeated protobuf entry
package bdr_proto;
message request {
message blob {
required string sha256 = 1; // the sha256 checksum of the blob
required int32 bsize = 2; // the size of the blob
}
repeated blob blobarray= 1;
}
@fengjijiao
fengjijiao / go-os-arch.md
Created August 22, 2020 08:50 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.14.7 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • aix
  • android
@fengjijiao
fengjijiao / golang-tls.md
Created January 21, 2021 08:40 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@fengjijiao
fengjijiao / client.go
Created February 8, 2021 01:14 — forked from spikebike/client.go
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@fengjijiao
fengjijiao / _struct_to_map.go
Created February 9, 2021 10:23 — forked from bxcodec/_struct_to_map.go
Golang Struct To Map Example By JSON tag
/*
This function will help you to convert your object from struct to map[string]interface{} based on your JSON tag in your structs.
Example how to use posted in sample_test.go file.
*/
func structToMap(item interface{}) map[string]interface{} {
res := map[string]interface{}{}
if item == nil {
return res
}
@fengjijiao
fengjijiao / client.go
Created February 14, 2021 00:50 — forked from hakobe/client.go
golang unix domain socket
package main
import (
"io"
"log"
"net"
"time"
)
func reader(r io.Reader) {
#!/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
@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]