Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface struct {
PrivateKey string `ini:"PrivateKey,omitempty"`
Address string `ini:"Address,omitempty"`
ListenPort uint `ini:"ListenPort,omitempty"`
DNS []string `ini:"DNS,omitempty"`
Table int `ini:"Table,omitempty"` // Routing table.
MTU int `ini:"MTU,omitempty"`
PreUp string `ini:"PreUp,omitempty"`
PostUp string `ini:"PostUp,omitempty"`
PreDown string `ini:"PreDown,omitempty"`
PostDown string `ini:"PostDown,omitempty"`
}
type Peer ¶
type Peer struct {
Comment string `ini:"-"`
PublicKey string `ini:"PublicKey,omitempty"`
AllowedIPs string `ini:"AllowedIPs,omitempty"`
Endpoint string `ini:"Endpoint,omitempty"`
PersistentKeepalive int `ini:"PersistentKeepalive,omitempty"`
}
func (Peer) ReflectINIStruct ¶
Bit of a hack here. The ini library overwrites sections with the same name when ReflectFrom is used and there is no other way around it (that is known atleast). So, We need to be abit cleaver here and first create a new empty ini.File object and perform ReflectFrom there.
See: https://github.com/go-ini/ini/blob/842b9a946dd3bb45b95001ce6d9ae86f3b3ce921/struct_test.go#L663
type Peers ¶
type Peers []Peer
Slice of peers.
func (Peers) ReflectINIStruct ¶
There is a hidden (e.g. not so well documented) "marshal" interface called StructReflector (https://pkg.go.dev/github.com/go-ini/ini#StructReflector) So we can define one for "Peers" (slice of Peer) type here. This way. the ini library is able to marshal our struct.
NOTE: This should really exists in the library already as all this function do is call ReflectINIStruct() on it's elements.