mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
Update seed list. New function LoadConfigOut to parse main config into custom structure.
Remove reuseport module file (not needed).
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
LogFile: Log.txt
|
||||
SeedList:
|
||||
- PublicKey: 026836d40a77779b7df5f1a08ca1ef8a83e15edcf0e4d8dc6ed5fc351cb60bd07c
|
||||
Address: ["[2a0b:6580::238:112]:112"]
|
||||
- PublicKey: 02b270f6fdac85e76df0d2f7374f33a620ede82542ff7cd62d6934b4c069921322
|
||||
- PublicKey: 02c490e4252bc7608fd55ddd9d7ca4a488ad152f3da6a6c2e9061f4c7e59f5b7f8 # 1.peernet.network
|
||||
Address: ["185.254.123.112:112","[2a0c:1880::112]:112"]
|
||||
- PublicKey: 02b270f6fdac85e76df0d2f7374f33a620ede82542ff7cd62d6934b4c069921322 # 2.peernet.network
|
||||
Address: ["167.99.45.141:112","[2a03:b0c0:2:d0::af0:e001]:112"]
|
||||
- PublicKey: 026836d40a77779b7df5f1a08ca1ef8a83e15edcf0e4d8dc6ed5fc351cb60bd07c # 3.peernet.network
|
||||
Address: ["[2a0b:6580::238:112]:112"]
|
||||
|
||||
29
Config.go
29
Config.go
@@ -42,8 +42,7 @@ var configFile string
|
||||
//go:embed "Config Default.yaml"
|
||||
var defaultConfig []byte
|
||||
|
||||
// LoadConfig reads the YAML configuration file
|
||||
// If an error is returned, the application shall exit.
|
||||
// LoadConfig reads the YAML configuration file. If an error is returned, the application shall exit.
|
||||
// Status: 0 = Unknown error checking config file, 1 = Error reading config file, 2 = Error parsing config file, 3 = Success
|
||||
func LoadConfig(filename string) (status int, err error) {
|
||||
var configData []byte
|
||||
@@ -68,6 +67,32 @@ func LoadConfig(filename string) (status int, err error) {
|
||||
return 3, nil
|
||||
}
|
||||
|
||||
// LoadConfigOut is similar to LoadConfig but unmarshals the config into a caller provided structure.
|
||||
func LoadConfigOut(Filename string, ConfigOut interface{}) (status int, err error) {
|
||||
var configData []byte
|
||||
configFile = Filename
|
||||
|
||||
// check if the file is non existent or empty
|
||||
stats, err := os.Stat(Filename)
|
||||
if err != nil && os.IsNotExist(err) || err == nil && stats.Size() == 0 {
|
||||
configData = defaultConfig
|
||||
} else if err != nil {
|
||||
return 0, err
|
||||
} else if configData, err = ioutil.ReadFile(Filename); err != nil {
|
||||
return 1, err
|
||||
}
|
||||
|
||||
// parse the config
|
||||
if err = yaml.Unmarshal(configData, &config); err != nil {
|
||||
return 2, err
|
||||
}
|
||||
if err = yaml.Unmarshal(configData, ConfigOut); err != nil {
|
||||
return 2, err
|
||||
}
|
||||
|
||||
return 3, nil
|
||||
}
|
||||
|
||||
func saveConfig() {
|
||||
data, err := yaml.Marshal(config)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
if status, err := core.LoadConfig("Settings.yaml"); err != nil {
|
||||
if status, err := core.LoadConfig("Config.yaml"); err != nil {
|
||||
fmt.Printf("Error loading config file: %s", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
7
go.mod
7
go.mod
@@ -3,11 +3,12 @@ module github.com/PeernetOfficial/core
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140043-ff9804bf6d25
|
||||
github.com/PeernetOfficial/core/reuseport v0.0.0-20210409204108-27ec231e1475
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140655-6a9d16717779
|
||||
github.com/btcsuite/btcd v0.21.0-beta.0.20210401013323-36a96f6a0025
|
||||
github.com/pkg/errors v0.9.1
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1
|
||||
golang.org/x/net v0.0.0-20210414194228-064579744ee0
|
||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
|
||||
lukechampine.com/blake3 v1.1.5
|
||||
)
|
||||
|
||||
14
go.sum
14
go.sum
@@ -1,7 +1,5 @@
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140043-ff9804bf6d25 h1:UawW82p89KZMttvQ+/neDOhmNuKwutFdcR+hNiSqCbc=
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140043-ff9804bf6d25/go.mod h1:sb2H21VIVTohCXVrDFo/Skl2tN8Yzba+MXSS6NgCYXw=
|
||||
github.com/PeernetOfficial/core/reuseport v0.0.0-20210409204108-27ec231e1475 h1:e3m7QUra7/QJhv1wTfYp5b1vdwAQuaYMN/oy2oa1faM=
|
||||
github.com/PeernetOfficial/core/reuseport v0.0.0-20210409204108-27ec231e1475/go.mod h1:j5lvi5jDpdDyuQrsUkCv4kkibVhPWj87sMol41sXIxc=
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140655-6a9d16717779 h1:P21VQkgh7qrNuXG/tiXC56BNv2cjGI6z/CYpfrCAVCk=
|
||||
github.com/PeernetOfficial/core/dht v0.0.0-20210410140655-6a9d16717779/go.mod h1:sb2H21VIVTohCXVrDFo/Skl2tN8Yzba+MXSS6NgCYXw=
|
||||
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
||||
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
|
||||
github.com/btcsuite/btcd v0.21.0-beta.0.20210401013323-36a96f6a0025 h1:aoVqvZk4mLyF3WZbqEVPq+vXnwL2wekZg4P4mjYJNLs=
|
||||
@@ -46,16 +44,16 @@ golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 h1:4qWs8cYYH6PoEFy4dfhDFgoMGkwAcETd+MmPdCPMzUc=
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
|
||||
golang.org/x/net v0.0.0-20210414194228-064579744ee0 h1:iqW3Mjl/6IP9cHJC/wdiIu3lyBDMUfDElRMyFlqbtiQ=
|
||||
golang.org/x/net v0.0.0-20210414194228-064579744ee0/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4=
|
||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
module github.com/PeernetOfficial/core/reuseport
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/pkg/errors v0.9.1
|
||||
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa
|
||||
)
|
||||
@@ -1,4 +0,0 @@
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa h1:ZYxPR6aca/uhfRJyaOAtflSHjJYiktO7QnJC5ut7iY4=
|
||||
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
Reference in New Issue
Block a user