mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
tstest/natlab: get tailscaled logs from gokrazy via syslog
Using https://github.com/gokrazy/gokrazy/pull/275 This is much lower latency than logcatcher, which is higher latency and chunkier. And this is better than getting it via 'tailscale debug daemon-logs', which misses early interesting logs. Updates #13038 Change-Id: I499ec254c003a9494c0e9910f9c650c8ac44ef33 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
10662c4282
commit
10d0ce8dde
@@ -397,10 +397,10 @@ func (n *network) serveLogCatcherConn(clientRemoteIP netip.Addr, c net.Conn) {
|
||||
if node != nil {
|
||||
node.logMu.Lock()
|
||||
defer node.logMu.Unlock()
|
||||
node.logCatcherWrites++
|
||||
for _, lg := range logs {
|
||||
tStr := lg.Logtail.Client_Time.Round(time.Millisecond).Format(time.RFC3339Nano)
|
||||
fmt.Fprintf(&node.logBuf, "[%v] %s\n", tStr, lg.Text)
|
||||
log.Printf("LOG %v [%v] %s\n", clientRemoteIP, tStr, lg.Text)
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -416,6 +416,7 @@ var (
|
||||
fakeDERP1IP = netip.AddrFrom4([4]byte{33, 4, 0, 1}) // 3340=DERP; 1=derp 1
|
||||
fakeDERP2IP = netip.AddrFrom4([4]byte{33, 4, 0, 2}) // 3340=DERP; 1=derp 1
|
||||
fakeLogCatcherIP = netip.AddrFrom4([4]byte{52, 52, 0, 4})
|
||||
fakeSyslogIP = netip.AddrFrom4([4]byte{52, 52, 0, 9})
|
||||
)
|
||||
|
||||
type EthernetPacket struct {
|
||||
@@ -501,16 +502,18 @@ func (n *network) MACOfIP(ip netip.Addr) (_ MAC, ok bool) {
|
||||
}
|
||||
|
||||
type node struct {
|
||||
mac MAC
|
||||
interfaceID int
|
||||
net *network
|
||||
lanIP netip.Addr // must be in net.lanIP prefix + unique in net
|
||||
mac MAC
|
||||
interfaceID int
|
||||
net *network
|
||||
lanIP netip.Addr // must be in net.lanIP prefix + unique in net
|
||||
verboseSyslog bool
|
||||
|
||||
// logMu guards logBuf.
|
||||
// TODO(bradfitz): conditionally write these out to separate files at the end?
|
||||
// Currently they only hold logcatcher logs.
|
||||
logMu sync.Mutex
|
||||
logBuf bytes.Buffer
|
||||
logMu sync.Mutex
|
||||
logBuf bytes.Buffer
|
||||
logCatcherWrites int
|
||||
}
|
||||
|
||||
type derpServer struct {
|
||||
@@ -1007,6 +1010,19 @@ func (n *network) HandleEthernetIPv4PacketForRouter(ep EthernetPacket) {
|
||||
return
|
||||
}
|
||||
|
||||
if isUDP && dstIP == fakeSyslogIP {
|
||||
node, ok := n.nodesByIP[srcIP]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if node.verboseSyslog {
|
||||
// TODO(bradfitz): parse this and capture it, structured, into
|
||||
// node's log buffer.
|
||||
log.Printf("syslog from %v: %s", srcIP, udp.Payload)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if !toForward && isNATPMP(packet) {
|
||||
n.handleNATPMPRequest(UDPPacket{
|
||||
Src: netip.AddrPortFrom(srcIP, uint16(udp.SrcPort)),
|
||||
|
Reference in New Issue
Block a user