Fix: clear IP data when VPN is stopped

This commit is contained in:
Quentin McGaw (desktop)
2021-09-06 13:28:05 +00:00
parent f9cb71027c
commit 6b6caa435f
5 changed files with 9 additions and 7 deletions

View File

@@ -2,5 +2,5 @@ package publicip
import "github.com/qdm12/gluetun/internal/publicip/state"
type Getter = state.DataGetter
type GetSetter = state.DataGetSetter
type SettingsGetSetter = state.SettingsGetSetter

View File

@@ -20,7 +20,7 @@ type Looper interface {
loopstate.Getter
loopstate.Applier
SettingsGetSetter
Getter
GetSetter
}
type Loop struct {

View File

@@ -7,3 +7,7 @@ import (
func (l *Loop) GetData() (data models.IPInfoData) {
return l.state.GetData()
}
func (l *Loop) SetData(data models.IPInfoData) {
l.state.SetData(data)
}

View File

@@ -5,12 +5,8 @@ import (
)
type DataGetSetter interface {
DataGetter
SetData(data models.IPInfoData)
}
type DataGetter interface {
GetData() (data models.IPInfoData)
SetData(data models.IPInfoData)
}
func (s *State) GetData() (data models.IPInfoData) {

View File

@@ -6,6 +6,7 @@ import (
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/provider"
"github.com/qdm12/gluetun/internal/publicip/models"
)
type Runner interface {
@@ -83,6 +84,7 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
case <-l.stop:
l.userTrigger = true
l.logger.Info("stopping")
l.publicip.SetData(models.IPInfoData{}) // clear public IP address data
l.stopPortForwarding(ctx, settings.Provider.PortForwarding.Enabled, 0)
openvpnCancel()
<-waitError