diff --git a/cmd/auth/cmd.go b/cmd/auth/cmd.go deleted file mode 100644 index d99e92e..0000000 --- a/cmd/auth/cmd.go +++ /dev/null @@ -1,31 +0,0 @@ -package auth - -import ( - "net" - "os/exec" - "strconv" - "strings" - - "github.com/sirupsen/logrus" -) - -type CmdAuthProvider struct { - Cmd string -} - -func (p *CmdAuthProvider) Auth(addr net.Addr, auth []byte, sSend uint64, sRecv uint64) (bool, string) { - cmd := exec.Command(p.Cmd, addr.String(), string(auth), strconv.Itoa(int(sSend)), strconv.Itoa(int(sRecv))) - out, err := cmd.Output() - if err != nil { - if _, ok := err.(*exec.ExitError); ok { - return false, strings.TrimSpace(string(out)) - } else { - logrus.WithFields(logrus.Fields{ - "error": err, - }).Error("Failed to execute auth command") - return false, "internal error" - } - } else { - return true, strings.TrimSpace(string(out)) - } -} diff --git a/cmd/auth/http.go b/cmd/auth/external.go similarity index 72% rename from cmd/auth/http.go rename to cmd/auth/external.go index 4b9162d..768e331 100644 --- a/cmd/auth/http.go +++ b/cmd/auth/external.go @@ -6,10 +6,34 @@ import ( "io/ioutil" "net" "net/http" + "os/exec" + "strconv" + "strings" "github.com/sirupsen/logrus" ) +type CmdAuthProvider struct { + Cmd string +} + +func (p *CmdAuthProvider) Auth(addr net.Addr, auth []byte, sSend uint64, sRecv uint64) (bool, string) { + cmd := exec.Command(p.Cmd, addr.String(), string(auth), strconv.Itoa(int(sSend)), strconv.Itoa(int(sRecv))) + out, err := cmd.Output() + if err != nil { + if _, ok := err.(*exec.ExitError); ok { + return false, strings.TrimSpace(string(out)) + } else { + logrus.WithFields(logrus.Fields{ + "error": err, + }).Error("Failed to execute auth command") + return false, "internal error" + } + } else { + return true, strings.TrimSpace(string(out)) + } +} + type HTTPAuthProvider struct { Client *http.Client URL string diff --git a/cmd/client_gpl.go b/cmd/client_gpl.go index cf82082..177e89b 100644 --- a/cmd/client_gpl.go +++ b/cmd/client_gpl.go @@ -47,7 +47,7 @@ func startTUN(config *clientConfig, client *core.Client, errChan chan error) { tcpSendBufferSize, err = units.RAMInBytes(config.TUN.TCPSendBufferSize) if err != nil { logrus.WithFields(logrus.Fields{ - "err": err, + "error": err, "tcp-sndbuf": config.TUN.TCPSendBufferSize, }).Fatal("Failed to parse tcp-sndbuf in the TUN config") } @@ -61,13 +61,13 @@ func startTUN(config *clientConfig, client *core.Client, errChan chan error) { tcpReceiveBufferSize, err = units.RAMInBytes(config.TUN.TCPReceiveBufferSize) if err != nil { logrus.WithFields(logrus.Fields{ - "err": err, + "error": err, "tcp-rcvbuf": config.TUN.TCPReceiveBufferSize, }).Fatal("Failed to parse tcp-rcvbuf in the TUN config") } if (tcpReceiveBufferSize != 0 && tcpReceiveBufferSize < tcp.MinBufferSize) || tcpReceiveBufferSize > tcp.MaxBufferSize { logrus.WithFields(logrus.Fields{ - "err": err, + "error": err, "tcp-rcvbuf": config.TUN.TCPReceiveBufferSize, }).Fatal("Invalid tcp-rcvbuf in the TUN config") } diff --git a/cmd/main.go b/cmd/main.go index 512b85c..36ef82c 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -57,8 +57,10 @@ var rootCmd = &cobra.Command{ logrus.SetFormatter(&nested.Formatter{ FieldsOrder: []string{ "version", "url", - "config", "file", "mode", + "config", "file", "mode", "protocol", + "cert", "key", "addr", "src", "dst", "session", "action", "interface", + "tcp-sndbuf", "tcp-rcvbuf", "retry", "interval", "code", "msg", "error", },