mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-28 03:57:44 -06:00
M13.12: script socket port validation, resource-string trailing commas, parser and socket edge-case tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
88384197f9
commit
2f1788bdf6
@@ -144,7 +144,10 @@ mod imp {
|
||||
err(format!("cannot connect to {host}: {last}"))
|
||||
}
|
||||
"listen" => {
|
||||
let port = p.get("port").and_then(J::as_u64).unwrap_or(0) as u16;
|
||||
let port = match p.get("port").and_then(J::as_f64).unwrap_or(0.0) {
|
||||
v if v.fract() == 0.0 && (0.0..=65535.0).contains(&v) => v as u16,
|
||||
v => return err(format!("bad port {v} (0 to 65535)")),
|
||||
};
|
||||
match TcpListener::bind(("127.0.0.1", port)).and_then(|l| l.set_nonblocking(true).map(|_| l)) {
|
||||
Ok(l) => {
|
||||
let port = l.local_addr().map(|a| a.port()).unwrap_or(port);
|
||||
|
||||
Reference in New Issue
Block a user