mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-09-26 21:01:14 +08:00
move New* functions beneath the types they construct
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
@@ -42,16 +42,6 @@ type WireGuardInterface struct {
|
||||
Agent *Agent
|
||||
}
|
||||
|
||||
func (i *WireGuardInterface) Apply(a *Agent) {
|
||||
if i.Agent != nil {
|
||||
panic("can not assign interface to more than a single agent")
|
||||
}
|
||||
|
||||
i.Agent = a
|
||||
|
||||
a.WireGuardInterfaces = append(a.WireGuardInterfaces, i)
|
||||
}
|
||||
|
||||
func NewWireGuardInterface(name string) (*WireGuardInterface, error) {
|
||||
lp := wg.DefaultPort
|
||||
sk, err := crypto.GeneratePrivateKey()
|
||||
@@ -70,6 +60,16 @@ func NewWireGuardInterface(name string) (*WireGuardInterface, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (i *WireGuardInterface) Apply(a *Agent) {
|
||||
if i.Agent != nil {
|
||||
panic("can not assign interface to more than a single agent")
|
||||
}
|
||||
|
||||
i.Agent = a
|
||||
|
||||
a.WireGuardInterfaces = append(a.WireGuardInterfaces, i)
|
||||
}
|
||||
|
||||
func (i *WireGuardInterface) Create() error {
|
||||
if i.WriteConfigFile {
|
||||
if err := i.WriteConfig(); err != nil {
|
||||
|
Reference in New Issue
Block a user