chore(portforward): remove PIA dependency on storage package

This commit is contained in:
Quentin McGaw
2024-05-02 09:17:30 +00:00
parent e0a977cf83
commit 6dd27e53d4
18 changed files with 63 additions and 98 deletions

View File

@@ -9,12 +9,13 @@ import (
)
type Settings struct {
Enabled *bool
PortForwarder PortForwarder
Filepath string
Interface string // needed for PIA and ProtonVPN, tun0 for example
ServerName string // needed for PIA
ListeningPort uint16
Enabled *bool
PortForwarder PortForwarder
Filepath string
Interface string // needed for PIA and ProtonVPN, tun0 for example
ServerName string // needed for PIA
CanPortForward bool // needed for PIA
ListeningPort uint16
}
func (s Settings) Copy() (copied Settings) {
@@ -23,6 +24,7 @@ func (s Settings) Copy() (copied Settings) {
copied.Filepath = s.Filepath
copied.Interface = s.Interface
copied.ServerName = s.ServerName
copied.CanPortForward = s.CanPortForward
copied.ListeningPort = s.ListeningPort
return copied
}
@@ -33,6 +35,7 @@ func (s *Settings) OverrideWith(update Settings) {
s.Filepath = gosettings.OverrideWithComparable(s.Filepath, update.Filepath)
s.Interface = gosettings.OverrideWithComparable(s.Interface, update.Interface)
s.ServerName = gosettings.OverrideWithComparable(s.ServerName, update.ServerName)
s.CanPortForward = gosettings.OverrideWithComparable(s.CanPortForward, update.CanPortForward)
s.ListeningPort = gosettings.OverrideWithComparable(s.ListeningPort, update.ListeningPort)
}

View File

@@ -23,10 +23,11 @@ func (s *Service) Start(ctx context.Context) (runError <-chan error, err error)
}
obj := utils.PortForwardObjects{
Logger: s.logger,
Gateway: gateway,
Client: s.client,
ServerName: s.settings.ServerName,
Logger: s.logger,
Gateway: gateway,
Client: s.client,
ServerName: s.settings.ServerName,
CanPortForward: s.settings.CanPortForward,
}
port, err := s.settings.PortForwarder.PortForward(ctx, obj)
if err != nil {