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

fix: enclose ipv6 host with brackets on client request #1243

Merged
merged 6 commits into from
Nov 24, 2023

Conversation

aldy505
Copy link
Contributor

@aldy505 aldy505 commented Nov 20, 2023

Closes #1241

@trim21
Copy link
Contributor

trim21 commented Nov 20, 2023

can't we just check : like standard library does?

@aldy505
Copy link
Contributor Author

aldy505 commented Nov 21, 2023

can't we just check : like standard library does?

I don't think that makes that much of a difference.

See this sample code:

const net = require("net");

const input = ["localhost", "postgres.arpa", "172.16.0.1", "valid-domain.com", "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "::1234:5678", "::", "::1234:5678:91.123.4.56", "::11.22.33.44"];

for (const i of input) {
  console.log(`Input: ${i}; IsIP? ${net.isIP(i)};`);
}

// Output:
// Input: localhost; IsIP? 0;
// Input: postgres.arpa; IsIP? 0;
// Input: 172.16.0.1; IsIP? 4;
// Input: valid-domain.com; IsIP? 0;
// Input: 2001:0db8:85a3:0000:0000:8a2e:0370:7334; IsIP? 6;
// Input: ::1234:5678; IsIP? 6;
// Input: ::; IsIP? 6;
// Input: ::1234:5678:91.123.4.56; IsIP? 6;
// Input: ::11.22.33.44; IsIP? 6;

@trim21
Copy link
Contributor

trim21 commented Nov 22, 2023

can't we just check : like standard library does?

I don't think that makes that much of a difference.

See this sample code:

const net = require("net");

const input = ["localhost", "postgres.arpa", "172.16.0.1", "valid-domain.com", "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "::1234:5678", "::", "::1234:5678:91.123.4.56", "::11.22.33.44"];

for (const i of input) {
  console.log(`Input: ${i}; IsIP? ${net.isIP(i)};`);
}

// Output:
// Input: localhost; IsIP? 0;
// Input: postgres.arpa; IsIP? 0;
// Input: 172.16.0.1; IsIP? 4;
// Input: valid-domain.com; IsIP? 0;
// Input: 2001:0db8:85a3:0000:0000:8a2e:0370:7334; IsIP? 6;
// Input: ::1234:5678; IsIP? 6;
// Input: ::; IsIP? 6;
// Input: ::1234:5678:91.123.4.56; IsIP? 6;
// Input: ::11.22.33.44; IsIP? 6;

some downstream users are using this package in web environment, using node:net may need more polyfill.

@aldy505
Copy link
Contributor Author

aldy505 commented Nov 22, 2023

can't we just check : like standard library does?

I don't think that makes that much of a difference.

See this sample code:

const net = require("net");

const input = ["localhost", "postgres.arpa", "172.16.0.1", "valid-domain.com", "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "::1234:5678", "::", "::1234:5678:91.123.4.56", "::11.22.33.44"];

for (const i of input) {

console.log(Input: ${i}; IsIP? ${net.isIP(i)};);

}

// Output:

// Input: localhost; IsIP? 0;

// Input: postgres.arpa; IsIP? 0;

// Input: 172.16.0.1; IsIP? 4;

// Input: valid-domain.com; IsIP? 0;

// Input: 2001:0db8:85a3:0000:0000:8a2e:0370:7334; IsIP? 6;

// Input: ::1234:5678; IsIP? 6;

// Input: ::; IsIP? 6;

// Input: ::1234:5678:91.123.4.56; IsIP? 6;

// Input: ::11.22.33.44; IsIP? 6;

some downstream users are using this package in web environment, using node:net may need more polyfill.

I feel like I'm missing something here. What about all those node:http and node:https imports?

Another side note: We should make this clear on README for what environment we support.

@trim21
Copy link
Contributor

trim21 commented Nov 22, 2023

I feel like I'm missing something here. What about all those node:http and node:https imports?

there are some issues about this:

#1002
#1053

Another side note: We should make this clear on README for what environment we support.

plus 1 for this

@aldy505
Copy link
Contributor Author

aldy505 commented Nov 22, 2023

I feel like I'm missing something here. What about all those node:http and node:https imports?

there are some issues about this:

#1002 #1053

Another side note: We should make this clear on README for what environment we support.

plus 1 for this

Okay, will implement that tomorrow (or next weekend)

@aldy505 aldy505 marked this pull request as draft November 22, 2023 13:13
@aldy505 aldy505 changed the title fix: enclose ipv6 host with brackets on client request [DO NOT MERGE] fix: enclose ipv6 host with brackets on client request Nov 22, 2023
@aldy505 aldy505 changed the title [DO NOT MERGE] fix: enclose ipv6 host with brackets on client request fix: enclose ipv6 host with brackets on client request Nov 24, 2023
@aldy505 aldy505 marked this pull request as ready for review November 24, 2023 01:43
@aldy505
Copy link
Contributor Author

aldy505 commented Nov 24, 2023

Request for review @trim21 @prakashsvmx

@prakashsvmx
Copy link
Member

Adding some unit test would be beneficial @aldy505

@aldy505
Copy link
Contributor Author

aldy505 commented Nov 24, 2023

Adding some unit test would be beneficial @aldy505

Done

@trim21
Copy link
Contributor

trim21 commented Nov 24, 2023

Lgtm

@prakashsvmx
Copy link
Member

Thank you @aldy505 for the contribution.

@harshavardhana harshavardhana merged commit f5356ea into minio:master Nov 24, 2023
14 checks passed
@aldy505 aldy505 deleted the fix/host-header-ipv6-url branch November 25, 2023 01:00
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.

Host Header is set incorrectly for ipv6 addresses with custom port
4 participants