-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi: add deadline for first connection of new LNC conn #408
multi: add deadline for first connection of new LNC conn #408
Conversation
96dbc12
to
6ff563f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK LGTM.. amazing turn around time 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, looks pretty good and should be a great security improvement!
I left a suggestion for making the logic a bit easier to understand.
session_rpcserver.go
Outdated
|
||
err = s.db.RevokeSession(pubKey) | ||
if err != nil { | ||
log.Debugf("error revoking session: "+"%v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for not returning the error here? Or was this intended to be a return fmt.Errorf()
? Also, string concatenation artifacts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
erg yeah sorry 🙈 also, there should be a return
after this 🙈
config.go
Outdated
Loop: &loopDefaultConfig, | ||
PoolMode: defaultPoolMode, | ||
Pool: &poolDefaultConfig, | ||
FirstLNCConnDeadline: 10 * time.Minute, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extract into constant?
session_rpcserver.go
Outdated
} | ||
|
||
// Start the deadline timer. | ||
firstConnectionDeadline = time.NewTimer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could use time.AfterFunc()
here that closes the firstConnTimeout
. Then in the onNewStatus
callback we only stop that timer and we don't need a whole other goroutine (the debug comment could be moved into the onNewStatus
callback).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg yeeeesss!!! thank you :) updated!
6ff563f
to
603f4c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @guggero ! updated as per you suggestion 🚀 much neater the way you have suggested :)
session_rpcserver.go
Outdated
|
||
err = s.db.RevokeSession(pubKey) | ||
if err != nil { | ||
log.Debugf("error revoking session: "+"%v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
erg yeah sorry 🙈 also, there should be a return
after this 🙈
session_rpcserver.go
Outdated
} | ||
|
||
// Start the deadline timer. | ||
firstConnectionDeadline = time.NewTimer( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omg yeeeesss!!! thank you :) updated!
hmmm the itest keeps failing....i must have broken something on the latest update. looking into it |
603f4c7
to
3ea0e5a
Compare
In this commit, we add a deadline for the initial connection of an LNC connection. So with this, the user is forced to use their pairing phrase within a certain time frame. After this initial connection, future connections are made with the second handshake version meaning that the pairing phrase is rendered useless. By adding a time limit to the time in which a user can use their pairing phrase, we reduce the risk created by the users pairing phrase being leaked. The default time limit is set to 10 minutes but can be customsed with the new `firstlncconndeadline` flag.
3ea0e5a
to
d5c2604
Compare
hahaha found the issue 🙈 when I extracted the timeout into a variable, I used seconds instead of minutes 🙈 should be g2g now! I also added another commit that adds LNC client logging to the itests just to make it easier to debug these things in future |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK, LGTM 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK 🔥
The deadline works as advertised. Thanks for this great update.
In this PR, we add a deadline for the initial connection of an LNC
connection. So with this, the user is forced to use their pairing phrase
within a certain time frame. After this initial connection, future
connections are made with the second handshake version meaning that the
pairing phrase is rendered useless. By adding a time limit to the time
in which a user can use their pairing phrase, we reduce the risk created
by the users pairing phrase being leaked. The default time limit is set
to 10 minutes but can be customsed with the new
firstlncconndeadline
flag.
The first commit in this PR adds a new
CreatedAt
field toSession
so thatwe can have an absolute deadline.
Depends on lightninglabs/lightning-node-connect#53
Fixes #406