fix(publicip): rework run loop and fix restarts

- Clearing IP data on VPN disconnection clears file
- More efficient partial updates
- Fix loop exit
- Validate settings before updating
This commit is contained in:
Quentin McGaw
2023-09-24 14:55:51 +00:00
parent e64e5af4c3
commit f96448947f
21 changed files with 308 additions and 380 deletions

View File

@@ -3,8 +3,6 @@ package vpn
import (
"context"
"errors"
"github.com/qdm12/gluetun/internal/models"
)
func (l *Loop) cleanup(vpnProvider string) {
@@ -15,9 +13,12 @@ func (l *Loop) cleanup(vpnProvider string) {
}
}
l.publicip.SetData(models.PublicIP{}) // clear public IP address data
err := l.publicip.ClearData()
if err != nil {
l.logger.Error("clearing public IP data: " + err.Error())
}
err := l.stopPortForwarding(vpnProvider)
err = l.stopPortForwarding(vpnProvider)
if err != nil {
portForwardingAlreadyStopped := errors.Is(err, context.Canceled)
if !portForwardingAlreadyStopped {