diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-03-20 18:39:08 +0100 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | 8efa7aa299b0488ae4439906482b75df0fb00cc7 (patch) | |
| tree | 2b740391aafc582b6bd2e5401a9ae35e3dae9981 | |
| parent | 1f599f1aab37343ff61852a8616c640310dfaee4 (diff) | |
Exports + Python + Server: Remove ShouldRenewButton
This is replace with expiry times
| -rw-r--r-- | client/server.go | 13 | ||||
| -rw-r--r-- | exports/exports.go | 13 | ||||
| -rw-r--r-- | internal/server/server.go | 30 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/loader.py | 1 | ||||
| -rw-r--r-- | wrappers/python/eduvpn_common/main.py | 8 |
5 files changed, 0 insertions, 65 deletions
diff --git a/client/server.go b/client/server.go index f31da2e..6c0b4d2 100644 --- a/client/server.go +++ b/client/server.go @@ -588,19 +588,6 @@ func (c *Client) RenewSession() (err error) { return c.ensureLogin(srv, srvtypes.Tokens{}) } -// ShouldRenewButton returns true if the renew button should be shown -// If there is no server then this returns false and logs with INFO if so -// In other cases it simply checks the expiry time and calculates according to: https://github.com/eduvpn/documentation/blob/b93854dcdd22050d5f23e401619e0165cb8bc591/API.md#session-expiry. -func (c *Client) ShouldRenewButton() bool { - srv, err := c.Servers.GetCurrentServer() - if err != nil { - log.Logger.Infof("no server to renew: %s\nstacktrace:\n%s", err.Error(), err.(*errors.Error).ErrorStack()) - return false - } - - return server.ShouldRenewButton(srv) -} - // ensureLogin logs the user back in if needed. // It runs the FSM transitions to ask for user input. func (c *Client) ensureLogin(srv server.Server, t srvtypes.Tokens) (err error) { diff --git a/exports/exports.go b/exports/exports.go index fe7581e..724185a 100644 --- a/exports/exports.go +++ b/exports/exports.go @@ -361,19 +361,6 @@ func RenewSession() *C.char { return getCError(renewSessionErr) } -//export ShouldRenewButton -func ShouldRenewButton() C.int { - state, stateErr := getVPNState() - if stateErr != nil { - return C.int(0) - } - shouldRenewBool := state.ShouldRenewButton() - if shouldRenewBool { - return C.int(1) - } - return C.int(0) -} - //export SetSupportWireguard func SetSupportWireguard(support C.int) *C.char { state, stateErr := getVPNState() diff --git a/internal/server/server.go b/internal/server/server.go index 775095c..4bd8766 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -48,36 +48,6 @@ type Endpoints struct { V string `json:"v"` } -// ShouldRenewButton returns whether or not the renew button should be shown for the server -// Implemented according to: https://github.com/eduvpn/documentation/blob/cdf4d054f7652d74e4192494e8bb0e21040e46ac/API.md#session-expiry -func ShouldRenewButton(srv Server) bool { - b, err := srv.Base() - if err != nil { - // FIXME: Log error here? - return false - } - - // Get current time - now := time.Now() - - // Session is expired - if !now.Before(b.EndTime) { - return true - } - - // 30 minutes have not passed - if !now.After(b.StartTime.Add(30 * time.Minute)) { - return false - } - - // Session will not expire today - if !now.Add(24 * time.Hour).After(b.EndTime) { - return false - } - - return true -} - func UpdateTokens(srv Server, t oauth.Token) { srv.OAuth().UpdateTokens(t) } diff --git a/wrappers/python/eduvpn_common/loader.py b/wrappers/python/eduvpn_common/loader.py index e57e81d..1cf7ab5 100644 --- a/wrappers/python/eduvpn_common/loader.py +++ b/wrappers/python/eduvpn_common/loader.py @@ -98,7 +98,6 @@ def initialize_functions(lib: CDLL) -> None: lib.SetSupportWireguard.argtypes, lib.SetSupportWireguard.restype = [ c_int, ], c_void_p - lib.ShouldRenewButton.argtypes, lib.ShouldRenewButton.restype = [], int lib.StartFailover.argtypes, lib.StartFailover.restype = [ c_char_p, c_int, diff --git a/wrappers/python/eduvpn_common/main.py b/wrappers/python/eduvpn_common/main.py index c654e41..947f8c1 100644 --- a/wrappers/python/eduvpn_common/main.py +++ b/wrappers/python/eduvpn_common/main.py @@ -264,14 +264,6 @@ class EduVPN(object): if support_err: forwardError(support_err) - def should_renew_button(self) -> bool: - """Whether or not the UI should show the renew button - - :return: Whether or not the return button should be shown - :rtype: bool - """ - return self.go_function(self.lib.ShouldRenewButton) - def start_failover( self, gateway: str, wg_mtu: int, readrxbytes: ReadRxBytes ) -> bool: |
