Skip to content

Commit

Permalink
Update launching processes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daiyangcheng committed Dec 23, 2023
1 parent 9f24496 commit b8e76ea
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 7 deletions.
9 changes: 8 additions & 1 deletion client/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,14 @@ func (ctl *Control) HandleNewProxyResp(inMsg *msg.NewProxyResp) {
if err != nil {
xl.Warn("[%s] 启动失败: %v", inMsg.ProxyName, err)
} else {
xl.Info("[%s] 映射启动成功, 感谢您使用LCF!", inMsg.ProxyName)
// http(s) 隧道规则
if ctl.pxyCfgs[inMsg.ProxyName].GetBaseConfig().ProxyType == "https" || ctl.pxyCfgs[inMsg.ProxyName].GetBaseConfig().ProxyType == "http" {
xl.Info("[%s] 映射启动成功, 感谢您使用LCF!", inMsg.ProxyName)
xl.Info("你可以使用 [%s] 连接至您的隧道: %s", inMsg.RemoteAddr, inMsg.ProxyName)
} else {
xl.Info("[%s] 映射启动成功, 感谢您使用LCF!", inMsg.ProxyName)
xl.Info("你可以使用 [%s] 连接至您的隧道: %s", ctl.clientCfg.ServerAddr+inMsg.RemoteAddr, inMsg.ProxyName)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/proxy/proxy_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,6 @@ func (pm *Manager) Reload(pxyCfgs map[string]config.ProxyConf) {
}
}
if len(addPxyNames) > 0 {
xl.Info("proxy added: %s", addPxyNames)
xl.Info("添加隧道: %s", addPxyNames)
}
}
31 changes: 26 additions & 5 deletions cmd/frpc/sub/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var rootCmd = &cobra.Command{
return nil
}

log.Info("欢迎使用LoCyanFrp映射客户端! v0.51.3 #20230823")
log.Info("欢迎使用LoCyanFrp, Stable Version: v0.51.3 - #2023121601")

// If cfgDir is not empty, run multiple frpc service for each config file in cfgDir.
// Note that it's only designed for testing. It's not guaranteed to be stable.
Expand All @@ -134,6 +134,22 @@ var rootCmd = &cobra.Command{
if len(cfgProxyIDs) > 1 {
var wg conc.WaitGroup

// 新建配置文件文件夹
iniDir := "./ini"

_, err := os.Stat(iniDir)
if err == nil {

Check warning on line 141 in cmd/frpc/sub/root.go

View workflow job for this annotation

GitHub Actions / lint

empty-block: this block is empty, you can remove it (revive)

Check warning on line 141 in cmd/frpc/sub/root.go

View workflow job for this annotation

GitHub Actions / lint

empty-block: this block is empty, you can remove it (revive)
} else if os.IsNotExist(err) {
err := os.Mkdir(iniDir, os.ModePerm)
if err != nil {
log.Error("Make ini folder failed: %s", err)
os.Exit(1)
}
} else {
log.Error("Make ini folder failed: %s", err)
os.Exit(1)
}

// 每一个都是新的协程
for _, proxyID := range cfgProxyIDs {
// 将循环变量赋值给局部变量
Expand All @@ -150,7 +166,7 @@ var rootCmd = &cobra.Command{
os.Exit(1)
}

log.Debug("Loading proxy config file: %s", configPath)
// log.Debug("Loading proxy config file: %s", configPath)

configFile, err := os.OpenFile(configPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, os.ModePerm)
if err != nil {
Expand Down Expand Up @@ -203,7 +219,12 @@ var rootCmd = &cobra.Command{
os.Exit(1)
}

defer file.Close()
defer func(file *os.File) {
err := file.Close()
if err != nil {
log.Error("Cant close file: %s", err)
}
}(file)

if _, err := file.WriteString(cfg); err != nil {
log.Error("Cant write content to config file: %s", err)
Expand Down Expand Up @@ -319,8 +340,8 @@ func startService(
cfg.LogMaxDays, cfg.DisableLogColor)

if cfgFile != "" {
log.Info("start frpc service for config file [%s]", cfgFile)
defer log.Info("frpc service for config file [%s] stopped", cfgFile)
log.Debug("Loading proxy config file: %s", cfgFile)
defer log.Debug("stopping proxy config file: %s", cfgFile)
}
svr, errRet := client.NewService(cfg, pxyCfgs, visitorCfgs, cfgFile)
if errRet != nil {
Expand Down
Loading

0 comments on commit b8e76ea

Please sign in to comment.