mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-17 16:37:30 +00:00
logtail: remove unneeded IP redaction code
Updates tailscale/corp#15664 Change-Id: I9523a43860685048548890cf1931ee6cbd60452c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
fd63123849
commit
4fa9411e3f
@@ -15,7 +15,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-json-experiment/json/jsontext"
|
||||
"tailscale.com/envknob"
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/tstime"
|
||||
"tailscale.com/util/must"
|
||||
@@ -316,85 +315,6 @@ func TestLoggerWriteResult(t *testing.T) {
|
||||
t.Errorf("mismatch.\n got: %#q\nwant: %#q", back, want)
|
||||
}
|
||||
}
|
||||
func TestRedact(t *testing.T) {
|
||||
envknob.Setenv("TS_OBSCURE_LOGGED_IPS", "true")
|
||||
tests := []struct {
|
||||
in string
|
||||
want string
|
||||
}{
|
||||
// tests for ipv4 addresses
|
||||
{
|
||||
"120.100.30.47",
|
||||
"120.100.x.x",
|
||||
},
|
||||
{
|
||||
"192.167.0.1/65",
|
||||
"192.167.x.x/65",
|
||||
},
|
||||
{
|
||||
"node [5Btdd] d:e89a3384f526d251 now using 10.0.0.222:41641 mtu=1360 tx=d81a8a35a0ce",
|
||||
"node [5Btdd] d:e89a3384f526d251 now using 10.0.x.x:41641 mtu=1360 tx=d81a8a35a0ce",
|
||||
},
|
||||
//tests for ipv6 addresses
|
||||
{
|
||||
"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"2001:0db8:x",
|
||||
},
|
||||
{
|
||||
"2345:0425:2CA1:0000:0000:0567:5673:23b5",
|
||||
"2345:0425:x",
|
||||
},
|
||||
{
|
||||
"2601:645:8200:edf0::c9de/64",
|
||||
"2601:645:x/64",
|
||||
},
|
||||
{
|
||||
"node [5Btdd] d:e89a3384f526d251 now using 2051:0000:140F::875B:131C mtu=1360 tx=d81a8a35a0ce",
|
||||
"node [5Btdd] d:e89a3384f526d251 now using 2051:0000:x mtu=1360 tx=d81a8a35a0ce",
|
||||
},
|
||||
{
|
||||
"2601:645:8200:edf0::c9de/64 2601:645:8200:edf0:1ce9:b17d:71f5:f6a3/64",
|
||||
"2601:645:x/64 2601:645:x/64",
|
||||
},
|
||||
//tests for tailscale ip addresses
|
||||
{
|
||||
"100.64.5.6",
|
||||
"100.64.5.6",
|
||||
},
|
||||
{
|
||||
"fd7a:115c:a1e0::/96",
|
||||
"fd7a:115c:a1e0::/96",
|
||||
},
|
||||
//tests for ipv6 and ipv4 together
|
||||
{
|
||||
"192.167.0.1 2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"192.167.x.x 2001:0db8:x",
|
||||
},
|
||||
{
|
||||
"node [5Btdd] d:e89a3384f526d251 now using 10.0.0.222:41641 mtu=1360 tx=d81a8a35a0ce 2345:0425:2CA1::0567:5673:23b5",
|
||||
"node [5Btdd] d:e89a3384f526d251 now using 10.0.x.x:41641 mtu=1360 tx=d81a8a35a0ce 2345:0425:x",
|
||||
},
|
||||
{
|
||||
"100.64.5.6 2091:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"100.64.5.6 2091:0db8:x",
|
||||
},
|
||||
{
|
||||
"192.167.0.1 120.100.30.47 2041:0000:140F::875B:131B",
|
||||
"192.167.x.x 120.100.x.x 2041:0000:x",
|
||||
},
|
||||
{
|
||||
"fd7a:115c:a1e0::/96 192.167.0.1 2001:0db8:85a3:0000:0000:8a2e:0370:7334",
|
||||
"fd7a:115c:a1e0::/96 192.167.x.x 2001:0db8:x",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
gotBuf := redactIPs([]byte(tt.in))
|
||||
if string(gotBuf) != tt.want {
|
||||
t.Errorf("for %q,\n got: %#q\nwant: %#q\n", tt.in, gotBuf, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppendMetadata(t *testing.T) {
|
||||
var l Logger
|
||||
|
Reference in New Issue
Block a user