summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exports/exports.go14
-rw-r--r--state.go15
-rw-r--r--wrappers/python/src/__init__.py4
-rw-r--r--wrappers/python/src/main.py3
4 files changed, 36 insertions, 0 deletions
diff --git a/exports/exports.go b/exports/exports.go
index 2eb3ab7..76c882a 100644
--- a/exports/exports.go
+++ b/exports/exports.go
@@ -270,6 +270,20 @@ func SetConnected(name *C.char) *C.char {
return C.CString(ErrorToString(setConnectedErr))
}
+//export ShouldRenewButton
+func ShouldRenewButton(name *C.char) C.int {
+ nameStr := C.GoString(name)
+ state, stateErr := GetVPNState(nameStr)
+ if stateErr != nil {
+ return C.int(0)
+ }
+ shouldRenewBool := state.ShouldRenewButton()
+ if shouldRenewBool {
+ return C.int(1)
+ }
+ return C.int(0)
+}
+
//export FreeString
func FreeString(addr *C.char) {
C.free(unsafe.Pointer(addr))
diff --git a/state.go b/state.go
index d559c88..be32c15 100644
--- a/state.go
+++ b/state.go
@@ -388,6 +388,21 @@ func (state *VPNState) SetDisconnected() error {
return nil
}
+func (state *VPNState) ShouldRenewButton() bool {
+ if !state.FSM.InState(fsm.CONNECTED) {
+ return false
+ }
+
+ currentServer, currentServerErr := state.Servers.GetCurrentServer()
+
+ if currentServerErr != nil {
+ state.Logger.Log(log.LOG_INFO, fmt.Sprintf("No server found to renew with err: %s", GetErrorTraceback(currentServerErr)))
+ return false
+ }
+
+ return server.ShouldRenewButton(currentServer)
+}
+
func GetErrorCause(err error) error {
return types.GetErrorCause(err)
}
diff --git a/wrappers/python/src/__init__.py b/wrappers/python/src/__init__.py
index 1e42bb5..2c933ca 100644
--- a/wrappers/python/src/__init__.py
+++ b/wrappers/python/src/__init__.py
@@ -86,6 +86,7 @@ lib.SetConnected.argtypes, lib.SetConnected.restype = [c_char_p], c_void_p
lib.SetConnecting.argtypes, lib.SetConnecting.restype = [c_char_p], c_void_p
lib.SetDisconnected.argtypes, lib.SetDisconnected.restype = [c_char_p], c_void_p
lib.SetSearchServer.argtypes, lib.SetSearchServer.restype = [c_char_p], c_void_p
+lib.ShouldRenewButton.argtypes, lib.ShouldRenewButton.restype = [], int
lib.FreeString.argtypes, lib.FreeString.restype = [c_void_p], None
@@ -143,8 +144,11 @@ def get_data_error(data_error: DataError) -> Tuple[str, str]:
error = get_error(data_error.error)
return data, error
+def get_bool(boolInt: c_int) -> bool:
+ return boolInt == 1
decode_map = {
+ c_int: get_bool,
c_void_p: get_error,
DataError: get_data_error,
}
diff --git a/wrappers/python/src/main.py b/wrappers/python/src/main.py
index 784e622..a2a0d14 100644
--- a/wrappers/python/src/main.py
+++ b/wrappers/python/src/main.py
@@ -206,3 +206,6 @@ class EduVPN(object):
if location_err:
raise Exception(location_err)
+
+ def should_renew_button(self) -> bool:
+ return self.go_function(lib.ShouldRenewButton)