format代码

This commit is contained in:
Hurricanezwf 2016-02-05 16:49:52 +08:00
parent 04c26d1c31
commit 60c9804776
7 changed files with 19 additions and 18 deletions

1
.gitignore vendored
View File

@ -28,3 +28,4 @@ bin/
# Cache # Cache
*.swp *.swp
*.swo

View File

@ -3,7 +3,7 @@ package main
import ( import (
"os" "os"
"sync" "sync"
"frp/pkg/utils/log" "frp/pkg/utils/log"
) )

View File

@ -3,8 +3,8 @@ package main
import ( import (
"os" "os"
"frp/pkg/utils/log"
"frp/pkg/utils/conn" "frp/pkg/utils/conn"
"frp/pkg/utils/log"
) )
func main() { func main() {

View File

@ -8,9 +8,9 @@ import (
) )
type ProxyClient struct { type ProxyClient struct {
Name string Name string
Passwd string Passwd string
LocalPort int64 LocalPort int64
} }
func (p *ProxyClient) GetLocalConn() (c *conn.Conn, err error) { 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) { func (p *ProxyClient) GetRemoteConn(addr string, port int64) (c *conn.Conn, err error) {
c = &conn.Conn{} c = &conn.Conn{}
defer func(){ defer func() {
if err != nil { if err != nil {
c.Close() c.Close()
} }
@ -37,9 +37,9 @@ func (p *ProxyClient) GetRemoteConn(addr string, port int64) (c *conn.Conn, err
} }
req := &ClientCtlReq{ req := &ClientCtlReq{
Type: WorkConn, Type: WorkConn,
ProxyName: p.Name, ProxyName: p.Name,
Passwd: p.Passwd, Passwd: p.Passwd,
} }
buf, _ := json.Marshal(req) 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(), 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) go conn.Join(localConn, remoteConn)
return nil return nil
} }

View File

@ -1,8 +1,8 @@
package models package models
type GeneralRes struct { type GeneralRes struct {
Code int64 `json:"code"` Code int64 `json:"code"`
Msg string `json:"msg"` Msg string `json:"msg"`
} }
// type // type
@ -12,16 +12,15 @@ const (
) )
type ClientCtlReq struct { type ClientCtlReq struct {
Type int64 `json:"type"` Type int64 `json:"type"`
ProxyName string `json:"proxy_name"` ProxyName string `json:"proxy_name"`
Passwd string `json:"passwd"` Passwd string `json:"passwd"`
} }
type ClientCtlRes struct { type ClientCtlRes struct {
GeneralRes GeneralRes
} }
type ServerCtlReq struct { type ServerCtlReq struct {
Type int64 `json:"type"` Type int64 `json:"type"`
} }

View File

@ -89,6 +89,7 @@ func (p *ProxyServer) Start() (err error) {
p.UserConnList.Remove(element) p.UserConnList.Remove(element)
} else { } else {
cliConn.Close() cliConn.Close()
p.Unlock()
continue continue
} }
p.Unlock() p.Unlock()

View File

@ -22,7 +22,7 @@ func SetLogFile(logWay string, logFile string) {
if logWay == "console" { if logWay == "console" {
Log.SetLogger("console", "") Log.SetLogger("console", "")
} else { } else {
Log.SetLogger("file", `{"filename": "` + logFile + `"}`) Log.SetLogger("file", `{"filename": "`+logFile+`"}`)
} }
} }