Skip to content
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

Option to Reject requests by default #58

Merged
merged 3 commits into from
Apr 2, 2020

Conversation

hannahhoward
Copy link
Collaborator

Goals

Some graphsync operators may want to operate a graphsync node which is more locked down, rejecting all requests by default, and only authorizing requests through hooks.

Implementation

  • modify hook registrations to return an unregister function (so hooks can be removed)
  • setup default validation as simply a validating hook
  • add a configurable functional options pattern to graphsync constructor
  • add an option to reject all requests by default -- just unregisters default validation
  • fix a potential race condition with list of request hooks in ResponseManager

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except one case where you're not unlocking.

@@ -217,18 +230,17 @@ func (rm *ResponseManager) executeQuery(ctx context.Context,
peerResponseSender := rm.peerManager.SenderForPeer(p)
selectorSpec := request.Selector()
ha := &hookActions{false, request.ID(), peerResponseSender, nil}
rm.requestHooksLk.RLock()
for _, requestHook := range rm.requestHooks {
requestHook.hook(p, request, ha)
if ha.err != nil {
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not unlocking.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha good catch

@hannahhoward hannahhoward force-pushed the feat/reject-requests-by-default branch from f904432 to 0d82d29 Compare April 2, 2020 00:15
@hannahhoward hannahhoward changed the base branch from refactor/testify to master April 2, 2020 00:15
@hannahhoward hannahhoward merged commit 6760665 into master Apr 2, 2020
@aschmahmann aschmahmann mentioned this pull request Sep 22, 2020
72 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants