Fix: clear IP data when VPN is stopped
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -20,7 +20,7 @@ type Looper interface {
|
||||
loopstate.Getter
|
||||
loopstate.Applier
|
||||
SettingsGetSetter
|
||||
Getter
|
||||
GetSetter
|
||||
}
|
||||
|
||||
type Loop struct {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user