|
|
|
@ -105,6 +105,28 @@ func (m *Machine) WriteWireguardKeys(ring int) error {
|
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// RemoveWireguardKeys deletes wgN.key and wgN.pub from
|
|
|
|
|
// the machine's config directory
|
|
|
|
|
func (m *Machine) RemoveWireguardKeys(ring int) error { |
|
|
|
|
var err error |
|
|
|
|
|
|
|
|
|
err = m.RemoveFile("wg%v.pub", ring) |
|
|
|
|
switch { |
|
|
|
|
case os.IsNotExist(err): |
|
|
|
|
// ignore
|
|
|
|
|
case err != nil: |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err = m.RemoveFile("wg%v.key", ring) |
|
|
|
|
if os.IsNotExist(err) { |
|
|
|
|
// ignore
|
|
|
|
|
err = nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetWireguardConfig reads a wgN.conf file
|
|
|
|
|
func (m *Machine) GetWireguardConfig(ring int) (*wireguard.Config, error) { |
|
|
|
|
data, err := m.ReadFile("wg%v.conf", ring) |
|
|
|
|