fix(docker): fix parameter parsing and signal handling in phantun.sh (#235)
All checks were successful
Docker image build / build (push) Successful in 5m48s
Rust / build (push) Successful in 4m6s

- Fix awk delimiter parsing for --tun, --tun-peer, --tun-peer6 arguments
- Change shebang from sh to bash to fix signal trap handling
- Add missing dependencies (iproute2, iptables, procps) to Dockerfile
This commit is contained in:
Heng lu
2025-10-07 00:29:18 +08:00
committed by GitHub
parent 9d74a6bfeb
commit 7f7da10b1b
2 changed files with 8 additions and 4 deletions

View File

@@ -25,6 +25,10 @@ FROM debian:latest
COPY --from=builder /usr/local/bin/phantun-server /usr/local/bin/ COPY --from=builder /usr/local/bin/phantun-server /usr/local/bin/
COPY --from=builder /usr/local/bin/phantun-client /usr/local/bin/ COPY --from=builder /usr/local/bin/phantun-client /usr/local/bin/
COPY docker/phantun.sh /usr/local/bin/ COPY docker/phantun.sh /usr/local/bin/
RUN apt-get update && apt-get install -y \
iproute2 \
iptables \
procps
ENV USE_IPTABLES_NFT_BACKEND=0 ENV USE_IPTABLES_NFT_BACKEND=0
ENV RUST_LOG=INFO ENV RUST_LOG=INFO

View File

@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# alias settings must be global, and must be defined before the function being called with the alias # alias settings must be global, and must be defined before the function being called with the alias
if [ "$USE_IPTABLES_NFT_BACKEND" = 1 ]; then if [ "$USE_IPTABLES_NFT_BACKEND" = 1 ]; then
@@ -70,17 +70,17 @@ _is_ipv4_only() {
} }
_get_tun_from_args() { _get_tun_from_args() {
local tun=$(echo "$@" | awk -F '--tun' '{print $2}' | awk '{print $1}') local tun=$(echo "$@" | awk -F '--tun ' '{print $2}' | awk '{print $1}')
echo ${tun:=tun0} echo ${tun:=tun0}
} }
_get_peer_from_args() { _get_peer_from_args() {
local peer=$(echo "$@" | awk -F '--tun-peer' '{print $2}' | awk '{print $1}') local peer=$(echo "$@" | awk -F '--tun-peer ' '{print $2}' | awk '{print $1}')
_is_server_mode "$1" && echo ${peer:=192.168.201.2} || echo ${peer:=192.168.200.2} _is_server_mode "$1" && echo ${peer:=192.168.201.2} || echo ${peer:=192.168.200.2}
} }
_get_peer6_from_args() { _get_peer6_from_args() {
local peer=$(echo "$@" | awk -F '--tun-peer6' '{print $2}' | awk '{print $1}') local peer=$(echo "$@" | awk -F '--tun-peer6 ' '{print $2}' | awk '{print $1}')
_is_server_mode "$1" && echo ${peer:=fcc9::2} || echo ${peer:=fcc8::2} _is_server_mode "$1" && echo ${peer:=fcc9::2} || echo ${peer:=fcc8::2}
} }