Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 805bac01ec | |||
| 2dc4520e9f | |||
| 0d8e15c32e |
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user