From c949e765104f130aa3e5ba465bdebc3286bebe44 Mon Sep 17 00:00:00 2001 From: Eugene Burkov Date: Wed, 9 Mar 2022 17:26:30 +0500 Subject: [PATCH] all: imp code, docs --- internal/aghnet/arpdb.go | 4 ++++ internal/aghnet/net_test.go | 1 + internal/aghos/os.go | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/aghnet/arpdb.go b/internal/aghnet/arpdb.go index d0b0b17fafe..456917a6ac2 100644 --- a/internal/aghnet/arpdb.go +++ b/internal/aghnet/arpdb.go @@ -122,6 +122,8 @@ func (ns *neighs) reset(with []Neighbor) { // command. lenHint is a hint for the size of the allocated slice of Neighbors. type parseFunc func(sc *bufio.Scanner, lenHint int) (ns []Neighbor) +// runcmdFunc is the function that runs some command and returns its output +// wrapped to be a io.Reader. type runcmdFunc func() (r io.Reader, err error) // cmdARPDB is the implementation of the ARPDB that uses command line to @@ -188,6 +190,8 @@ type arpdbs struct { last int } +// newARPDBs returns a properly initialized *arpdbs. It begins refreshing from +// the first of arps. func newARPDBs(arps ...ARPDB) (arp *arpdbs) { return &arpdbs{ arps: arps, diff --git a/internal/aghnet/net_test.go b/internal/aghnet/net_test.go index a1526d55548..34e99faaddf 100644 --- a/internal/aghnet/net_test.go +++ b/internal/aghnet/net_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/require" ) +// testdata is the filesystem containing data for testing the package. var testdata fs.FS = os.DirFS("./testdata") func TestMain(m *testing.M) { diff --git a/internal/aghos/os.go b/internal/aghos/os.go index 21523c535ed..8ac189a1c14 100644 --- a/internal/aghos/os.go +++ b/internal/aghos/os.go @@ -54,7 +54,7 @@ func HaveAdminRights() (bool, error) { // MaxCmdOutputSize is the maximum length of performed shell command output in // bytes. -const MaxCmdOutputSize = 2 * 1024 +const MaxCmdOutputSize = 64 * 1024 // RunCommand runs shell command. func RunCommand(command string, arguments ...string) (code int, output string, err error) {