allow gencfg overwrite and ntp all failed
This commit is contained in:
parent
76071f0d0d
commit
9fce61bf11
|
@ -1,4 +1,6 @@
|
|||
Config output dir: /tmp/eg_gen_p2p
|
||||
Enable generated config overwrite: false
|
||||
Add NodeID to the interface name: true
|
||||
ConfigTemplate for edge node: ""
|
||||
Network name: "EgNet"
|
||||
Edge Node:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Config output dir: /tmp/eg_gen_p2p
|
||||
Enable generated config overwrite: false
|
||||
Add NodeID to the interface name: true
|
||||
ConfigTemplate for edge node: "EgNet_edge1.yaml"
|
||||
Network name: "EgNet"
|
||||
Edge Node:
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Config output dir: /tmp/eg_gen_static
|
||||
Enable generated config overwrite: false
|
||||
Add NodeID to the interface name: true
|
||||
ConfigTemplate for edge node: "EgNet_edge1.yaml"
|
||||
Network name: "EgNet"
|
||||
Edge Node:
|
||||
|
|
|
@ -3,7 +3,7 @@ Interface:
|
|||
Name: EgNet001
|
||||
VPPIFaceID: 1
|
||||
VPPBridgeID: 4242
|
||||
MacAddrPrefix: FA:A7:11:D6
|
||||
MacAddrPrefix: 96:BB:DC:52
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
|
@ -16,7 +16,7 @@ NodeName: EgNet001
|
|||
PostScript: ""
|
||||
DefaultTTL: 200
|
||||
L2FIBTimeout: 3600
|
||||
PrivKey: +KAYwkRgacUbxc52t04z8fTJBgvrkPLsisr0qJOhIUE=
|
||||
PrivKey: lyQLML+TbAZvrJpa25ARTAfMvHVQa/a1n3Wcwo7nkDU=
|
||||
ListenPort: 3001
|
||||
DisabledAf:
|
||||
IPv4: false
|
||||
|
@ -40,11 +40,11 @@ DynamicRoute:
|
|||
SaveNewPeers: true
|
||||
SuperNode:
|
||||
UseSuperNode: true
|
||||
PSKey: yl/4SNFee7+kNekajVCrK0toqXJ4mlT4IN0klyAgyqU=
|
||||
PSKey: Ld8FN/TNcmR21xdhMTCSeZBxrJ1z+FFvnQSnTwSxgUE=
|
||||
EndpointV4: 127.0.0.1:3456
|
||||
PubKeyV4: 1NS6MxL2LUIlMsppJ5JfHnlofQfCxDUzaItBGwz+jBo=
|
||||
PubKeyV4: j6+qNLYwGLILh4VKXc2fGeQy828RnRasA6zKHk3T/kw=
|
||||
EndpointV6: ""
|
||||
PubKeyV6: gSBwlJH4aUPRfSP4ZHKAnXIkPZuVaEhsLBispLYFiwo=
|
||||
PubKeyV6: SdrhLctYIQ7lEurGNn0ZjM8ezkPaKPCI+nAbrnwvUDA=
|
||||
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
|
||||
SkipLocalIP: false
|
||||
AdditionalLocalIP: []
|
||||
|
@ -62,7 +62,7 @@ DynamicRoute:
|
|||
NTPConfig:
|
||||
UseNTP: true
|
||||
MaxServerUse: 8
|
||||
SyncTimeInterval: 3600
|
||||
SyncTimeInterval: 99999
|
||||
NTPTimeout: 3
|
||||
Servers:
|
||||
- time.google.com
|
||||
|
@ -85,6 +85,13 @@ DynamicRoute:
|
|||
- 1.pool.ntp.org
|
||||
- 2.pool.ntp.org
|
||||
- 3.pool.ntp.org
|
||||
- cn.ntp.org.cn
|
||||
- edu.ntp.org.cn
|
||||
- hk.ntp.org.cn
|
||||
- tw.ntp.org.cn
|
||||
- ntp.aliyun.com
|
||||
- time1.cloud.tencent.com
|
||||
- ntp.tuna.tsinghua.edu.cn
|
||||
NextHopTable: {}
|
||||
ResetEndPointInterval: 600
|
||||
Peers: []
|
||||
|
|
|
@ -3,7 +3,7 @@ Interface:
|
|||
Name: EgNet002
|
||||
VPPIFaceID: 1
|
||||
VPPBridgeID: 4242
|
||||
MacAddrPrefix: FA:A7:11:D6
|
||||
MacAddrPrefix: 96:BB:DC:52
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
|
@ -16,7 +16,7 @@ NodeName: EgNet002
|
|||
PostScript: ""
|
||||
DefaultTTL: 200
|
||||
L2FIBTimeout: 3600
|
||||
PrivKey: jDAolOiiRj/ju1xpVagZTtsxJSJba2rjp7J2XMc3yoM=
|
||||
PrivKey: r6vMkwreEkbpXoaHgdecPuWhaVK4qWlKazgQbYPDSQ4=
|
||||
ListenPort: 3002
|
||||
DisabledAf:
|
||||
IPv4: false
|
||||
|
@ -40,11 +40,11 @@ DynamicRoute:
|
|||
SaveNewPeers: true
|
||||
SuperNode:
|
||||
UseSuperNode: true
|
||||
PSKey: FJfjc+wRfk0FSuUkHlXl6D8xPzOKYdy3bxeYr5cpevQ=
|
||||
PSKey: Wmhz6SvUNBGczD0iJjHn7gUGy15ahjQsr4lKJAqDE3A=
|
||||
EndpointV4: 127.0.0.1:3456
|
||||
PubKeyV4: 1NS6MxL2LUIlMsppJ5JfHnlofQfCxDUzaItBGwz+jBo=
|
||||
PubKeyV4: j6+qNLYwGLILh4VKXc2fGeQy828RnRasA6zKHk3T/kw=
|
||||
EndpointV6: ""
|
||||
PubKeyV6: gSBwlJH4aUPRfSP4ZHKAnXIkPZuVaEhsLBispLYFiwo=
|
||||
PubKeyV6: SdrhLctYIQ7lEurGNn0ZjM8ezkPaKPCI+nAbrnwvUDA=
|
||||
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
|
||||
SkipLocalIP: false
|
||||
AdditionalLocalIP: []
|
||||
|
@ -62,7 +62,7 @@ DynamicRoute:
|
|||
NTPConfig:
|
||||
UseNTP: true
|
||||
MaxServerUse: 8
|
||||
SyncTimeInterval: 3600
|
||||
SyncTimeInterval: 99999
|
||||
NTPTimeout: 3
|
||||
Servers:
|
||||
- time.google.com
|
||||
|
@ -85,6 +85,13 @@ DynamicRoute:
|
|||
- 1.pool.ntp.org
|
||||
- 2.pool.ntp.org
|
||||
- 3.pool.ntp.org
|
||||
- cn.ntp.org.cn
|
||||
- edu.ntp.org.cn
|
||||
- hk.ntp.org.cn
|
||||
- tw.ntp.org.cn
|
||||
- ntp.aliyun.com
|
||||
- time1.cloud.tencent.com
|
||||
- ntp.tuna.tsinghua.edu.cn
|
||||
NextHopTable: {}
|
||||
ResetEndPointInterval: 600
|
||||
Peers: []
|
||||
|
|
|
@ -3,7 +3,7 @@ Interface:
|
|||
Name: EgNet100
|
||||
VPPIFaceID: 1
|
||||
VPPBridgeID: 4242
|
||||
MacAddrPrefix: FA:A7:11:D6
|
||||
MacAddrPrefix: 96:BB:DC:52
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
|
@ -16,7 +16,7 @@ NodeName: EgNet100
|
|||
PostScript: ""
|
||||
DefaultTTL: 200
|
||||
L2FIBTimeout: 3600
|
||||
PrivKey: yNf1SkvwV8c59GmesfTNxSut6gFjYKEg9uIsE05XQUI=
|
||||
PrivKey: U68wDkoic4xviKbOed9EBykI/wgpfpHGmc8N4ML5spE=
|
||||
ListenPort: 0
|
||||
DisabledAf:
|
||||
IPv4: false
|
||||
|
@ -40,11 +40,11 @@ DynamicRoute:
|
|||
SaveNewPeers: true
|
||||
SuperNode:
|
||||
UseSuperNode: true
|
||||
PSKey: 5BPLK4IX3oUd4ILQct2Xc690kkKeUd4jlyeFBkO6pHA=
|
||||
PSKey: Ffe8veAmFX/L8lmNxbb2sofBx/K1CCY3u1osKh0sL2g=
|
||||
EndpointV4: 127.0.0.1:3456
|
||||
PubKeyV4: 1NS6MxL2LUIlMsppJ5JfHnlofQfCxDUzaItBGwz+jBo=
|
||||
PubKeyV4: j6+qNLYwGLILh4VKXc2fGeQy828RnRasA6zKHk3T/kw=
|
||||
EndpointV6: ""
|
||||
PubKeyV6: gSBwlJH4aUPRfSP4ZHKAnXIkPZuVaEhsLBispLYFiwo=
|
||||
PubKeyV6: SdrhLctYIQ7lEurGNn0ZjM8ezkPaKPCI+nAbrnwvUDA=
|
||||
EndpointEdgeAPIUrl: http://127.0.0.1:3456/eg_net/eg_api
|
||||
SkipLocalIP: false
|
||||
AdditionalLocalIP: []
|
||||
|
@ -62,7 +62,7 @@ DynamicRoute:
|
|||
NTPConfig:
|
||||
UseNTP: true
|
||||
MaxServerUse: 8
|
||||
SyncTimeInterval: 3600
|
||||
SyncTimeInterval: 99999
|
||||
NTPTimeout: 3
|
||||
Servers:
|
||||
- time.google.com
|
||||
|
@ -85,6 +85,13 @@ DynamicRoute:
|
|||
- 1.pool.ntp.org
|
||||
- 2.pool.ntp.org
|
||||
- 3.pool.ntp.org
|
||||
- cn.ntp.org.cn
|
||||
- edu.ntp.org.cn
|
||||
- hk.ntp.org.cn
|
||||
- tw.ntp.org.cn
|
||||
- ntp.aliyun.com
|
||||
- time1.cloud.tencent.com
|
||||
- ntp.tuna.tsinghua.edu.cn
|
||||
NextHopTable: {}
|
||||
ResetEndPointInterval: 600
|
||||
Peers: []
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
NodeName: EgNetSP
|
||||
NodeName: EgNetSN
|
||||
PostScript: ""
|
||||
PrivKeyV4: W4hrtkH+htbU3/zAbKLdFeflMSUoKLf741DONjnLk18=
|
||||
PrivKeyV6: y47AY2xGs4uiUTHfMLhxooMPu/mFOezSFQ1iZ9giW7E=
|
||||
PrivKeyV4: vm2M7cNXbrUFORMiLvlbAxXX0l0yduo5TAJ9vyRTQZE=
|
||||
PrivKeyV6: xUJ4yaVl/O//PRS24UFMNXgmeF/rhykroCxdJrljFgE=
|
||||
ListenPort: 3456
|
||||
ListenPort_EdgeAPI: "3456"
|
||||
ListenPort_ManageAPI: "3456"
|
||||
|
@ -42,28 +42,28 @@ GraphRecalculateSetting:
|
|||
NextHopTable: {}
|
||||
EdgeTemplate: EgNet_edge001.yaml
|
||||
UsePSKForInterEdge: true
|
||||
makResetEndPointInterval: 1
|
||||
ResetEndPointInterval: 600
|
||||
Peers:
|
||||
- NodeID: 1
|
||||
Name: EgNet001
|
||||
PubKey: 6mdRv+McDgxWIq6bVB1ekxnMMWqhktzHc3JIq5bCSHI=
|
||||
PSKey: yl/4SNFee7+kNekajVCrK0toqXJ4mlT4IN0klyAgyqU=
|
||||
AdditionalCost: 10
|
||||
SkipLocalIP: false
|
||||
EndPoint: "127.0.0.1:3001"
|
||||
ExternalIP: ""
|
||||
- NodeID: 2
|
||||
Name: EgNet002
|
||||
PubKey: Xb6eYSf4fTkFRLGVqf1sAPBXMKlWsRAbajs1mYABT0w=
|
||||
PSKey: FJfjc+wRfk0FSuUkHlXl6D8xPzOKYdy3bxeYr5cpevQ=
|
||||
AdditionalCost: 10
|
||||
SkipLocalIP: false
|
||||
EndPoint: "127.0.0.1:3002"
|
||||
ExternalIP: ""
|
||||
- NodeID: 100
|
||||
Name: EgNet100
|
||||
PubKey: cZb8NNE1FBLy6kIUGXjdXCprUHuqzfpyXTwUxHJobnM=
|
||||
PSKey: 5BPLK4IX3oUd4ILQct2Xc690kkKeUd4jlyeFBkO6pHA=
|
||||
PubKey: lMiu9Qvf9qTo+X539+IxyA3YOleXMVTKtfOVHAnOIic=
|
||||
PSKey: Ld8FN/TNcmR21xdhMTCSeZBxrJ1z+FFvnQSnTwSxgUE=
|
||||
AdditionalCost: 10
|
||||
SkipLocalIP: false
|
||||
EndPoint: ""
|
||||
ExternalIP: ""
|
||||
- NodeID: 2
|
||||
Name: EgNet002
|
||||
PubKey: Ev271azq3FXmjhCWtwgVvqe9EN017mijjqMiB9LVQU8=
|
||||
PSKey: Wmhz6SvUNBGczD0iJjHn7gUGy15ahjQsr4lKJAqDE3A=
|
||||
AdditionalCost: 10
|
||||
SkipLocalIP: false
|
||||
EndPoint: ""
|
||||
ExternalIP: ""
|
||||
- NodeID: 100
|
||||
Name: EgNet100
|
||||
PubKey: nL3BdnKYt+DGl783iYe/7JETVTZU31RkHQu4x49Wk0s=
|
||||
PSKey: Ffe8veAmFX/L8lmNxbb2sofBx/K1CCY3u1osKh0sL2g=
|
||||
AdditionalCost: 10
|
||||
SkipLocalIP: false
|
||||
EndPoint: ""
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
Config output dir: /tmp/eg_gen_super
|
||||
Enable generated config overwrite: false
|
||||
Add NodeID to the interface name: true
|
||||
ConfigTemplate for super node: "" # "EgNet_super.yaml"
|
||||
ConfigTemplate for edge node: "" # "EgNet_edge001.yaml"
|
||||
Network name: EgNet
|
||||
|
|
|
@ -107,7 +107,7 @@ func GetExampleEdgeConf(templatePath string, getDemo bool) (mtypes.EdgeConfig, e
|
|||
NTPConfig: mtypes.NTPInfo{
|
||||
UseNTP: true,
|
||||
MaxServerUse: 8,
|
||||
SyncTimeInterval: 604800,
|
||||
SyncTimeInterval: 99999,
|
||||
NTPTimeout: 3,
|
||||
Servers: []string{
|
||||
"time.google.com",
|
||||
|
@ -136,7 +136,7 @@ func GetExampleEdgeConf(templatePath string, getDemo bool) (mtypes.EdgeConfig, e
|
|||
"tw.ntp.org.cn",
|
||||
"ntp.aliyun.com",
|
||||
"time1.cloud.tencent.com",
|
||||
"ntp.tuna.tsinghua.edu.cn ",
|
||||
"ntp.tuna.tsinghua.edu.cn",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -213,7 +213,7 @@ func GetExampleSuperConf(templatePath string, getDemo bool) (mtypes.SuperConfig,
|
|||
ListenPort_ManageAPI: "3000",
|
||||
API_Prefix: "/eg_api",
|
||||
LogLevel: mtypes.LoggerInfo{
|
||||
LogLevel: "normal",
|
||||
LogLevel: "error",
|
||||
LogTransit: false,
|
||||
LogControl: true,
|
||||
LogNormal: false,
|
||||
|
|
|
@ -7,7 +7,6 @@ package gencfg
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
@ -50,13 +49,11 @@ func GenNMCfg(NMCinfigPath string, enableP2P bool, printExample bool) (err error
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
files, err := os.ReadDir(NMCfg.ConfigOutputDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(files) > 0 {
|
||||
return fmt.Errorf(NMCfg.ConfigOutputDir + " not empty")
|
||||
}
|
||||
|
||||
var fileWriter bulkFileWriter
|
||||
fileWriter.files = make(map[string]fileWriterfile)
|
||||
fileWriter.ow = NMCfg.ConfigOutputDirOW
|
||||
|
||||
if NMCfg.EdgeConfigTemplate != "" {
|
||||
var econfig mtypes.EdgeConfig
|
||||
err = mtypes.ReadYaml(NMCfg.EdgeConfigTemplate, &econfig)
|
||||
|
@ -231,6 +228,8 @@ func GenNMCfg(NMCinfigPath string, enableP2P bool, printExample bool) (err error
|
|||
|
||||
var pskdb device.PSKDB
|
||||
for NodeID, Edge := range edge_infos {
|
||||
econfig.NodeName = NMCfg.NetworkName
|
||||
econfig.Interface.Name = NMCfg.NetworkName
|
||||
econfig.Interface.MacAddrPrefix = NMCfg.EdgeNode.MacPrefix
|
||||
econfig.Interface.IPv4CIDR = NMCfg.EdgeNode.IPv4Range
|
||||
econfig.Interface.IPv6CIDR = NMCfg.EdgeNode.IPv6Range
|
||||
|
@ -238,7 +237,10 @@ func GenNMCfg(NMCinfigPath string, enableP2P bool, printExample bool) (err error
|
|||
econfig.PrivKey = Edge.PrivKey
|
||||
econfig.NodeID = NodeID
|
||||
idstr := fmt.Sprintf("%0"+strconv.Itoa(len(MaxNodeID.ToString()))+"d", NodeID)
|
||||
econfig.NodeName = NMCfg.NetworkName + idstr
|
||||
if NMCfg.NetworkIFNameID {
|
||||
econfig.NodeName += idstr
|
||||
econfig.Interface.Name += idstr
|
||||
}
|
||||
PersistentKeepalive := uint32(30)
|
||||
econfig.ListenPort = 0
|
||||
if Edge.Endpoint != "" {
|
||||
|
@ -263,9 +265,9 @@ func GenNMCfg(NMCinfigPath string, enableP2P bool, printExample bool) (err error
|
|||
})
|
||||
}
|
||||
mtypesBytes, _ := yaml.Marshal(econfig)
|
||||
ioutil.WriteFile(filepath.Join(NMCfg.ConfigOutputDir, NMCfg.NetworkName+"_edge"+idstr+".yaml"), mtypesBytes, 0o600)
|
||||
fmt.Println(filepath.Join(NMCfg.ConfigOutputDir, NMCfg.NetworkName+"_edge"+idstr+".yaml"))
|
||||
fileWriter.WriteFile(filepath.Join(NMCfg.ConfigOutputDir, NMCfg.NetworkName+"_edge"+idstr+".yaml"), mtypesBytes, 0o600)
|
||||
}
|
||||
return nil
|
||||
err = fileWriter.Commit()
|
||||
return err
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ package gencfg
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -133,13 +132,9 @@ func GenSuperCfg(SMCinfigPath string, printExample bool) (err error) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
files, err := os.ReadDir(SMCfg.ConfigOutputDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(files) > 0 {
|
||||
return fmt.Errorf(SMCfg.ConfigOutputDir + " not empty")
|
||||
}
|
||||
var fileWriter bulkFileWriter
|
||||
fileWriter.files = make(map[string]fileWriterfile)
|
||||
fileWriter.ow = SMCfg.ConfigOutputDirOW
|
||||
|
||||
if SMCfg.SuperConfigTemplate != "" {
|
||||
var sconfig mtypes.SuperConfig
|
||||
|
@ -198,7 +193,7 @@ func GenSuperCfg(SMCinfigPath string, printExample bool) (err error) {
|
|||
|
||||
EndpointEdgeAPIUrl := SMCfg.Supernode.Endpoint_EdgeAPI
|
||||
|
||||
sconfig.NodeName = SMCfg.NetworkName + "SP"
|
||||
sconfig.NodeName = SMCfg.NetworkName + "SN"
|
||||
sconfig.API_Prefix = API_Prefix
|
||||
sconfig.ListenPort, _ = strconv.Atoi(ListenPort)
|
||||
sconfig.ListenPort_EdgeAPI = ListenPort
|
||||
|
@ -268,14 +263,18 @@ func GenSuperCfg(SMCinfigPath string, printExample bool) (err error) {
|
|||
peerceconf.DynamicRoute.SuperNode.EndpointV6 = EndpointV6 + ":" + ListenPort
|
||||
}
|
||||
peerceconf.DynamicRoute.SuperNode.EndpointEdgeAPIUrl = EndpointEdgeAPIUrl
|
||||
peerceconf.NodeName = SMCfg.NetworkName
|
||||
peerceconf.Interface.Name = SMCfg.NetworkName
|
||||
if SMCfg.NetworkIFNameID {
|
||||
peerceconf.NodeName += idstr
|
||||
peerceconf.Interface.Name += idstr
|
||||
}
|
||||
peerceconf.Interface.MacAddrPrefix = MacPrefix
|
||||
peerceconf.Interface.IPv4CIDR = IPv4Block
|
||||
peerceconf.Interface.IPv6CIDR = IPv6Block
|
||||
peerceconf.Interface.IPv6LLPrefix = IPv6LLBlock
|
||||
|
||||
peerceconf.NodeID = i
|
||||
peerceconf.NodeName = SMCfg.NetworkName + idstr
|
||||
peerceconf.Interface.Name = SMCfg.NetworkName + idstr
|
||||
peerceconf.DynamicRoute.SuperNode.PubKeyV4 = PubKeyS4.ToString()
|
||||
peerceconf.DynamicRoute.SuperNode.PubKeyV6 = PubKeyS6.ToString()
|
||||
peerceconf.DynamicRoute.SuperNode.PSKey = PSKeyE.ToString()
|
||||
|
@ -290,12 +289,11 @@ func GenSuperCfg(SMCinfigPath string, printExample bool) (err error) {
|
|||
SkipLocalIP: peerceconf.DynamicRoute.SuperNode.SkipLocalIP,
|
||||
})
|
||||
mtypesBytes, _ := yaml.Marshal(peerceconf)
|
||||
ioutil.WriteFile(filepath.Join(SMCfg.ConfigOutputDir, SMCfg.NetworkName+"_edge"+idstr+".yaml"), mtypesBytes, 0o600)
|
||||
fmt.Println(filepath.Join(SMCfg.ConfigOutputDir, SMCfg.NetworkName+"_edge"+idstr+".yaml"))
|
||||
fileWriter.WriteFile(filepath.Join(SMCfg.ConfigOutputDir, SMCfg.NetworkName+"_edge"+idstr+".yaml"), mtypesBytes, 0o600)
|
||||
}
|
||||
sconfig.Peers = SuperPeerInfo
|
||||
mtypesBytes, _ := yaml.Marshal(sconfig)
|
||||
ioutil.WriteFile(filepath.Join(SMCfg.ConfigOutputDir, SMCfg.NetworkName+"_super.yaml"), mtypesBytes, 0o600)
|
||||
fmt.Println(filepath.Join(SMCfg.ConfigOutputDir, SMCfg.NetworkName+"_super.yaml"))
|
||||
return nil
|
||||
fileWriter.WriteFile(filepath.Join(SMCfg.ConfigOutputDir, SMCfg.NetworkName+"_super.yaml"), mtypesBytes, 0o600)
|
||||
err = fileWriter.Commit()
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -6,14 +6,21 @@
|
|||
package gencfg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/KusakabeSi/EtherGuard-VPN/mtypes"
|
||||
)
|
||||
|
||||
type SMCfg struct {
|
||||
ConfigOutputDir string `yaml:"Config output dir"`
|
||||
ConfigOutputDirOW bool `yaml:"Enable generated config overwrite"`
|
||||
SuperConfigTemplate string `yaml:"ConfigTemplate for super node"`
|
||||
EdgeConfigTemplate string `yaml:"ConfigTemplate for edge node"`
|
||||
NetworkName string `yaml:"Network name"`
|
||||
NetworkIFNameID bool `yaml:"Add NodeID to the interface name"`
|
||||
Supernode struct {
|
||||
ListenPort int `yaml:"Listen port"`
|
||||
EdgeAPI_Prefix string `yaml:"EdgeAPI prefix"`
|
||||
|
@ -32,8 +39,10 @@ type SMCfg struct {
|
|||
|
||||
type NMCfg struct {
|
||||
ConfigOutputDir string `yaml:"Config output dir"`
|
||||
ConfigOutputDirOW bool `yaml:"Overwrite old configs"`
|
||||
EdgeConfigTemplate string `yaml:"ConfigTemplate for edge node"`
|
||||
NetworkName string `yaml:"Network name"`
|
||||
NetworkIFNameID bool `yaml:"Add NodeID to the interface name"`
|
||||
EdgeNode struct {
|
||||
MacPrefix string `yaml:"MacAddress prefix"`
|
||||
IPv4Range string `yaml:"IPv4 range"`
|
||||
|
@ -45,12 +54,53 @@ type NMCfg struct {
|
|||
}
|
||||
|
||||
type edge_raw_info struct {
|
||||
Endpoint string `yaml:"Endpoint(optional)"`
|
||||
Endpoint string `yaml:"Endpoint(optional)"`
|
||||
}
|
||||
|
||||
type edge_info struct {
|
||||
Endpoint string
|
||||
ConnectedEdge map[mtypes.Vertex]bool
|
||||
PrivKey string
|
||||
PubKey string
|
||||
Endpoint string
|
||||
ConnectedEdge map[mtypes.Vertex]bool
|
||||
PrivKey string
|
||||
PubKey string
|
||||
}
|
||||
|
||||
type bulkFileWriter struct {
|
||||
files map[string]fileWriterfile
|
||||
committed bool
|
||||
ow bool
|
||||
}
|
||||
|
||||
type fileWriterfile struct {
|
||||
content []byte
|
||||
perm fs.FileMode
|
||||
}
|
||||
|
||||
func (f *bulkFileWriter) WriteFile(path string, content []byte, perm fs.FileMode) {
|
||||
f.files[path] = fileWriterfile{
|
||||
content: content,
|
||||
perm: perm,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *bulkFileWriter) Commit() error {
|
||||
if f.committed {
|
||||
return fmt.Errorf("fileWriter has been commited")
|
||||
}
|
||||
f.committed = true
|
||||
for path, file := range f.files {
|
||||
if !f.ow {
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
// path/to/whatever does not exist
|
||||
} else {
|
||||
return fmt.Errorf("file %v exists, overwrite disabled", path)
|
||||
}
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(path, file.content, file.perm); err != nil {
|
||||
return err
|
||||
} else {
|
||||
fmt.Println(path)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
15
path/ntp.go
15
path/ntp.go
|
@ -98,11 +98,18 @@ func (g *IG) SyncTimeMultiple(count int) {
|
|||
for _, result := range results {
|
||||
totaltime += result
|
||||
}
|
||||
avgtime := totaltime / time.Duration(len(results))
|
||||
if g.loglevel.LogNTP {
|
||||
fmt.Println("NTP: Arvage offset: " + avgtime.String())
|
||||
if len(results) > 0 {
|
||||
avgtime := totaltime / time.Duration(len(results))
|
||||
if g.loglevel.LogNTP {
|
||||
fmt.Println("NTP: Arvage offset: " + avgtime.String())
|
||||
}
|
||||
g.ntp_offset = avgtime
|
||||
} else {
|
||||
if g.loglevel.LogNTP {
|
||||
fmt.Println("NTP: All server failed, skip sync")
|
||||
}
|
||||
}
|
||||
g.ntp_offset = avgtime
|
||||
|
||||
}
|
||||
|
||||
func (g *IG) SyncTime(url string, timeout time.Duration) {
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package main
|
||||
|
||||
var Version = "v0.3.5"
|
||||
var Version = "v0.3.5-f1"
|
||||
|
|
Loading…
Reference in New Issue