Skip to content

Commit

Permalink
[openwrt] build sing-box from source, use gvisor stack
Browse files Browse the repository at this point in the history
  • Loading branch information
lirundong committed Nov 17, 2024
1 parent f572e0e commit 5dcf9ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/artifacts-release-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- uses: actions/setup-go@v5
with:
go-version: stable
- id: setup_dependencies
run: |
pip3 install --user --upgrade --requirement requirements.txt
Expand Down
2 changes: 2 additions & 0 deletions conf-gen/source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ generates:
- tag: tun
type: tun
interface_name: tun0
stack: gvisor
sniff: true
sniff_override_destination: true
address:
Expand Down Expand Up @@ -632,6 +633,7 @@ generates:
- tag: tun
type: tun
auto_route: true
stack: gvisor
sniff: true
sniff_override_destination: true
address:
Expand Down
12 changes: 7 additions & 5 deletions openwrt-builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ $ROOT_DIR/common/secret_decoder.py -r $SRC_DIR/files ./files -e '.*skip$' '__pyc
mkdir -p files/usr/bin files/root
CUSTOM_FILES_DIR=$(realpath -- ./files)

# Sing-Box.
# Build sing-box from source.
SING_BOX_VERSION=${SING_BOX_VERSION:-$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/SagerNet/sing-box/releases/latest | grep -Po 'v\K\d+\.\d+\.\d+')}
SING_BOX_ARCH=${SING_BOX_ARCH:-'amd64'}
SING_BOX_CONFIG=${SING_BOX_CONFIG:-'artifacts-conf/sing-box-daemon/config.json'}
if [[ ! -f ${SING_BOX_CONFIG} ]]; then
echo "sing-box configuration file ${SING_BOX_CONFIG} didn't exist"
exit -1
fi
curl -sSL https://github.com/SagerNet/sing-box/releases/download/v${SING_BOX_VERSION}/sing-box-${SING_BOX_VERSION}-linux-${SING_BOX_ARCH}.tar.gz -o sing-box.tar.gz
tar -xf sing-box.tar.gz
chmod +x sing-box-${SING_BOX_VERSION}-linux-${SING_BOX_ARCH}/sing-box
mv sing-box-${SING_BOX_VERSION}-linux-${SING_BOX_ARCH}/sing-box $CUSTOM_FILES_DIR/usr/bin/
git clone --depth=1 --branch=v${SING_BOX_VERSION} https://github.com/SagerNet/sing-box.git
pushd sing-box
PATH=${SDK_BIN_DIR}:${PATH} CC=${SDK_CC} LD=${SDK_LD} GOOS=linux GOARCH=${SING_BOX_ARCH} GOAMD64=v3 CGO_ENABLED=1 make VERSION=${SING_BOX_VERSION} build
SING_BOX_OPENWRT_EXE=$(realpath ./sing-box)
popd
mkdir -p $CUSTOM_FILES_DIR/root/.config/sing-box
cp ${SING_BOX_OPENWRT_EXE} $CUSTOM_FILES_DIR/usr/bin/
cp ${SING_BOX_CONFIG} $CUSTOM_FILES_DIR/root/.config/sing-box/config.json

# Sing-Box web dashbord.
Expand Down

0 comments on commit 5dcf9ec

Please sign in to comment.