summaryrefslogtreecommitdiff
path: root/internal/server
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2024-03-14 17:19:25 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2024-03-14 17:19:25 +0100
commit948d986fda345ff41da699adf2dbf26144269145 (patch)
tree5800568b9a7af700e346067a3ad7c84096b9e519 /internal/server
parent35b11f421c23b18680b9468cca6cdec08430aba7 (diff)
Client + Server: Cache secure internet profile choice per location
Diffstat (limited to 'internal/server')
-rw-r--r--internal/server/server.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 1182f15..2148f85 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -178,7 +178,15 @@ func (s *Server) SetProfileID(id string) error {
if err != nil {
return err
}
+ oldP := cs.Profiles.Current
cs.Profiles.Current = id
+
+ if s.t == srvtypes.TypeSecureInternet {
+ if cs.LocationProfiles == nil {
+ cs.LocationProfiles = make(map[string]string)
+ }
+ cs.LocationProfiles[cs.CountryCode] = oldP
+ }
return nil
}
@@ -211,19 +219,6 @@ func (s *Server) ProfileID() (string, error) {
return cs.Profiles.Current, nil
}
-// SetLocation sets the secure internet location for the server
-func (s *Server) SetLocation(loc string) error {
- if s.t != srvtypes.TypeSecureInternet {
- return errors.New("changing secure internet location is only possible when the server is a secure location")
- }
- cs, err := s.cfgServer()
- if err != nil {
- return err
- }
- cs.CountryCode = loc
- return nil
-}
-
// SetCurrent sets the current server in the state file to this one
func (s *Server) SetCurrent() error {
if s.storage == nil {