mirror of
https://github.com/ehang-io/nps.git
synced 2025-08-31 17:56:56 +00:00
Optimizing compatibility
This commit is contained in:
@@ -87,7 +87,7 @@ func StartFromFile(path string) {
|
||||
first := true
|
||||
cnf, err := config.NewConfig(path)
|
||||
if err != nil || cnf.CommonConfig == nil {
|
||||
logs.Error("Config file %s loading error", path)
|
||||
logs.Error("Config file %s loading error %s", path, err.Error())
|
||||
os.Exit(0)
|
||||
}
|
||||
logs.Info("Loading configuration file %s successfully", path)
|
||||
@@ -115,12 +115,12 @@ re:
|
||||
vkey := cnf.CommonConfig.VKey
|
||||
if isPub {
|
||||
// send global configuration to server and get status of config setting
|
||||
if _, err := c.SendConfigInfo(cnf.CommonConfig); err != nil {
|
||||
if _, err := c.SendInfo(cnf.CommonConfig.Client, common.NEW_CONF); err != nil {
|
||||
logs.Error(err)
|
||||
goto re
|
||||
}
|
||||
if !c.GetAddStatus() {
|
||||
logs.Error(errAdd)
|
||||
logs.Error("the web_user may have been occupied!")
|
||||
goto re
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ re:
|
||||
|
||||
//send hosts to server
|
||||
for _, v := range cnf.Hosts {
|
||||
if _, err := c.SendHostInfo(v); err != nil {
|
||||
if _, err := c.SendInfo(v, common.NEW_HOST); err != nil {
|
||||
logs.Error(err)
|
||||
goto re
|
||||
}
|
||||
@@ -146,12 +146,12 @@ re:
|
||||
|
||||
//send task to server
|
||||
for _, v := range cnf.Tasks {
|
||||
if _, err := c.SendTaskInfo(v); err != nil {
|
||||
if _, err := c.SendInfo(v, common.NEW_TASK); err != nil {
|
||||
logs.Error(err)
|
||||
goto re
|
||||
}
|
||||
if !c.GetAddStatus() {
|
||||
logs.Error(errAdd, v.Ports)
|
||||
logs.Error(errAdd, v.Ports, v.Remark)
|
||||
goto re
|
||||
}
|
||||
if v.Mode == "file" {
|
||||
@@ -166,7 +166,11 @@ re:
|
||||
}
|
||||
|
||||
c.Close()
|
||||
logs.Notice("web access login key ", vkey)
|
||||
if cnf.CommonConfig.Client.WebUserName == "" || cnf.CommonConfig.Client.WebPassword == "" {
|
||||
logs.Notice("web access login username:user password:%s", vkey)
|
||||
} else {
|
||||
logs.Notice("web access login username:%s password:%s", cnf.CommonConfig.Client.WebUserName, cnf.CommonConfig.Client.WebPassword)
|
||||
}
|
||||
NewRPClient(cnf.CommonConfig.Server, vkey, cnf.CommonConfig.Tp, cnf.CommonConfig.ProxyUrl, cnf).Start()
|
||||
CloseLocalServer()
|
||||
goto re
|
||||
|
@@ -86,12 +86,13 @@ func processP2P(localTcpConn net.Conn, config *config.CommonConfig, l *config.Lo
|
||||
logs.Error(err)
|
||||
return
|
||||
}
|
||||
link := conn.NewLink(common.CONN_TCP, l.Target, config.Cnf.Crypt, config.Cnf.Compress, localTcpConn.LocalAddr().String())
|
||||
if _, err := conn.NewConn(nowConn).SendLinkInfo(link); err != nil {
|
||||
//TODO just support compress now because there is not tls file in client packages
|
||||
link := conn.NewLink(common.CONN_TCP, l.Target, false, config.Client.Cnf.Compress, localTcpConn.LocalAddr().String())
|
||||
if _, err := conn.NewConn(nowConn).SendInfo(link, ""); err != nil {
|
||||
logs.Error(err)
|
||||
return
|
||||
}
|
||||
conn.CopyWaitGroup(nowConn, localTcpConn, config.Cnf.Crypt, config.Cnf.Compress, nil, nil, false, nil)
|
||||
conn.CopyWaitGroup(nowConn, localTcpConn, false, config.Client.Cnf.Compress, nil, nil, false, nil)
|
||||
}
|
||||
|
||||
func newUdpConn(config *config.CommonConfig, l *config.LocalServer) {
|
||||
|
Reference in New Issue
Block a user