Skip to content

Commit e6856a6

Browse files
committed
Disable multipath TCP by default via GODEBUG
Set defaultGODEBUG=multipathtcp=0 at build time to disable MPTCP by default, while maintaining compatibility with older Go versions.
1 parent d9d12ee commit e6856a6

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ jobs:
206206
set -xeuo pipefail
207207
mkdir -p dist
208208
go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
209-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
209+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
210210
./cmd/sing-box
211211
env:
212212
CGO_ENABLED: "0"
@@ -228,7 +228,7 @@ jobs:
228228
set -xeuo pipefail
229229
mkdir -p dist
230230
go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
231-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
231+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
232232
./cmd/sing-box
233233
env:
234234
CGO_ENABLED: "1"
@@ -243,7 +243,7 @@ jobs:
243243
set -xeuo pipefail
244244
mkdir -p dist
245245
go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
246-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
246+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
247247
./cmd/sing-box
248248
env:
249249
CGO_ENABLED: "1"
@@ -258,7 +258,7 @@ jobs:
258258
set -xeuo pipefail
259259
mkdir -p dist
260260
go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
261-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
261+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
262262
./cmd/sing-box
263263
env:
264264
CGO_ENABLED: "0"
@@ -278,7 +278,7 @@ jobs:
278278
export CXX="${CC}++"
279279
mkdir -p dist
280280
GOOS=$BUILD_GOOS GOARCH=$BUILD_GOARCH build go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
281-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
281+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
282282
./cmd/sing-box
283283
env:
284284
CGO_ENABLED: "1"
@@ -445,7 +445,7 @@ jobs:
445445
set -xeuo pipefail
446446
mkdir -p dist
447447
go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
448-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
448+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
449449
./cmd/sing-box
450450
env:
451451
CGO_ENABLED: "1"
@@ -505,7 +505,7 @@ jobs:
505505
run: |
506506
mkdir -p dist
507507
go build -v -trimpath -o dist/sing-box.exe -tags "with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale,with_ccm,with_ocm,with_naive_outbound,with_purego,badlinkname,tfogo_checklinkname0" `
508-
-ldflags "-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0" `
508+
-ldflags "-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0" `
509509
./cmd/sing-box
510510
env:
511511
CGO_ENABLED: "0"
@@ -517,7 +517,7 @@ jobs:
517517
run: |
518518
mkdir -p dist
519519
go build -v -trimpath -o dist/sing-box.exe -tags "with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale,with_ccm,with_ocm,badlinkname,tfogo_checklinkname0" `
520-
-ldflags "-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0" `
520+
-ldflags "-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0" `
521521
./cmd/sing-box
522522
env:
523523
CGO_ENABLED: "0"

.github/workflows/docker.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ jobs:
103103
run: |
104104
set -xeuo pipefail
105105
go build -v -trimpath -o sing-box -tags "${BUILD_TAGS}" \
106-
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=${VERSION}\" -s -w -buildid= -checklinkname=0" \
106+
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=${VERSION}\" -X 'internal/godebug.defaultGODEBUG=multipathtcp=0' -s -w -buildid= -checklinkname=0" \
107107
./cmd/sing-box
108108
env:
109109
CGO_ENABLED: "1"
@@ -115,7 +115,7 @@ jobs:
115115
run: |
116116
set -xeuo pipefail
117117
go build -v -trimpath -o sing-box -tags "${BUILD_TAGS}" \
118-
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=${VERSION}\" -s -w -buildid= -checklinkname=0" \
118+
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=${VERSION}\" -X 'internal/godebug.defaultGODEBUG=multipathtcp=0' -s -w -buildid= -checklinkname=0" \
119119
./cmd/sing-box
120120
env:
121121
CGO_ENABLED: "0"

.github/workflows/linux.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
set -xeuo pipefail
128128
mkdir -p dist
129129
go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
130-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
130+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
131131
./cmd/sing-box
132132
env:
133133
CGO_ENABLED: "1"
@@ -141,7 +141,7 @@ jobs:
141141
set -xeuo pipefail
142142
mkdir -p dist
143143
go build -v -trimpath -o dist/sing-box -tags "${BUILD_TAGS}" \
144-
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -checklinkname=0' \
144+
-ldflags '-s -buildid= -X github.com/sagernet/sing-box/constant.Version=${{ needs.calculate_version.outputs.version }} -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0' \
145145
./cmd/sing-box
146146
env:
147147
CGO_ENABLED: "0"

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN set -ex \
1515
&& go build -v -trimpath -tags \
1616
"with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale,with_ccm,with_ocm,badlinkname,tfogo_checklinkname0" \
1717
-o /go/bin/sing-box \
18-
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid= -checklinkname=0" \
18+
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -X 'internal/godebug.defaultGODEBUG=multipathtcp=0' -s -w -buildid= -checklinkname=0" \
1919
./cmd/sing-box
2020
FROM --platform=$TARGETPLATFORM alpine AS dist
2121
LABEL maintainer="nekohasekai <contact-git@sekai.icu>"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ GOHOSTOS = $(shell go env GOHOSTOS)
66
GOHOSTARCH = $(shell go env GOHOSTARCH)
77
VERSION=$(shell CGO_ENABLED=0 GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) go run github.com/sagernet/sing-box/cmd/internal/read_tag@latest)
88

9-
PARAMS = -v -trimpath -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=$(VERSION)' -s -w -buildid= -checklinkname=0"
9+
PARAMS = -v -trimpath -ldflags "-X 'github.com/sagernet/sing-box/constant.Version=$(VERSION)' -X 'internal/godebug.defaultGODEBUG=multipathtcp=0' -s -w -buildid= -checklinkname=0"
1010
MAIN_PARAMS = $(PARAMS) -tags "$(TAGS)"
1111
MAIN = ./cmd/sing-box
1212
PREFIX ?= $(shell go env GOPATH)

cmd/internal/build_libbox/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func init() {
6060
if err != nil {
6161
currentTag = "unknown"
6262
}
63-
sharedFlags = append(sharedFlags, "-ldflags", "-X github.com/sagernet/sing-box/constant.Version="+currentTag+" -s -w -buildid= -checklinkname=0")
64-
debugFlags = append(debugFlags, "-ldflags", "-X github.com/sagernet/sing-box/constant.Version="+currentTag+" -checklinkname=0")
63+
sharedFlags = append(sharedFlags, "-ldflags", "-X github.com/sagernet/sing-box/constant.Version="+currentTag+" -X internal/godebug.defaultGODEBUG=multipathtcp=0 -s -w -buildid= -checklinkname=0")
64+
debugFlags = append(debugFlags, "-ldflags", "-X github.com/sagernet/sing-box/constant.Version="+currentTag+" -X internal/godebug.defaultGODEBUG=multipathtcp=0 -checklinkname=0")
6565

6666
sharedTags = append(sharedTags, "with_gvisor", "with_quic", "with_wireguard", "with_utls", "with_naive_outbound", "with_clash_api", "with_conntrack", "badlinkname", "tfogo_checklinkname0")
6767
darwinTags = append(darwinTags, "with_dhcp")

release/local/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ get_version() {
4444
get_ldflags() {
4545
local version
4646
version=$(get_version)
47-
echo "-X 'github.com/sagernet/sing-box/constant.Version=${version}' -s -w -buildid= -checklinkname=0"
47+
echo "-X 'github.com/sagernet/sing-box/constant.Version=${version}' -X 'internal/godebug.defaultGODEBUG=multipathtcp=0' -s -w -buildid= -checklinkname=0"
4848
}
4949

5050
build_sing_box() {

0 commit comments

Comments
 (0)