Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b33dd35bdc | |||
| 6143dd8d3a | |||
| 106c58c5da |
@@ -8,20 +8,15 @@ import (
|
|||||||
"darvaza.org/core"
|
"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 {
|
func loadConfSection(out *Config, src *basic.Section) error {
|
||||||
h, ok := sectionMap[src.Key]
|
switch src.Key {
|
||||||
if !ok {
|
case "Interface":
|
||||||
|
return loadInterfaceConfSection(out, src)
|
||||||
|
case "Peer":
|
||||||
|
return loadPeerConfSection(out, src)
|
||||||
|
default:
|
||||||
return core.Wrapf(fs.ErrInvalid, "unknown section %q", src.Key)
|
return core.Wrapf(fs.ErrInvalid, "unknown section %q", src.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
return h(out, src)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadInterfaceConfSection(out *Config, src *basic.Section) error {
|
func loadInterfaceConfSection(out *Config, src *basic.Section) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user