You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "PDGGK (via GitHub)" <gi...@apache.org> on 2026/07/24 05:19:17 UTC
[PR] Support IPv6 node URLs and filter wildcard redirect endpoints [iotdb-client-nodejs]
PDGGK opened a new pull request, #21:
URL: https://github.com/apache/iotdb-client-nodejs/pull/21
## Problem
`parseNodeUrls` splits each node URL on `:` and requires exactly two parts, so an IPv6 endpoint such as `[::1]:6667` is rejected up front with "Invalid nodeUrl format", making the client unusable with IPv6 nodes. Separately, on the redirect path the client caches and connects to whatever endpoint the server advertises in a `redirectNode`, with no guard against a wildcard/listen-all address.
## Fix
Following the same approach as apache/iotdb#18162:
- Parsing: parse the bracketed `[ipv6]:port` form by stripping the brackets and reading the port after them, keeping IPv4 and hostname parsing unchanged. A bare (unbracketed) IPv6 address with a port is ambiguous and rejected; the `[ipv6]:port` form must be used.
- Wildcard filtering: after an insert, the server's `redirectNode` is stored in `Session.lastRedirectEndpoint` and later cached and connected to by the pool via `getAndClearLastRedirect()`. That consumption point now ignores a redirect whose address is a wildcard/listen-all address (`0.0.0.0`, `::`), which is not a connectable remote endpoint — the current endpoint is kept.
## Tests
- `parseNodeUrls`: bracketed IPv6 (`[::1]:6667`, `[2001:db8::1]:6668`) and malformed inputs (bare IPv6, unbalanced bracket, missing colon, empty port).
- `isWildcardAddress`, and `Session.getAndClearLastRedirect` on the real path: a wildcard redirect endpoint is dropped, a normal one passes through.
- Parsing is unit-tested including the `[::1]` loopback address; live IPv6-loopback connection tests (as in #18162) would need an IPv6-capable CI/test server, which I'm happy to add as a follow-up if the client CI supports it.
Existing tests and `tsc` pass. Follows the dev@ "[DISCUSS] Improve IPv6 endpoint support" thread; one focused PR per client as @HTHou suggested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support IPv6 node URLs and filter wildcard redirect endpoints [iotdb-client-nodejs]
Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou merged PR #21:
URL: https://github.com/apache/iotdb-client-nodejs/pull/21
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support IPv6 node URLs and filter wildcard redirect endpoints [iotdb-client-nodejs]
Posted by "PDGGK (via GitHub)" <gi...@apache.org>.
PDGGK commented on PR #21:
URL: https://github.com/apache/iotdb-client-nodejs/pull/21#issuecomment-5067412276
Thanks @HTHou — you're right, `parseInt` accepting a numeric prefix let malformed endpoints slip through. Fixed: the port must now be an all-digits string (validated with `/^\d+$/`) before conversion, so `[::1]:6667junk` and `[::1]:6667:9999` — and the hostname/IPv4 equivalents — are rejected with the `Invalid nodeUrl format` error rather than parsed as `6667`. Added regression tests covering all four cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support IPv6 node URLs and filter wildcard redirect endpoints [iotdb-client-nodejs]
Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou commented on code in PR #21:
URL: https://github.com/apache/iotdb-client-nodejs/pull/21#discussion_r3643445906
##########
src/utils/Config.ts:
##########
@@ -32,23 +32,48 @@ export interface InternalConfig extends Config {
sqlDialect?: string;
}
+/**
+ * Parse a single "host:port" node URL into an EndPoint. Accepts the bracketed
+ * IPv6 form "[::1]:6667" (consistent with the [ipv6]:port endpoint format
+ * standardized in apache/iotdb#18162) as well as IPv4 and hostname URLs. A bare
+ * (unbracketed) IPv6 address with a port is ambiguous and rejected; the
+ * "[ipv6]:port" form must be used.
+ */
+function parseNodeUrl(url: string): EndPoint {
+ const trimmed = url.trim();
+ let host: string;
+ let portStr: string;
+ if (trimmed.startsWith('[')) {
+ // Bracketed IPv6: [host]:port
+ const close = trimmed.indexOf(']');
+ if (close === -1 || trimmed[close + 1] !== ':') {
+ throw new Error(`Invalid nodeUrl format: ${url}. Expected format: "[ipv6]:port"`);
+ }
+ host = trimmed.slice(1, close).trim();
+ portStr = trimmed.slice(close + 2).trim();
+ } else {
+ const idx = trimmed.indexOf(':');
+ // A non-bracketed URL with more than one colon is a bare IPv6 address,
+ // which is ambiguous with a trailing port; it must be written as [ipv6]:port.
+ if (idx === -1 || idx !== trimmed.lastIndexOf(':')) {
+ throw new Error(`Invalid nodeUrl format: ${url}. Expected format: "host:port" (use "[ipv6]:port" for IPv6 addresses)`);
+ }
+ host = trimmed.slice(0, idx).trim();
+ portStr = trimmed.slice(idx + 1).trim();
+ }
+ const port = parseInt(portStr, 10);
Review Comment:
`parseInt` accepts a numeric prefix rather than requiring the entire string to be numeric, so malformed endpoints such as `[::1]:6667junk` and `[::1]:6667:9999` are silently accepted as port `6667`. Could we validate the complete port string (for example, with a digits-only check before conversion) and add regression tests for these cases? IoTDB's Java and Python endpoint parsers reject both inputs because their integer conversions require the full value to be valid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org