sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

Remove null byte from tailscale log

Open word5355 opened this issue 3 months ago • 1 comments

Operating system

Linux

System version

Fedora 42

Installation type

Original sing-box Command Line

If you are using a graphical client, please provide the version of the client.

None

Version

sing-box version 1.12.9

Environment: go1.25.1 linux/amd64
Tags: with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_acme,with_clash_api,with_tailscale
Revision: 328a6de7976182700aaa4f7e2c134bd568b47d88
CGO: disabled

Description

Tailscale’s logger writes every JSON log line with the literal prefix [v\x00JSON]. When the line is later processed by logtail, the NUL is recognised and stripped out, but sing-box somehow logs \x00. Some editors see the null bytes and identify the file as binary, showing warning or refusing to open it as text.

types/logger/logger.go:

logf("[v\x00JSON]%d%s", level%10, je.buf.Bytes())

logtail/logtail.go:

vJSON = []byte("[v\x00JSON]") // precedes log level '0'-'9' byte, then JSON value
...
if i := bytes.Index(buf, vJSON); i != -1 {
	rest := buf[i+len(vJSON):]
	if len(rest) >= 2 {
		v := rest[0]
		if v >= '0' && v <= '9' {
			return int(v - '0'), rest[1:]
		}
	}
}
Image

Reproduction

  1. Install sing-box v1.12.9 (original command-line).
  2. Configure and run sing-box with Tailscale endpoint.
  3. Open log file.

Logs

INFO network: updated default interface eth0, index 3
TRACE endpoint/tailscale[hs-ep]: [v1] using fake (no-op) tun device
TRACE endpoint/tailscale[hs-ep]: [v1] using fake (no-op) OS network configurator
TRACE endpoint/tailscale[hs-ep]: dns: using *tailscale.dnsConfigurtor
TRACE endpoint/tailscale[hs-ep]: link state: interfaces.State{defaultRoute=[REDACTED_IP] ifs={eth0:[REDACTED_IP]/32 [REDACTED_IP]} v4=true v6=false}
TRACE endpoint/tailscale[hs-ep]: onPortUpdate(port=57317, network=udp6)
TRACE endpoint/tailscale[hs-ep]: [v1] warning: fakeRouter.UpdateMagicsockPort: not implemented.
TRACE endpoint/tailscale[hs-ep]: magicsock: [warning] failed to force-set UDP read buffer size to 7340032: operation not permitted; using kernel default values (impacts throughput only)
TRACE endpoint/tailscale[hs-ep]: magicsock: [warning] failed to force-set UDP write buffer size to 7340032: operation not permitted; using kernel default values (impacts throughput only)
TRACE endpoint/tailscale[hs-ep]: onPortUpdate(port=43015, network=udp4)
TRACE endpoint/tailscale[hs-ep]: [v1] warning: fakeRouter.UpdateMagicsockPort: not implemented.
TRACE endpoint/tailscale[hs-ep]: magicsock: [warning] failed to force-set UDP read buffer size to 7340032: operation not permitted; using kernel default values (impacts throughput only)
TRACE endpoint/tailscale[hs-ep]: magicsock: [warning] failed to force-set UDP write buffer size to 7340032: operation not permitted; using kernel default values (impacts throughput only)
TRACE endpoint/tailscale[hs-ep]: [v1] magicsock: peermtu: peer MTU status is false
TRACE endpoint/tailscale[hs-ep]: magicsock: disco key = [REDACTED_KEY]
TRACE endpoint/tailscale[hs-ep]: Creating WireGuard device...
TRACE endpoint/tailscale[hs-ep]: Bringing WireGuard device up...
TRACE endpoint/tailscale[hs-ep]: wg: [v2] UDP bind has been updated
TRACE endpoint/tailscale[hs-ep]: wg: [v2] Interface state was Down, requested Up, now Up
TRACE endpoint/tailscale[hs-ep]: Bringing router up...
TRACE endpoint/tailscale[hs-ep]: [v1] warning: fakeRouter.Up: not implemented.
TRACE endpoint/tailscale[hs-ep]: Clearing router settings...
TRACE endpoint/tailscale[hs-ep]: [v1] warning: fakeRouter.Set: not implemented.
TRACE endpoint/tailscale[hs-ep]: Starting network monitor...
TRACE endpoint/tailscale[hs-ep]: Engine created.
DEBUG endpoint/tailscale[hs-ep]: tsnet running state path [REDACTED_PATH]
TRACE endpoint/tailscale[hs-ep]: pm: using backend prefs for "profile-bfc2": Prefs{ra=false dns=true want=true routes=[] statefulFiltering=false nf=on url="[REDACTED_URL]" host="app-singbox"}
TRACE endpoint/tailscale[hs-ep]: [v1] netmap packet filter: (not ready yet)
DEBUG endpoint/tailscale[hs-ep]: tsnet starting with hostname "[REDACTED_HOSTNAME]", varRoot "[REDACTED_ROOT]"
TRACE endpoint/tailscale[hs-ep]: Start
TRACE endpoint/tailscale[hs-ep]: wg: [v2] Routine: receive incoming mkReceiveFunc - started
TRACE endpoint/tailscale[hs-ep]: wg: [v2] Routine: receive incoming mkReceiveFunc - started
TRACE endpoint/tailscale[hs-ep]: wg: [v2] Routine: receive incoming receiveDERP - started
TRACE endpoint/tailscale[hs-ep]: [v[NULL BYTE HERE]JSON] {"Hostinfo":{"IPNVersion":"sing-box 1.12.9","BackendLogID":"[REDACTED_BACKEND_LOG_ID]","OS":"linux","OSVersion":"","Container":false,"Distro":"fedora","DistroVersion":"42","Desktop":true,"Hostname":"app-singbox","NoLogsNoSupport":true,"Machine":"x86_64","GoArch":"amd64","GoArchVar":"v1","GoVersion":"go1.25.1","Userspace":true,"UserspaceRouter":true,"AppConnector":false}}

Supporter

Integrity requirements

  • [x] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • [x] I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
  • [x] I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
  • [x] I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.

word5355 avatar Oct 18 '25 21:10 word5355

Given that the files are installed in /usr/, and not in /usr/local/, I presume it means zstd was installed from package, not from source ?

Cyan4973 avatar Sep 20 '25 14:09 Cyan4973

I presume it means zstd was installed from package, not from source ?

Do they set prefix when compiling a binary?

tansy avatar Sep 22 '25 14:09 tansy