From cf15e14727fc7f94f43df1140d436edffcf278fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Mon, 16 Feb 2026 15:50:54 +0800 Subject: [PATCH] doc: add more ex --- README.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c4d579..63d0d0b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ tls.Client(terasu.NewConn(conn), &tls.Config{ }).Handshake() ``` -## Custom Plugin (Linux Only) +## Custom Plugin Custom plugin code is located in the `ext/custom` directory. You can write and build your own plugin. @@ -28,5 +28,26 @@ Custom plugin code is located in the `ext/custom` directory. You can write and b 2. Build the plugin: ```bash -GOOS=linux go build -o terasu.plugin.so -buildmode=plugin -ldflags="-s -w" -trimpath ./ext/custom +go build -o terasu.plugin.so -buildmode=plugin -ldflags="-s -w" -trimpath ./ext/custom +``` + +### Example 1. Build for OpenWrt arm64 +```bash +sudo apt-get update +sudo apt-get install -y build-essential module-assistant gcc-9-multilib-i686-linux-gnu g++-9-multilib-i686-linux-gnu +wget -nv https://downloads.openwrt.org/releases/23.05.3/targets/ipq807x/generic/openwrt-sdk-23.05.3-ipq807x-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz +tar -xJf openwrt-sdk-23.05.3-ipq807x-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz +mv openwrt-sdk-23.05.3-ipq807x-generic_gcc-12.3.0_musl.Linux-x86_64 op23053-ipq807x +rm openwrt-sdk-23.05.3-ipq807x-generic_gcc-12.3.0_musl.Linux-x86_64.tar.xz + +PATH=$PATH:`pwd`/op23053-ipq807x/staging_dir/toolchain-aarch64_cortex-a53_gcc-12.3.0_musl/bin/ +export PATH +export STAGING_DIR=`pwd`/op23053-ipq807x/staging_dir/toolchain-aarch64_cortex-a53_gcc-12.3.0_musl/ +export CGO_CFLAGS=$CGO_CFLAGS" -fuse-ld=bfd" +echo $CGO_CFLAGS +export CGO_LDFLAGS=$CGO_LDFLAGS" -fuse-ld=bfd" +echo $CGO_LDFLAGS +export GOGCCFLAGS=$GOGCCFLAGS" -fuse-ld=bfd" +echo $GOGCCFLAGS +CGO_ENABLED=1 GOOS=linux GOARCH=arm64 GOARM=8 CC=aarch64-openwrt-linux-gcc CXX=aarch64-openwrt-linux-g++ AR=aarch64-openwrt-linux-ar go build -o terasu.plugin.so -buildmode=plugin -ldflags="-s -w" -trimpath ./ext/custom ```