Skip to content

Commit d01e5da

Browse files
authored
Merge branch 'main' into claude/new-vertical-hosting-plan-d52px3
2 parents ea5b5d6 + b4e0ce0 commit d01e5da

7 files changed

Lines changed: 428 additions & 61 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fmt:
187187
fmt-check:
188188
@printf "$(GREEN)Checking code formatting (workspace members only)...$(NC)\n"
189189
@FAILED=0; \
190-
for pkg in aimdb-derive aimdb-data-contracts aimdb-core aimdb-client aimdb-embassy-adapter aimdb-tokio-adapter aimdb-wasm-adapter aimdb-sync aimdb-persistence aimdb-persistence-sqlite aimdb-mqtt-connector aimdb-knx-connector aimdb-ws-protocol aimdb-websocket-connector aimdb-uds-connector aimdb-serial-connector aimdb-tcp-connector aimdb-codegen aimdb-cli aimdb-mcp sync-api-demo tokio-mqtt-connector-demo embassy-mqtt-connector-demo embassy-knx-connector-demo embassy-serial-connector-demo embassy-bench-stm32h5 weather-mesh-common weather-hub weather-station-alpha weather-station-beta hello-mailbox hello-mailbox-async hello-single-latest-async aimdb-bench; do \
190+
for pkg in aimdb-derive aimdb-data-contracts aimdb-core aimdb-client aimdb-embassy-adapter aimdb-tokio-adapter aimdb-wasm-adapter aimdb-sync aimdb-persistence aimdb-persistence-sqlite aimdb-mqtt-connector aimdb-knx-connector aimdb-ws-protocol aimdb-websocket-connector aimdb-uds-connector aimdb-serial-connector aimdb-tcp-connector aimdb-codegen aimdb-cli aimdb-mcp sync-api-demo tokio-mqtt-connector-demo embassy-mqtt-connector-demo tokio-knx-connector-demo embassy-knx-connector-demo embassy-serial-connector-demo embassy-bench-stm32h5 weather-mesh-common weather-hub weather-station-alpha weather-station-beta hello-mailbox hello-mailbox-async hello-single-latest-async aimdb-bench; do \
191191
printf "$(YELLOW) → Checking $$pkg$(NC)\n"; \
192192
if ! cargo fmt -p $$pkg -- --check 2>&1; then \
193193
printf "$(RED)❌ Formatting check failed for $$pkg$(NC)\n"; \

aimdb-client/src/endpoint.rs

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,42 @@ fn require_nonempty(endpoint: &str, target: &str) -> ClientResult<()> {
170170
fn require_tcp_target(endpoint: &str, target: &str) -> ClientResult<()> {
171171
require_nonempty(endpoint, target)?;
172172

173-
let Some((host, port)) = target.rsplit_once(':') else {
174-
return Err(ClientError::unsupported_endpoint(
175-
endpoint,
176-
"missing TCP port",
177-
));
173+
let (host, port) = if let Some(rest) = target.strip_prefix('[') {
174+
let Some((host, after_host)) = rest.split_once(']') else {
175+
return Err(ClientError::unsupported_endpoint(
176+
endpoint,
177+
"missing closing bracket for IPv6 TCP host",
178+
));
179+
};
180+
let Some(port) = after_host.strip_prefix(':') else {
181+
return Err(ClientError::unsupported_endpoint(
182+
endpoint,
183+
"missing TCP port",
184+
));
185+
};
186+
(host, port)
187+
} else {
188+
if target.matches(':').count() > 1 {
189+
return Err(ClientError::unsupported_endpoint(
190+
endpoint,
191+
"IPv6 TCP hosts must be bracketed, e.g. tcp://[::1]:7001",
192+
));
193+
}
194+
let Some((host, port)) = target.split_once(':') else {
195+
return Err(ClientError::unsupported_endpoint(
196+
endpoint,
197+
"missing TCP port",
198+
));
199+
};
200+
if host.contains(['[', ']']) {
201+
return Err(ClientError::unsupported_endpoint(
202+
endpoint,
203+
"malformed TCP host",
204+
));
205+
}
206+
(host, port)
178207
};
208+
179209
if host.is_empty() {
180210
return Err(ClientError::unsupported_endpoint(
181211
endpoint,
@@ -268,6 +298,14 @@ mod tests {
268298
let p = parse_endpoint("tcp://localhost:7001").expect("parse");
269299
assert_eq!(p.scheme, Scheme::Tcp);
270300
assert_eq!(p.target, "localhost:7001");
301+
302+
let p = parse_endpoint("tcp://[::1]:7001").expect("parse");
303+
assert_eq!(p.scheme, Scheme::Tcp);
304+
assert_eq!(p.target, "[::1]:7001");
305+
306+
let p = parse_endpoint("tcp://[fe80::1]:7001").expect("parse");
307+
assert_eq!(p.scheme, Scheme::Tcp);
308+
assert_eq!(p.target, "[fe80::1]:7001");
271309
}
272310

273311
#[test]
@@ -277,6 +315,10 @@ mod tests {
277315
assert!(parse_endpoint("tcp://host").is_err());
278316
assert!(parse_endpoint("tcp://:1234").is_err());
279317
assert!(parse_endpoint("tcp://host:fast").is_err());
318+
assert!(parse_endpoint("tcp://fe80::1").is_err());
319+
assert!(parse_endpoint("tcp://[fe80::1]").is_err());
320+
assert!(parse_endpoint("tcp://[]:7001").is_err());
321+
assert!(parse_endpoint("tcp://[fe80::1:7001").is_err());
280322
// Empty + empty target.
281323
assert!(parse_endpoint("").is_err());
282324
assert!(parse_endpoint("unix://").is_err());

aimdb-tcp-connector/Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ std = [
1717
"aimdb-core/alloc",
1818
"aimdb-core/connector-session",
1919
"aimdb-core/remote",
20-
"thiserror",
2120
]
2221

2322
tokio-runtime = [
@@ -38,26 +37,22 @@ embassy-runtime = [
3837
"dep:embedded-io-async",
3938
]
4039

41-
tracing = ["dep:tracing", "aimdb-core/tracing"]
42-
defmt = ["dep:defmt", "aimdb-core/defmt"]
40+
tracing = ["aimdb-core/tracing"]
41+
defmt = ["aimdb-core/defmt"]
4342

4443
_test-tokio = ["tokio-runtime", "dep:aimdb-tokio-adapter"]
4544

4645
[dependencies]
4746
aimdb-core = { version = "1.1.0", path = "../aimdb-core", default-features = false }
4847

4948
tokio = { workspace = true, optional = true, features = ["net", "io-util"] }
50-
thiserror = { workspace = true, optional = true }
5149

5250
aimdb-embassy-adapter = { version = "0.6.0", path = "../aimdb-embassy-adapter", default-features = false, optional = true }
5351
embassy-net = { workspace = true, optional = true }
5452
embedded-io-async = { workspace = true, optional = true }
5553

5654
aimdb-tokio-adapter = { version = "0.6.0", path = "../aimdb-tokio-adapter", optional = true }
5755

58-
tracing = { workspace = true, optional = true }
59-
defmt = { workspace = true, optional = true }
60-
6156
[dev-dependencies]
6257
tokio = { version = "1", features = ["rt-multi-thread", "macros", "time", "io-util", "net"] }
6358
serde = { workspace = true }

0 commit comments

Comments
 (0)