Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use output instead of start #2

Open
wants to merge 1 commit into
base: firewalla
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions client/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
package client

import (
"encoding/json"
"fmt"
"io"
"os"
"strings"
"encoding/json"
"os/exec"
"runtime"
"strings"
"sync"
"time"
"os/exec"

"github.com/fatedier/frp/models/config"
"github.com/fatedier/frp/models/msg"
"github.com/fatedier/frp/utils/crypto"
Expand Down Expand Up @@ -389,10 +390,10 @@ func (ctl *Control) manager() {
if m.Error != "" {
ctl.Warn("[%s] start error: %s", m.ProxyName, m.Error)
cmdErr := ctl.generateRedisMessage(m.ProxyName, 1, m.Error)
if cmdErr != nil{
if cmdErr != nil {
ctl.Warn("redis-cli publish error: %v", cmdErr)
continue
}else{
} else {
os.Exit(1)
}
}
Expand All @@ -418,7 +419,7 @@ func (ctl *Control) manager() {
ctl.addProxy(m.ProxyName, pxy)
ctl.Info("[%s] start proxy success", m.ProxyName)
cmdErr := ctl.generateRedisMessage(m.ProxyName, 0, "")
if cmdErr != nil{
if cmdErr != nil {
ctl.Warn("redis-cli publish error: %v", cmdErr)
}
case *msg.Pong:
Expand Down Expand Up @@ -630,15 +631,15 @@ func (ctl *Control) reloadConf(pxyCfgs map[string]config.ProxyConf, vistorCfgs m
}
ctl.Info("vistor added: %v", addedVistorName)
}
func (ctl *Control) generateRedisMessage(port string, code int, message string) (err error){
func (ctl *Control) generateRedisMessage(port string, code int, message string) (err error) {
redisMessage := make(map[string]interface{})
arr := strings.Split(port, "SSH")
redisMessage["port"] = arr[1]
redisMessage["code"] = code
redisMessage["error"] = message
mjson, _ :=json.Marshal(redisMessage)
mString :=string(mjson)
cmd := exec.Command("redis-cli","publish","System:RemoteSupport",mString)
cmdErr := cmd.Start()
mjson, _ := json.Marshal(redisMessage)
mString := string(mjson)
cmd := exec.Command("redis-cli", "publish", "System:RemoteSupport", mString)
_, cmdErr := cmd.Output()
return cmdErr
}