|
|
|
@ -61,6 +61,26 @@ func (m *Machine) GetWireguardKeys(ring int) (*wireguard.KeyPair, error) {
|
|
|
|
|
return kp, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (m *Machine) tryReadWireguardKeys(ring int) error { |
|
|
|
|
kp, err := m.GetWireguardKeys(ring) |
|
|
|
|
switch { |
|
|
|
|
case os.IsNotExist(err): |
|
|
|
|
// ignore
|
|
|
|
|
return nil |
|
|
|
|
case err != nil: |
|
|
|
|
// something went wrong
|
|
|
|
|
return err |
|
|
|
|
default: |
|
|
|
|
// import keys
|
|
|
|
|
ri := &RingInfo{ |
|
|
|
|
Ring: ring, |
|
|
|
|
Keys: kp, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return m.applyRingInfo(ring, ri) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetWireguardConfig reads a wgN.conf file
|
|
|
|
|
func (m *Machine) GetWireguardConfig(ring int) (*wireguard.Config, error) { |
|
|
|
|
data, err := m.ReadFile("wg%v.conf", ring) |
|
|
|
|