summaryrefslogtreecommitdiff
path: root/internal/server/server.go
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-12 13:23:01 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-12-12 13:39:20 +0100
commit5084f1ed5df024918e61de81692b6066c421b8bd (patch)
tree0cbf6a4d8ab6c459428cc6fda536e9c49daf10d1 /internal/server/server.go
parenta8a2436975da7f8b8319da21f1ca3d93ebff08e8 (diff)
Server: Minor style changes
Diffstat (limited to 'internal/server/server.go')
-rw-r--r--internal/server/server.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index de0fa9a..1637d35 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -67,9 +67,9 @@ func ShouldRenewButton(srv Server) bool {
}
// Session duration is less than 24 hours but not 75% has passed
- d := b.EndTime.Sub(b.StartTime)
- pct := b.StartTime.Add((d / 4) * 3)
- if d < 24*time.Hour && !now.After(pct) {
+ delta := b.EndTime.Sub(b.StartTime)
+ passed := b.StartTime.Add((delta / 4) * 3)
+ if delta < 24*time.Hour && !now.After(passed) {
return false
}
@@ -110,14 +110,14 @@ func CurrentProfile(srv Server) (*Profile, error) {
if err != nil {
return nil, err
}
- pid := b.Profiles.Current
+ pID := b.Profiles.Current
for _, profile := range b.Profiles.Info.ProfileList {
- if profile.ID == pid {
+ if profile.ID == pID {
return &profile, nil
}
}
- return nil, errors.Errorf("profile not found: " + pid)
+ return nil, errors.Errorf("profile not found: " + pID)
}
func ValidProfiles(srv Server, wireguardSupport bool) (*ProfileInfo, error) {
@@ -139,14 +139,14 @@ func wireguardGetConfig(srv Server, preferTCP bool, openVPNSupport bool) (string
return "", "", err
}
- pid := b.Profiles.Current
+ pID := b.Profiles.Current
key, err := wireguard.GenerateKey()
if err != nil {
return "", "", err
}
pub := key.PublicKey().String()
- cfg, ct, exp, err := APIConnectWireguard(srv, pid, pub, preferTCP, openVPNSupport)
+ cfg, proto, exp, err := APIConnectWireguard(srv, pID, pub, preferTCP, openVPNSupport)
if err != nil {
return "", "", err
}
@@ -155,7 +155,7 @@ func wireguardGetConfig(srv Server, preferTCP bool, openVPNSupport bool) (string
b.StartTime = time.Now()
b.EndTime = exp
- if ct == "wireguard" {
+ if proto == "wireguard" {
// This needs the go code a way to identify a connection
// Use the uuid of the connection e.g. on Linux
// This needs the client code to call the go code
@@ -163,7 +163,7 @@ func wireguardGetConfig(srv Server, preferTCP bool, openVPNSupport bool) (string
cfg = wireguard.ConfigAddKey(cfg, key)
}
- return cfg, ct, nil
+ return cfg, proto, nil
}
func openVPNGetConfig(srv Server, preferTCP bool) (string, string, error) {
@@ -173,15 +173,14 @@ func openVPNGetConfig(srv Server, preferTCP bool) (string, string, error) {
}
pid := b.Profiles.Current
cfg, exp, err := APIConnectOpenVPN(srv, pid, preferTCP)
+ if err != nil {
+ return "", "", err
+ }
// Store start and end time
b.StartTime = time.Now()
b.EndTime = exp
- if err != nil {
- return "", "", err
- }
-
return cfg, "openvpn", nil
}