Explorar o código

cmd/frps: improve the description of login failed

fatedier %!s(int64=8) %!d(string=hai) anos
pai
achega
a4e051d494
Modificáronse 1 ficheiros con 7 adicións e 6 borrados
  1. 7 6
      src/frp/cmd/frps/control.go

+ 7 - 6
src/frp/cmd/frps/control.go

@@ -69,11 +69,6 @@ func controlWorker(c *conn.Conn) {
 
 	// login when type is NewCtlConn or NewWorkConn
 	ret, info := doLogin(cliReq, c)
-	s, ok := server.ProxyServers[cliReq.ProxyName]
-	if !ok {
-		log.Warn("ProxyName [%s] is not exist", cliReq.ProxyName)
-		return
-	}
 	// if login type is NewWorkConn, nothing will be send to frpc
 	if cliReq.Type != consts.NewWorkConn {
 		cliRes := &msg.ControlRes{
@@ -84,7 +79,7 @@ func controlWorker(c *conn.Conn) {
 		byteBuf, _ := json.Marshal(cliRes)
 		err = c.Write(string(byteBuf) + "\n")
 		if err != nil {
-			log.Warn("ProxyName [%s], write to client error, proxy exit", s.Name)
+			log.Warn("ProxyName [%s], write to client error, proxy exit", cliReq.ProxyName)
 			time.Sleep(1 * time.Second)
 			return
 		}
@@ -98,6 +93,12 @@ func controlWorker(c *conn.Conn) {
 		return
 	}
 
+	s, ok := server.ProxyServers[cliReq.ProxyName]
+	if !ok {
+		log.Warn("ProxyName [%s], is not exist now", cliReq.ProxyName)
+		return
+	}
+
 	// create a channel for sending messages
 	msgSendChan := make(chan interface{}, 1024)
 	go msgSender(s, c, msgSendChan)