summaryrefslogtreecommitdiff
path: root/pkg/client/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/client/client.go')
-rw-r--r--pkg/client/client.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/pkg/client/client.go b/pkg/client/client.go
index 2f0a16e..8f5fc58 100644
--- a/pkg/client/client.go
+++ b/pkg/client/client.go
@@ -2,8 +2,9 @@ package client
import (
"tunnel/pkg/config"
- "strings"
+ "tunnel/pkg/netstring"
"errors"
+ "bytes"
"time"
"net"
"io"
@@ -32,10 +33,16 @@ func (c *Client) Send(args []string) (string, error) {
c.conn.SetDeadline(t)
}()
- msg := strings.Join(args, " ")
+ out := new(bytes.Buffer)
+ enc := netstring.NewEncoder(out)
+
+ for _, s := range args {
+ enc.Encode(s)
+ }
+
buf := make([]byte, config.BufSize)
- _, ew := c.conn.Write([]byte(msg))
+ _, ew := c.conn.Write([]byte(out.Bytes()))
if ew != nil {
return "", ew
}