- Feat: allow to change VPN type at runtime - Feat: allow to change interface name at runtime - Maint: Add cleanup method to cleanup VPN loop on a vpn shutdown - Change: allow VPN inputs ports only when tunnel is up
28 lines
630 B
Go
28 lines
630 B
Go
package vpn
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/qdm12/gluetun/internal/publicip/models"
|
|
)
|
|
|
|
func (l *Loop) cleanup(ctx context.Context, pfEnabled bool) {
|
|
for _, vpnPort := range l.vpnInputPorts {
|
|
err := l.fw.RemoveAllowedPort(ctx, vpnPort)
|
|
if err != nil {
|
|
l.logger.Error("cannot remove allowed input port from firewall: " + err.Error())
|
|
}
|
|
}
|
|
|
|
l.publicip.SetData(models.IPInfoData{}) // clear public IP address data
|
|
|
|
if pfEnabled {
|
|
const pfTimeout = 100 * time.Millisecond
|
|
err := l.stopPortForwarding(ctx, pfTimeout)
|
|
if err != nil {
|
|
l.logger.Error("cannot stop port forwarding: " + err.Error())
|
|
}
|
|
}
|
|
}
|