Compare commits

..

4 Commits

Author SHA1 Message Date
amery f293ead8d5 pkg/ceph: [WIP]
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 19:31:15 +00:00
amery 805bac01ec build-sys: use local asciigoat.org/ini
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 19:29:45 +00:00
amery 2dc4520e9f vscode: add special words to the dictionary
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 19:29:30 +00:00
amery 0d8e15c32e wireguard: switch from gcfg to asciigoat.org/ini/basic
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-09-04 19:28:19 +00:00
3 changed files with 33 additions and 11 deletions
+21 -4
View File
@@ -11,13 +11,17 @@ import (
"darvaza.org/core"
)
var sectionMap = map[string]func(*Config, *basic.Section) error{
"global": loadGlobalConfSection,
}
func loadConfSection(out *Config, src *basic.Section) error {
switch src.Key {
case "global":
return loadGlobalConfSection(out, src)
default:
h, ok := sectionMap[src.Key]
if !ok {
return core.Wrapf(fs.ErrInvalid, "unknown section %q", src.Key)
}
return h(out, src)
}
func loadGlobalConfSection(out *Config, src *basic.Section) error {
@@ -69,6 +73,19 @@ func loadGlobalConfField(cfg *GlobalConfig, field basic.Field) error {
entries, _ := parser.SplitCommaArray(field.Value)
cfg.Monitors = append(cfg.Monitors, entries...)
return nil
case "cluster_network":
if !core.IsZero(cfg.ClusterNetwork) {
err := core.Wrap(fs.ErrInvalid, "fields before the first section")
return err
}
err := cfg.ClusterNetwork.UnmarshalText([]byte(field.Value))
switch {
case err != nil:
return core.Wrap(err, field.Key)
default:
return nil
}
}
return nil
}
+1 -1
View File
@@ -78,7 +78,7 @@ type PeerConfig struct {
Name string
PublicKey PublicKey
Endpoint EndpointAddress
AllowedIPs []netip.Prefix `ini:",comma"`
AllowedIPs []netip.Prefix
}
// EndpointAddress is a host:port pair to reach the Peer
+11 -6
View File
@@ -8,15 +8,20 @@ import (
"darvaza.org/core"
)
type sectionHandler func(*Config, *basic.Section) error
var sectionMap = map[string]func(*Config, *basic.Section) error{
"Interface": loadInterfaceConfSection,
"Peer": loadPeerConfSection,
}
func loadConfSection(out *Config, src *basic.Section) error {
switch src.Key {
case "Interface":
return loadInterfaceConfSection(out, src)
case "Peer":
return loadPeerConfSection(out, src)
default:
h, ok := sectionMap[src.Key]
if !ok {
return core.Wrapf(fs.ErrInvalid, "unknown section %q", src.Key)
}
return h(out, src)
}
func loadInterfaceConfSection(out *Config, src *basic.Section) error {