feat(dns): added support for a custom lookup function; (#5339)#6
Open
MitchLewis930 wants to merge 1 commit intopr_026_beforefrom
Open
feat(dns): added support for a custom lookup function; (#5339)#6MitchLewis930 wants to merge 1 commit intopr_026_beforefrom
MitchLewis930 wants to merge 1 commit intopr_026_beforefrom
Conversation
Greptile OverviewGreptile SummaryThis PR adds support for custom DNS lookup functions in axios HTTP adapter, allowing users to override DNS resolution behavior for Node.js environments. Key Changes:
Critical Issue:
Testing:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Axios
participant httpAdapter
participant callbackify
participant lookup as Custom Lookup
participant NodeHTTP as Node.js HTTP/HTTPS
User->>Axios: axios.get(url, {lookup, family})
Axios->>httpAdapter: httpAdapter(config)
alt lookup is async function
httpAdapter->>callbackify: callbackify(lookup, reducer)
Note over callbackify: Converts async to callback
callbackify-->>httpAdapter: callback-based lookup
end
httpAdapter->>httpAdapter: Build request options
Note over httpAdapter: Add family & lookup to options
httpAdapter->>NodeHTTP: http.request(options)
alt DNS resolution needed
NodeHTTP->>lookup: lookup(hostname, options, callback)
alt Original async lookup
lookup->>lookup: Resolve DNS async
lookup-->>callbackify: Return [address, family] or string
callbackify->>callbackify: Apply reducer transform
callbackify-->>NodeHTTP: callback(null, address, family)
else Original callback lookup
lookup->>lookup: Resolve DNS
lookup-->>NodeHTTP: callback(null, address, family)
end
end
NodeHTTP->>NodeHTTP: Connect to resolved address
NodeHTTP-->>httpAdapter: Response
httpAdapter-->>Axios: Formatted response
Axios-->>User: Response data
|
| if (lookup && utils.isAsyncFn(lookup)) { | ||
| lookup = callbackify(lookup, (entry) => { | ||
| if(utils.isString(entry)) { | ||
| entry = [entry, entry.indexOf('.') < 0 ? 6 : 4] |
There was a problem hiding this comment.
IPv4/IPv6 detection logic is inverted. IPv4 addresses contain dots (like 127.0.0.1), while IPv6 addresses use colons (like ::1). This will assign family 6 to IPv4 addresses and family 4 to IPv6 addresses.
Suggested change
| entry = [entry, entry.indexOf('.') < 0 ? 6 : 4] | |
| entry = [entry, entry.indexOf('.') < 0 ? 4 : 6] |
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/adapters/http.js
Line: 160:160
Comment:
IPv4/IPv6 detection logic is inverted. IPv4 addresses contain dots (like `127.0.0.1`), while IPv6 addresses use colons (like `::1`). This will assign family 6 to IPv4 addresses and family 4 to IPv6 addresses.
```suggestion
entry = [entry, entry.indexOf('.') < 0 ? 4 : 6]
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| if (lookup && utils.isAsyncFn(lookup)) { | ||
| lookup = callbackify(lookup, (entry) => { | ||
| if(utils.isString(entry)) { |
There was a problem hiding this comment.
Missing space after if keyword for consistency with the codebase style
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/adapters/http.js
Line: 159:159
Comment:
Missing space after `if` keyword for consistency with the codebase style
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR_026