diff --git a/tools/cmd/at/main.go b/tools/cmd/at/main.go index 4658fc71a..a09244463 100644 --- a/tools/cmd/at/main.go +++ b/tools/cmd/at/main.go @@ -98,7 +98,9 @@ func send_rc_command(rc *utils.RemoteControlCmd, timeout float64) (err error) { if err != nil { return } - println(string(d)) + r := utils.BytesReader{Data: d} + + println(string(r.Data)) return } diff --git a/tools/utils/io.go b/tools/utils/io.go new file mode 100644 index 000000000..29bcc4311 --- /dev/null +++ b/tools/utils/io.go @@ -0,0 +1,19 @@ +package utils + +import ( + "io" +) + +type BytesReader struct { + Data []byte + Pos int64 +} + +func (self *BytesReader) Read(b []byte) (n int, err error) { + if self.Pos >= int64(len(self.Data)) { + return 0, io.EOF + } + n = copy(b, self.Data[self.Pos:]) + self.Pos += int64(n) + return +} diff --git a/tools/utils/sockets.go b/tools/utils/sockets.go index 245e9a2fd..c27bce5fd 100644 --- a/tools/utils/sockets.go +++ b/tools/utils/sockets.go @@ -2,9 +2,10 @@ package utils import ( "fmt" - "github.com/seancfoley/ipaddress-go/ipaddr" "runtime" "strings" + + "github.com/seancfoley/ipaddress-go/ipaddr" ) func Cut(s string, sep string) (string, string, bool) { @@ -21,7 +22,7 @@ func ParseSocketAddress(spec string) (network string, addr string, err error) { return } if network == "unix" { - if strings.HasSuffix(addr, "@") && runtime.GOOS != "linux" { + if strings.HasPrefix(addr, "@") && runtime.GOOS != "linux" { err = fmt.Errorf("Abstract UNIX sockets are only supported on Linux. Cannot use: %s", spec) } return