diff --git a/.gitignore b/.gitignore index 72c9fd3..e237cc4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ bin/ # Cache *.swp +*.swo diff --git a/cmd/frpc/main.go b/cmd/frpc/main.go index 7f07282..8f5b08b 100644 --- a/cmd/frpc/main.go +++ b/cmd/frpc/main.go @@ -3,7 +3,7 @@ package main import ( "os" "sync" - + "frp/pkg/utils/log" ) diff --git a/cmd/frps/main.go b/cmd/frps/main.go index 1288622..d2c98be 100644 --- a/cmd/frps/main.go +++ b/cmd/frps/main.go @@ -3,8 +3,8 @@ package main import ( "os" - "frp/pkg/utils/log" "frp/pkg/utils/conn" + "frp/pkg/utils/log" ) func main() { diff --git a/pkg/models/client.go b/pkg/models/client.go index 1f01d50..0ebac20 100644 --- a/pkg/models/client.go +++ b/pkg/models/client.go @@ -8,9 +8,9 @@ import ( ) type ProxyClient struct { - Name string - Passwd string - LocalPort int64 + Name string + Passwd string + LocalPort int64 } func (p *ProxyClient) GetLocalConn() (c *conn.Conn, err error) { @@ -24,7 +24,7 @@ func (p *ProxyClient) GetLocalConn() (c *conn.Conn, err error) { func (p *ProxyClient) GetRemoteConn(addr string, port int64) (c *conn.Conn, err error) { c = &conn.Conn{} - defer func(){ + defer func() { if err != nil { c.Close() } @@ -37,9 +37,9 @@ func (p *ProxyClient) GetRemoteConn(addr string, port int64) (c *conn.Conn, err } req := &ClientCtlReq{ - Type: WorkConn, - ProxyName: p.Name, - Passwd: p.Passwd, + Type: WorkConn, + ProxyName: p.Name, + Passwd: p.Passwd, } buf, _ := json.Marshal(req) @@ -64,7 +64,7 @@ func (p *ProxyClient) StartTunnel(serverAddr string, serverPort int64) (err erro } log.Debug("Join two conns, (l[%s] r[%s]) (l[%s] r[%s])", localConn.GetLocalAddr(), localConn.GetRemoteAddr(), - remoteConn.GetLocalAddr(), remoteConn.GetRemoteAddr()) + remoteConn.GetLocalAddr(), remoteConn.GetRemoteAddr()) go conn.Join(localConn, remoteConn) return nil } diff --git a/pkg/models/msg.go b/pkg/models/msg.go index 0062556..a3018e7 100644 --- a/pkg/models/msg.go +++ b/pkg/models/msg.go @@ -1,8 +1,8 @@ package models type GeneralRes struct { - Code int64 `json:"code"` - Msg string `json:"msg"` + Code int64 `json:"code"` + Msg string `json:"msg"` } // type @@ -12,16 +12,15 @@ const ( ) type ClientCtlReq struct { - Type int64 `json:"type"` - ProxyName string `json:"proxy_name"` - Passwd string `json:"passwd"` + Type int64 `json:"type"` + ProxyName string `json:"proxy_name"` + Passwd string `json:"passwd"` } type ClientCtlRes struct { GeneralRes } - type ServerCtlReq struct { - Type int64 `json:"type"` + Type int64 `json:"type"` } diff --git a/pkg/models/server.go b/pkg/models/server.go index 2c503dd..f8c9451 100644 --- a/pkg/models/server.go +++ b/pkg/models/server.go @@ -89,6 +89,7 @@ func (p *ProxyServer) Start() (err error) { p.UserConnList.Remove(element) } else { cliConn.Close() + p.Unlock() continue } p.Unlock() diff --git a/pkg/utils/log/log.go b/pkg/utils/log/log.go index 1a55c3c..f6587cd 100644 --- a/pkg/utils/log/log.go +++ b/pkg/utils/log/log.go @@ -22,7 +22,7 @@ func SetLogFile(logWay string, logFile string) { if logWay == "console" { Log.SetLogger("console", "") } else { - Log.SetLogger("file", `{"filename": "` + logFile + `"}`) + Log.SetLogger("file", `{"filename": "`+logFile+`"}`) } }