Skip to content

Commit f7c8270

Browse files
committed
fix: add BRIDGE_CODE env var fallback for bridge session code
Some Android/Termux shells may not pass command-line arguments correctly to dynamically-linked PIE binaries. Add BRIDGE_CODE environment variable as a fallback so the code is passed via both os.Args and the env.
1 parent db2ba88 commit f7c8270

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

bridge/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ func main() {
7474
if wsURL == "" {
7575
fatal(`Missing env var: BRIDGE_WS_URL`)
7676
}
77-
if len(os.Args) < 2 {
78-
fatal("Usage: cya-bridge <session code>")
79-
}
8077
code := os.Args[1]
78+
if !sessionCodePattern.MatchString(code) {
79+
code = os.Getenv("BRIDGE_CODE")
80+
}
8181
if !sessionCodePattern.MatchString(code) {
8282
fatal("Usage: cya-bridge <session code>")
8383
}

server/static/connect-unix.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ else
6161
exit 1
6262
fi
6363
chmod +x "${TMPDIR}/${BIN_NAME}"
64-
BRIDGE_WS_URL="${BASE_URL/http/ws}/ws" "${TMPDIR}/${BIN_NAME}" "${CODE}"
64+
BRIDGE_WS_URL="${BASE_URL/http/ws}/ws" BRIDGE_CODE="${CODE}" "${TMPDIR}/${BIN_NAME}" "${CODE}"

0 commit comments

Comments
 (0)