This commit is contained in:
TenderIronh
2023-08-09 22:52:29 +08:00
parent b2a7619bd6
commit e21adebc26
8 changed files with 355 additions and 15 deletions
+12 -13
View File
@@ -15,14 +15,15 @@ var gConf Config
type AppConfig struct {
// required
AppName string
Protocol string
SrcPort int
PeerNode string
DstPort int
DstHost string
PeerUser string
Enabled int // default:1
AppName string
Protocol string
Whitelist string
SrcPort int
PeerNode string
DstPort int
DstHost string
PeerUser string
Enabled int // default:1
// runtime info
peerVersion string
peerToken uint64
@@ -207,6 +208,7 @@ func parseParams(subCommand string) {
node := fset.String("node", "", "node name. 8-31 characters. if not set, it will be hostname")
peerNode := fset.String("peernode", "", "peer node name that you want to connect")
dstIP := fset.String("dstip", "127.0.0.1", "destination ip ")
whiteList := fset.String("whitelist", "", "whitelist for p2pApp ")
dstPort := fset.Int("dstport", 0, "destination port ")
srcPort := fset.Int("srcport", 0, "source port ")
tcpPort := fset.Int("tcpport", 0, "tcp port for upnp or publicip")
@@ -226,6 +228,7 @@ func parseParams(subCommand string) {
config := AppConfig{Enabled: 1}
config.PeerNode = *peerNode
config.DstHost = *dstIP
config.Whitelist = *whiteList
config.DstPort = *dstPort
config.SrcPort = *srcPort
config.Protocol = *protocol
@@ -264,15 +267,11 @@ func parseParams(subCommand string) {
gConf.Network.ServerHost = *serverHost
}
if *node != "" {
if len(*node) < MinNodeNameLen {
gLog.Println(LvERROR, ErrNodeTooShort)
os.Exit(9)
}
gConf.Network.Node = *node
} else {
envNode := os.Getenv("OPENP2P_NODE")
if envNode != "" {
gConf.setNode(envNode)
gConf.Network.Node = envNode
}
if gConf.Network.Node == "" { // if node name not set. use os.Hostname
gConf.Network.Node = defaultNodeName()