Skip to content

Instantly share code, notes, and snippets.

View chenhengqi's full-sized avatar
🐝
Healing CloudNative with BPF

Hengqi Chen chenhengqi

🐝
Healing CloudNative with BPF
View GitHub Profile
@NoReNoLife
NoReNoLife / FuckTLSdump.py
Created September 18, 2024 23:30
KeyGen for tlsdump | tlsdump注册机 破解
#!/usr/bin/env python3
import base64
import subprocess
from json import dumps
from hashlib import md5
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
def get_id_and_sn():
@aojea
aojea / force cgo resolver
Last active May 31, 2022 09:43
localhost resolution in go
GODEBUG=netdns=cgo+2 go run listen.go
GOOS: linux
go package net: using cgo DNS resolver
go package net: hostLookupOrder(localhost) = cgo
net.LookupHost addrs: [::1 127.0.0.1] err: <nil>
go package net: hostLookupOrder(localhost) = cgo
Listener address: 127.0.0.1:8080
go package net: hostLookupOrder(localhost) = cgo
Dial remote address: 127.0.0.1:8080
@sbernard31
sbernard31 / test.c
Last active March 11, 2023 18:04
UDP load balancer proto using bcc (XDP/Bpf)
#define KBUILD_MODNAME "foo"
#include <uapi/linux/bpf.h>
#include <linux/bpf.h>
#include <linux/icmp.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
@helinwang
helinwang / string.md
Last active March 7, 2024 01:23
How to call go from c with string (char *) as the parameter without making a copy

Here is the gist for showing how to send string from c to go without a copy, for sending an float32 array from c to go without copy, please see here

Below is the documentation for converting between a c string and a go string:

// From https://golang.org/cmd/cgo/
// A few special functions convert between Go and C types by making copies of the data. 
// Go string to C string
// The C string is allocated in the C heap using malloc.
// It is the caller's responsibility to arrange for it to be
// freed, such as by calling C.free (be sure to include stdlib.h
@teknoraver
teknoraver / unixhttpc.go
Last active May 16, 2025 19:35
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@zchee
zchee / cgo.md
Last active June 20, 2025 08:51
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.