fix incorrect logic in rotateSequence
This was introduced in the previous few commits when adding support for multiple secrets in knockd. The logic to push and pop entries from the knockSequences slice needed to be adjusted to cound for the number of secrets that are loaded by hypd.
This commit is contained in:
parent
1e195c3768
commit
a52f3f0d43
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ hyp.secret
|
|||||||
hypd/hypd
|
hypd/hypd
|
||||||
hyp/hyp
|
hyp/hyp
|
||||||
hypd/hypdconfig.json
|
hypd/hypdconfig.json
|
||||||
|
hypd/secrets/
|
@ -175,7 +175,7 @@ func rotateSequence() {
|
|||||||
for {
|
for {
|
||||||
// Generate new knock sequences with time skew support
|
// Generate new knock sequences with time skew support
|
||||||
t := time.Now().Add(time.Second * -30)
|
t := time.Now().Add(time.Second * -30)
|
||||||
for i := len(knockSequences); i < 3; i++ {
|
for i := len(knockSequences) / len(sharedSecrets); i < 3; i++ {
|
||||||
for _, secret := range sharedSecrets {
|
for _, secret := range sharedSecrets {
|
||||||
portSequence, err := otphyp.GeneratePorts(secret, t.Add((time.Second * 30 * time.Duration(i))))
|
portSequence, err := otphyp.GeneratePorts(secret, t.Add((time.Second * 30 * time.Duration(i))))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -190,7 +190,7 @@ func rotateSequence() {
|
|||||||
time.Sleep(time.Until(time.Now().Truncate(time.Second * 30).Add(time.Second * 30)))
|
time.Sleep(time.Until(time.Now().Truncate(time.Second * 30).Add(time.Second * 30)))
|
||||||
|
|
||||||
// pop first value, next iteration pushes new value
|
// pop first value, next iteration pushes new value
|
||||||
knockSequences = knockSequences[1:]
|
knockSequences = knockSequences[len(sharedSecrets):]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user