diff --git a/cmd/durdur/helpers.go b/cmd/durdur/helpers.go index e5f591b..0bc3e0d 100644 --- a/cmd/durdur/helpers.go +++ b/cmd/durdur/helpers.go @@ -8,6 +8,10 @@ import ( "github.com/urfave/cli/v2" ) +func writeLn(c *cli.Context, format string, a ...any) error { + return write(c, format+"\n", a...) +} + func write(c *cli.Context, format string, a ...any) error { _, err := io.WriteString(c.App.Writer, fmt.Sprintf(format, a...)) return err @@ -19,5 +23,5 @@ func marshalAndWrite(c *cli.Context, list any) error { return fmt.Errorf("marshal src list: %w", err) } - return write(c, string(b)) + return writeLn(c, string(b)) } diff --git a/internal/ebpf/list_test.go b/internal/ebpf/list_test.go index 370b259..6615bca 100644 --- a/internal/ebpf/list_test.go +++ b/internal/ebpf/list_test.go @@ -34,14 +34,14 @@ func TestList(t *testing.T) { c.Run("list ip and dns", func(c *qt.C) { newTWrap().Run(c, "attach", func(e *EBPF) { c.Assert(e.DropSrc(tSrcIP), qt.IsNil) - c.Assert(e.DropDNS("bora.sh", "google.com"), qt.IsNil) + c.Assert(e.DropDNS("bora.sh", "quik.bora.sh"), qt.IsNil) srcList, err := e.ListDNS() c.Assert(err, qt.IsNil) c.Assert(srcList, qt.HasLen, 2) c.Assert(srcList, qt.DeepEquals, map[string]int{ - "bora.sh": 0, - "google.com": 0, + "bora.sh": 0, + "quik.bora.sh": 0, }) TDNSLookup(c, "bora.sh", false) @@ -50,7 +50,7 @@ func TestList(t *testing.T) { c.Assert(err, qt.IsNil) c.Assert(srcList, qt.HasLen, 2) c.Assert(srcList["bora.sh"], qt.Not(qt.Equals), 0) - c.Assert(srcList["google.com"], qt.Equals, 0) + c.Assert(srcList["quik.bora.sh"], qt.Equals, 0) srcList, err = e.ListSrc() c.Assert(err, qt.IsNil)