Skip to content

url,src: simplify ipv6 logic by using uv_inet_pton#38842

Closed
XadillaX wants to merge 1 commit intonodejs:masterfrom
XadillaX:simplify-ipv6
Closed

url,src: simplify ipv6 logic by using uv_inet_pton#38842
XadillaX wants to merge 1 commit intonodejs:masterfrom
XadillaX:simplify-ipv6

Conversation

@XadillaX
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 29, 2021
@XadillaX XadillaX changed the title url,src: simplify ipv6 code by using inet_pton [WIP] url,src: simplify ipv6 code by using inet_pton May 29, 2021
@XadillaX XadillaX changed the title [WIP] url,src: simplify ipv6 code by using inet_pton url,src: simplify ipv6 code by using inet_pton May 30, 2021
@XadillaX XadillaX changed the title url,src: simplify ipv6 code by using inet_pton url,src: simplify ipv6 logic by using uv_inet_pton May 30, 2021
src/node_url.cc Outdated
std::string domain_or_opaque;
uint32_t ipv4;
uint16_t ipv6[8];
uint16_t ipv6[NS_IN6ADDRSZ / NS_INT16SZ];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think just 8 was a bit clearer here, to be honest…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don’t think glibc is the gold standard for code readability here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've changed it back.🐣

memset(buf, 0, sizeof(buf));
memcpy(*ipv6, input, sizeof(const char) * length);

int ret = uv_inet_pton(AF_INET6, *ipv6, buf);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In theory I'm +1 but we need to make sure that uv_inet_pton matches what the url standard expects here. The reason for the more complicated implementation is that it's what the standard spec specifically calls out.

Copy link
Copy Markdown
Contributor Author

@XadillaX XadillaX May 31, 2021

Choose a reason for hiding this comment

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

  1. It passes wpt;
  2. uv_inet_ntop and inet_ntop breaks URLHost::ToString() because it does not match web standard ...:x.x.x.x. So I do not modify logic by using *_ntop.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

XadillaX added a commit that referenced this pull request Jun 10, 2021
PR-URL: #38842
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@XadillaX
Copy link
Copy Markdown
Contributor Author

Landed in c109a6c

@XadillaX XadillaX closed this Jun 10, 2021
targos pushed a commit that referenced this pull request Jun 11, 2021
PR-URL: #38842
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@danielleadams danielleadams mentioned this pull request Jun 14, 2021
danielleadams pushed a commit that referenced this pull request Jun 17, 2021
PR-URL: #38842
Reviewed-By: Anna Henningsen <anna@addaleax.net>
richardlau pushed a commit that referenced this pull request Jul 19, 2021
PR-URL: #38842
Reviewed-By: Anna Henningsen <anna@addaleax.net>
richardlau pushed a commit that referenced this pull request Jul 20, 2021
PR-URL: #38842
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@richardlau richardlau mentioned this pull request Jul 20, 2021
foxxyz pushed a commit to foxxyz/node that referenced this pull request Oct 18, 2021
PR-URL: nodejs#38842
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants