Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Refactor dns handlers #1344

Merged
merged 8 commits into from
Aug 21, 2015
Merged

Refactor dns handlers #1344

merged 8 commits into from
Aug 21, 2015

Conversation

rade
Copy link
Member

@rade rade commented Aug 20, 2015

This takes the refactoring bit of #1334, evolves it (the handler construction is neater here), adds some extra refactors, and an optimisation.

Best reviewed by looking at the individual commits. And the first of those is best view in a good diff viewer, e.g. kompare in whitespace-ignore mode, where it will appear much smaller than here on github.

introduce a handler struct, which

- enables lifting of all the handle* closures to methods
- eliminates the passing around of defaultMaxResponseSize
- reduces the number of free-floating functions
no need to do a binary search if all the answers fit
}

// pick a random max size, truncate response to that, check it
maxSize := 512 + rand.Intn(response.Len()-512)
truncateResponse(response, maxSize)
maxSize := 512 + rand.Intn(2*512)

This comment was marked as abuse.

@tomwilkie
Copy link
Contributor

If you stick ?w=1 on the end of the url, github will also ignore whitespace.

@rade
Copy link
Member Author

rade commented Aug 20, 2015

If you stick ?w=1 on the end of the url, github will also ignore whitespace.

Thanks! Looks much better that way.

continue
}
response.Id = req.Id
if response.Len() > h.getMaxResponseSize(req) {

This comment was marked as abuse.

This comment was marked as abuse.

@tomwilkie
Copy link
Contributor

Whilst you're refactoring, you could move errorResponse onto handler and move it down the file to be with makeResponse.

@tomwilkie
Copy link
Contributor

Also should errorResponse use respond too?

@tomwilkie
Copy link
Contributor

Otherwise LGTM; I'll fix #1345 and #1332 on top of this now?

@tomwilkie tomwilkie assigned rade and unassigned tomwilkie Aug 21, 2015
@rade
Copy link
Member Author

rade commented Aug 21, 2015

I'll fix #1345 and #1332 on top of this now?

wait until it's merged.

and implement it in terms of existing functions, plus provide a
convenience method for sending the rather common NameError.
@rade rade assigned tomwilkie and unassigned rade Aug 21, 2015
@tomwilkie
Copy link
Contributor

That last change looks good to; merge away.

rade added a commit that referenced this pull request Aug 21, 2015
@rade rade merged commit 58dafbf into master Aug 21, 2015
@rade rade deleted the refactor-dns-handlers branch August 21, 2015 13:03
@rade rade modified the milestone: 1.1.0 Aug 29, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants