Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 805bac01ec | |||
| 2dc4520e9f | |||
| 0d8e15c32e |
@@ -8,15 +8,20 @@ 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 {
|
||||||
switch src.Key {
|
h, ok := sectionMap[src.Key]
|
||||||
case "Interface":
|
if !ok {
|
||||||
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