From 0c6233ab691973859b6d636e6d9fdddd2a6acd5e Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Fri, 22 Jul 2022 17:16:13 +0200 Subject: State + Exports: Implement should show renew button boolean --- state.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'state.go') 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) } -- cgit v1.2.3