mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-29 05:41:23 +08:00
fix #774
This commit is contained in:
parent
ecfa30ef0c
commit
35692ea6fd
@ -58,27 +58,29 @@ func (s *server) Start(in *gen.LoadConfigReq, out *gen.ErrorResp) (_ error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *in.NeedExtraProcess {
|
if *in.NeedExtraProcess {
|
||||||
extraConfPath := *in.ExtraProcessConfDir + string(os.PathSeparator) + "extra.conf"
|
|
||||||
f, e := os.OpenFile(extraConfPath, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 700)
|
|
||||||
if e != nil {
|
|
||||||
err = E.Cause(e, "Failed to open extra.conf")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, e = f.WriteString(*in.ExtraProcessConf)
|
|
||||||
if e != nil {
|
|
||||||
err = E.Cause(e, "Failed to write extra.conf")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_ = f.Close()
|
|
||||||
args, e := shlex.Split(*in.ExtraProcessArgs)
|
args, e := shlex.Split(*in.ExtraProcessArgs)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
err = E.Cause(e, "Failed to parse args")
|
err = E.Cause(e, "Failed to parse args")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for idx, arg := range args {
|
if in.ExtraProcessConf != nil {
|
||||||
if strings.Contains(arg, "%s") {
|
extraConfPath := *in.ExtraProcessConfDir + string(os.PathSeparator) + "extra.conf"
|
||||||
args[idx] = fmt.Sprintf(arg, extraConfPath)
|
f, e := os.OpenFile(extraConfPath, os.O_CREATE|os.O_TRUNC|os.O_RDWR, 700)
|
||||||
break
|
if e != nil {
|
||||||
|
err = E.Cause(e, "Failed to open extra.conf")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, e = f.WriteString(*in.ExtraProcessConf)
|
||||||
|
if e != nil {
|
||||||
|
err = E.Cause(e, "Failed to write extra.conf")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_ = f.Close()
|
||||||
|
for idx, arg := range args {
|
||||||
|
if strings.Contains(arg, "%s") {
|
||||||
|
args[idx] = fmt.Sprintf(arg, extraConfPath)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user