down command removes wireguard-go sock to stop process
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
57bcab7996
commit
4c295e7654
@ -66,7 +66,7 @@ var downCmd = &cobra.Command{
|
|||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
c, log := loadConfig(args[0])
|
c, log := loadConfig(args[0])
|
||||||
if err := wgquick.Down(c, iface, log); err != nil {
|
if err := wgquick.Down(c, iface, userspace, log); err != nil {
|
||||||
logrus.WithError(err).Errorln("cannot down interface")
|
logrus.WithError(err).Errorln("cannot down interface")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -83,7 +83,7 @@ func Up(cfg *Config, iface string, uspace bool, logger logrus.FieldLogger) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Down destroys the wg interface. Mostly equivalent to `wg-quick down iface`.
|
// Down destroys the wg interface. Mostly equivalent to `wg-quick down iface`.
|
||||||
func Down(cfg *Config, iface string, logger logrus.FieldLogger) error {
|
func Down(cfg *Config, iface string, uspace bool, logger logrus.FieldLogger) error {
|
||||||
log := logger.WithField("iface", iface)
|
log := logger.WithField("iface", iface)
|
||||||
|
|
||||||
link, err := netlink.LinkByName(iface)
|
link, err := netlink.LinkByName(iface)
|
||||||
@ -119,6 +119,14 @@ func Down(cfg *Config, iface string, logger logrus.FieldLogger) error {
|
|||||||
log.Infoln("applied post-down command")
|
log.Infoln("applied post-down command")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If using userland wireguard, the sock file indicates a running wireguard-go process.
|
||||||
|
// By removing it, it will close itself.
|
||||||
|
if uspace {
|
||||||
|
if err := os.Remove(fmt.Sprintf("/var/run/wireguard/%s.sock", iface)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user