Skip to content

Commit 239e039

Browse files
committed
merge status-Retry branch into master
1 parent f3cda5e commit 239e039

98 files changed

Lines changed: 1300 additions & 1055 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
DIST=dist/
22
APPNAME=halsecur
33

4-
GOLANGCILINT_VERSION=v2.5.0
5-
GOSEC_VERSION=v2.22.9
4+
GOLANGCILINT_VERSION=v2.7.2
5+
GOSEC_VERSION=v2.22.11
66
VULNCHECK_VERSION=latest
77

88
all: clean build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Usage:
2828
halsecur [command]
2929
3030
Available Commands:
31-
Logout
31+
logout
3232
completion Generate the autocompletion script for the specified shell
3333
discover Discover Hörmann BiSecur gateways on the local network
3434
get-name Queries the name of the Hörmann BiSecur gateway

cli/bisecur/consts.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ import "time"
44

55
const (
66
TokenExpirationTime = 30 * time.Minute
7-
retryCount = 3
87
)

cli/bisecur/getName.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package bisecur
22

33
import (
44
"bisecur/cli"
5+
"bisecur/cli/utils"
56
"bisecur/sdk"
67
)
78

@@ -20,7 +21,7 @@ func GetName(localMac, mac [6]byte, host string, port int, token uint32) (string
2021
}()
2122

2223
var name string
23-
err = Retry(func() error {
24+
err = utils.Retry(utils.RetryCount, func() error {
2425
var err2 error
2526
name, err2 = client.GetName()
2627
return err2

cli/bisecur/groups/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package groups
22

33
import (
44
"bisecur/cli"
5-
"bisecur/cli/bisecur"
5+
"bisecur/cli/utils"
66
"bisecur/sdk"
77
)
88

@@ -21,7 +21,7 @@ func ListGroups(localMac [6]byte, mac [6]byte, host string, port int, token uint
2121
}()
2222

2323
var groups *sdk.Groups
24-
err = bisecur.Retry(func() error {
24+
err = utils.Retry(utils.RetryCount, func() error {
2525
var err2 error
2626
groups, err2 = client.GetGroups()
2727
return err2

cli/bisecur/login.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,5 @@ func Login(localMac [6]byte, mac [6]byte, host string, port int, username string
2020
}()
2121

2222
err = client.Login(username, password)
23-
if err != nil {
24-
return 0, err
25-
}
26-
27-
return client.GetToken(), nil
23+
return client.GetToken(), err
2824
}

cli/bisecur/logout.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ package bisecur
33
import (
44
"bisecur/cli"
55
"bisecur/sdk"
6-
"fmt"
76
)
87

98
func Logout(localMac [6]byte, mac [6]byte, host string, port int, token uint32) error {
109
if token == 0 {
11-
return fmt.Errorf("invalid token value: 0x%X", token)
10+
return nil //fmt.Errorf("invalid token value: 0x%X. Logout request ignored", token)
1211
}
1312

1413
client := sdk.NewClient(cli.Log, localMac, mac, host, port, token)
@@ -24,7 +23,7 @@ func Logout(localMac [6]byte, mac [6]byte, host string, port int, token uint32)
2423
}
2524
}()
2625

27-
client.SetToken(token)
26+
client.SetToken(0) // clear token in local client instance
2827

2928
err = client.Logout()
3029
if err != nil {

cli/bisecur/password.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package bisecur
22

33
import (
44
"bisecur/cli"
5+
"bisecur/cli/utils"
56
"bisecur/sdk"
67
)
78

@@ -19,7 +20,7 @@ func UserPasswordChange(localMac [6]byte, mac [6]byte, host string, port int, to
1920
}
2021
}()
2122

22-
err = Retry(func() error {
23+
err = utils.Retry(utils.RetryCount, func() error {
2324
err2 := client.PasswordChange(userId, newPassword)
2425
return err2
2526
})

cli/bisecur/state.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package bisecur
22

33
import (
44
"bisecur/cli"
5+
"bisecur/cli/utils"
56
"bisecur/sdk"
67
"bisecur/sdk/payload"
78
)
@@ -21,14 +22,14 @@ func GetStatus(localMac [6]byte, mac [6]byte, host string, port int, devicePort
2122
}()
2223

2324
var status *payload.HmGetTransitionResponse
24-
err = Retry(func() error {
25+
err = utils.Retry(utils.RetryCount, func() error {
2526
var err2 error
2627
status, err2 = client.GetTransition(devicePort)
2728
return err2
2829
})
2930

3031
if err != nil {
31-
return nil, err
32+
return status, err
3233
}
3334

3435
return status, nil
@@ -48,7 +49,7 @@ func SetState(localMac [6]byte, mac [6]byte, host string, port int, devicePort b
4849
}
4950
}()
5051

51-
err = Retry(func() error {
52+
err = utils.Retry(utils.RetryCount, func() error {
5253
err2 := client.SetState(devicePort)
5354
return err2
5455
})

cli/bisecur/users/add.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package users
22

33
import (
44
"bisecur/cli"
5-
"bisecur/cli/bisecur"
5+
"bisecur/cli/utils"
66
"bisecur/sdk"
77
)
88

@@ -21,7 +21,7 @@ func UserAdd(localMac [6]byte, mac [6]byte, host string, port int, token uint32,
2121
}()
2222

2323
var userId byte
24-
err = bisecur.Retry(func() error {
24+
err = utils.Retry(utils.RetryCount, func() error {
2525
var err2 error
2626
userId, err2 = client.AddUser(userName, password)
2727
return err2

0 commit comments

Comments
 (0)