Add more documentation for prompt handling
This commit is contained in:
@@ -51,6 +51,7 @@ func prompt(ctx context.Context, conn *network.Connection, pkt packet.Packet) {
|
|||||||
// Create notification.
|
// Create notification.
|
||||||
n := createPrompt(ctx, conn, pkt)
|
n := createPrompt(ctx, conn, pkt)
|
||||||
if n == nil {
|
if n == nil {
|
||||||
|
// createPrompt returns nil when no further action should be taken.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,23 +129,26 @@ func createPrompt(ctx context.Context, conn *network.Connection, pkt packet.Pack
|
|||||||
|
|
||||||
// If there already is a notification, just update the expiry.
|
// If there already is a notification, just update the expiry.
|
||||||
if n != nil {
|
if n != nil {
|
||||||
// Get notification state
|
// Get notification state and action.
|
||||||
n.Lock()
|
n.Lock()
|
||||||
state := n.State
|
state := n.State
|
||||||
|
action := n.SelectedActionID
|
||||||
n.Unlock()
|
n.Unlock()
|
||||||
|
|
||||||
// If the notification is still active, extend and return.
|
// If the notification is still active, extend and return.
|
||||||
|
// This can can happen because user input (prompts changing the endpoint
|
||||||
|
// lists) can happen any time - also between checking the endpoint lists
|
||||||
|
// and now.
|
||||||
if state == notifications.Active {
|
if state == notifications.Active {
|
||||||
n.Update(expires)
|
n.Update(expires)
|
||||||
log.Tracer(ctx).Debugf("filter: updated existing prompt notification")
|
log.Tracer(ctx).Debugf("filter: updated existing prompt notification")
|
||||||
return
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// The notification is not active anymore, let's check if there is an
|
// The notification is not active anymore, let's check if there is an
|
||||||
// action we can perform.
|
// action we can perform.
|
||||||
n.Lock()
|
// If there already is an action defined, we won't be fast enough to
|
||||||
action := n.SelectedActionID
|
// receive the action with n.Response(), so we take direct action here.
|
||||||
n.Unlock()
|
|
||||||
if action != "" {
|
if action != "" {
|
||||||
switch action {
|
switch action {
|
||||||
case allowDomainAll, allowDomainDistinct, allowIP, allowServingIP:
|
case allowDomainAll, allowDomainDistinct, allowIP, allowServingIP:
|
||||||
|
|||||||
Reference in New Issue
Block a user