Skip to content

Commit 1a0a062

Browse files
committed
intra: grab goenv if possible
1 parent 5e83bdb commit 1a0a062

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ XGO_LDFLAGS='-s -w -X main.version=$(COMMIT_ID)'
1010
# github.com/xjasonlyu/tun2socks/blob/bf745d0e0/Makefile#L14
1111
LDFLAGS_DEBUG='-buildid= -X $(IMPORT_PATH)/intra/core.Date=$(DATESTR) -X $(IMPORT_PATH)/intra/core.Commit=$(COMMIT_ID)'
1212
LDFLAGS='-w -s -buildid= -X $(IMPORT_PATH)/intra/core.Date=$(DATESTR) -X $(IMPORT_PATH)/intra/core.Commit=$(COMMIT_ID)'
13-
CGO_LDFLAGS="$(CGO_LDFLAGS) -s -w -Wl,-z,max-page-size=16384"
13+
CGO_LDFLAGS="$(CGO_LDFLAGS) -checklinkname=0 -s -w -Wl,-z,max-page-size=16384"
1414

1515
# github.com/golang/mobile/blob/a1d90793fc/cmd/gomobile/bind.go#L36
1616
GOBIND=bind -trimpath -v -x -a -javapkg com.celzero.firestack

intra/core/overreach.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2026 RethinkDNS and its authors.
2+
//
3+
// This Source Code Form is subject to the terms of the Mozilla Public
4+
// License, v. 2.0. If a copy of the MPL was not distributed with this
5+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
package core
8+
9+
import _ "unsafe" // required for go:linkname
10+
11+
//go:linkname runtimeGoTraceback runtime.gotraceback
12+
func runtimeGoTraceback() (level int32, all, crash bool)
13+
14+
// GoTraceback returns the Go runtime's current traceback settings.
15+
func GoTraceback() (level int32, all, crash bool) {
16+
return runtimeGoTraceback()
17+
}
18+
19+
//go:linkname runtimeEnviron runtime.environ
20+
func runtimeEnviron() []string
21+
22+
// RuntimeEnviron returns the Go runtime's cached environment slice.
23+
//
24+
// Warning: building with this file enabled requires disabling the linker's
25+
// linkname checks: `-ldflags=-checklinkname=0`.
26+
func RuntimeEnviron() []string {
27+
return runtimeEnviron()
28+
}

intra/tunnel.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,9 @@ func (t *rtunnel) stat() (*x.NetStat, error) {
518518
out.GOSt.NumCgo = int64(runtime.NumCgoCall())
519519
out.GOSt.NumCPU = int64(runtime.NumCPU())
520520

521-
out.GOSt.Args = strings.Join(os.Args, ";")
522-
out.GOSt.Env = strings.Join(os.Environ(), ";")
521+
level, all, crash := core.GoTraceback()
522+
out.GOSt.Args = fmt.Sprintf("%d;%t;%t", level, all, crash)
523+
out.GOSt.Env = strings.Join(core.RuntimeEnviron(), ";")
523524
out.GOSt.Pers, _ = os.Executable()
524525

525526
if r := t.resolver; r != nil {

0 commit comments

Comments
 (0)