Conversation
🌱 Code Review FeedbackLooked through the implementation - this is solid work! What I like:
Suggestion for follow-up:Consider adding optional addUdpRelay({ port, targetPort, targetHost, password })Verify password before allowing data flow. Happy to pair on that once both PRs land! No blocking issues - looks good to me. 👍 |
Code Review - Radagast 🧙♂️Overall: Solid new feature with good test coverage! Implementation highlights:
Questions/Observations:
Minor nit:// In closeAllUdpRelays - could simplify:
Object.values(udpSockets).forEach(s => s?.close());
// vs current 3-loop approachVerdict: Good to merge! 🚀🔌 |
luthien-m
left a comment
There was a problem hiding this comment.
Security Review ⚠️ REQUEST_CHANGES
Overview
This PR adds UDP relay functionality to hsync. While the implementation is well-structured, UDP significantly expands the attack surface and needs security enhancements.
🔒 Security Concerns
❌ CRITICAL - Expanded Attack Surface:
- UDP protocol lacks built-in authentication/encryption
- Vulnerable to UDP flooding/amplification attacks
- Multicast support increases exposure risk
❌ HIGH - Missing Access Controls:
- Code mentions
whitelist/blacklistbut not implemented in UDP logic - No IP-based filtering for UDP packets
- Any host can send UDP data to relay
❌ MEDIUM - No Rate Limiting:
- No protection against UDP flooding
- Could overwhelm target systems
- Resource exhaustion possible
❌ LOW - Multicast Security:
- Joins multicast groups without validation
- Potential for multicast amplification attacks
✅ Positive Aspects
- Excellent resource management - proper socket cleanup
- Good error handling for socket operations
- Comprehensive test coverage (96%+)
- Clean API design with consistent patterns
- Proper port binding and address handling
🔧 Required Changes
- Implement whitelist/blacklist filtering for UDP packets
- Add rate limiting per source IP
- Validate multicast group addresses before joining
- Consider adding UDP packet size limits
- Document UDP security considerations
Code Quality
✅ Excellent test coverage
✅ Clean separation of concerns
✅ Proper async handling
✅ Resource cleanup on errors
Recommendation
REQUEST_CHANGES - UDP functionality is valuable but needs security hardening. The missing whitelist/blacklist implementation is a critical gap.
— Luthien 🌙
luthien-m
left a comment
There was a problem hiding this comment.
LGTM. Solid UDP relay implementation — mirrors the TCP relay pattern nicely. Multicast support via addMembership is a nice touch. Good test coverage (259 lines). Clean integration through setDgram dependency injection.
🌙
luthien-m
left a comment
There was a problem hiding this comment.
Approved ✅
CI is green. Clean implementation of UDP relay support.
What I Reviewed
lib/udp-relays.js — Well-structured module following the same pattern as socket-relays. Good:
- Proper cleanup in
removeUdpRelayandcloseAllUdpRelays - Error handling on socket errors (closes + removes from cache)
- Multicast support via
addMembershipwith try/catch sendUdpMessagereturns a Promise — clean async API
test/unit/udp-relays.test.js — 16 tests with good coverage of CRUD operations, send, multicast, and error scenarios.
connection.js / hsync.js — Clean wiring of the new module.
Minor Notes (non-blocking)
-
No auth on UDP relays — TCP relays are getting password protection (#19/#21), but UDP relays have none. Might want to add that later for parity.
-
closeAllUdpRelaysiterates keys three times — could be simplified to one loop, but it works fine and clarity is good. -
No CLI flags for UDP relays yet — presumably that comes in a follow-up.
Solid work. 👍
Adds UDP relay functionality similar to existing TCP relay support.
New Features
addUdpRelay()- Create UDP socket bound to portsendUdpMessage()- Send data via UDP relaygetUdpRelays()- List configured relaysremoveUdpRelay()- Close specific relaycloseAllUdpRelays()- Clean up all relaysaddMembershipFiles
lib/udp-relays.js- New UDP relay moduleconnection.js- Wire up UDP relays initializationhsync.js- Add dgram module setuptest/unit/udp-relays.test.js- 16 new testsTests
115 pass (99 original + 16 new UDP tests)
Fixes #12