forked from ehang-io/nps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
刘河
committed
Feb 16, 2019
1 parent
9f6b33a
commit 3b18d66
Showing
64 changed files
with
1,414 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/binary" | ||
"github.com/cnlh/nps/lib/common" | ||
"log" | ||
"os" | ||
) | ||
|
||
func RegisterLocalIp(server string, vKey string, tp string, proxyUrl string, hour int) { | ||
c, err := NewConn(tp, vKey, server, common.WORK_REGISTER, proxyUrl) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
if err := binary.Write(c, binary.LittleEndian, int32(hour)); err != nil { | ||
log.Fatalln(err) | ||
} | ||
log.Printf("Successful ip registration for local public network, the validity period is %d hours.", hour) | ||
os.Exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/cnlh/nps/lib/common" | ||
"github.com/cnlh/nps/lib/config" | ||
"github.com/cnlh/nps/lib/lg" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
func GetTaskStatus(path string) { | ||
cnf, err := config.NewConfig(path) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
c, err := NewConn(cnf.CommonConfig.Tp, cnf.CommonConfig.VKey, cnf.CommonConfig.Server, common.WORK_CONFIG, cnf.CommonConfig.ProxyUrl) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
if _, err := c.Write([]byte(common.WORK_STATUS)); err != nil { | ||
log.Fatalln(err) | ||
} | ||
if f, err := common.ReadAllFromFile(filepath.Join(common.GetTmpPath(), "npc_vkey.txt")); err != nil { | ||
log.Fatalln(err) | ||
} else if _, err := c.Write([]byte(string(f))); err != nil { | ||
log.Fatalln(err) | ||
} | ||
if l, err := c.GetLen(); err != nil { | ||
log.Fatalln(err) | ||
} else if b, err := c.ReadLen(l); err != nil { | ||
lg.Fatalln(err) | ||
} else { | ||
arr := strings.Split(string(b), common.CONN_DATA_SEQ) | ||
for _, v := range cnf.Hosts { | ||
if common.InArr(arr, v.Remark) { | ||
log.Println(v.Remark, "ok") | ||
} else { | ||
log.Println(v.Remark, "not running") | ||
} | ||
} | ||
for _, v := range cnf.Tasks { | ||
if common.InArr(arr, v.Remark) { | ||
log.Println(v.Remark, "ok") | ||
} else { | ||
log.Println(v.Remark, "not running") | ||
} | ||
} | ||
} | ||
os.Exit(0) | ||
} |
Oops, something went wrong.