Repository navigation
feat: add --proxy and --source-addr to the client commands - #26
Merged
Merged
Conversation
Every command that connects to a device (detect, models, read*, poll*, capture) takes --proxy socks5://host:port (or socks5h://) and --source-addr <ip>, also as SUNSPECCTL_PROXY and SUNSPECCTL_SOURCE_ADDR. They build go-modbus v1.14.1's Config.Dialer: a SOCKS5 CONNECT client (RFC 1928, no authentication, ported from s7commctl) for the TCP transports, and a bound local address for TCP and UDP. --proxy with udp/rtuoverudp, either flag with rtu/ascii or on serve, and invalid values are usage errors before anything is sent. tcp+tls verifies the device certificate against the URL host through the proxy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--proxy socks5://host:port/socks5h://(SUNSPECCTL_PROXY) and--source-addr <ip>(SUNSPECCTL_SOURCE_ADDR) ondetect,models,read,read-model,read-point,poll*andcapture, modelled on feat: --proxy and --source-addr on every connecting command; go-s7comm v0.15.0 s7commctl#23.clientConfigsetsmodbus.Config.Dialerfrom the flags (dial.go). No other dial path exists: go-sunspec discovery runs on the Modbus client.internal/netdial: SOCKS5 CONNECT client (RFC 1928, no auth, no new dependency) ported from s7commctl, with--source-addrbinding TCP and UDP (udp,rtuoverudp).internal/socks5test: the scripted test proxy.--proxyfortcp,tcp+tls,rtuovertcp,asciiovertcp; usage error (exit 2) withudp/rtuoverudp(no UDP ASSOCIATE). Either flag withrtu:///ascii://, or onserve, is a usage error (serveignores the env vars). Invalid values are usage errors before anything is sent. A refusing proxy is exit 4, a silent one exit 5.tcp+tlshandshakes through the proxy, verified against the URL host.## v0.7.0.Tests
internal/netdialandinternal/socks5testat 100 %.dial_test.go: every client command through the proxy to a fake SunSpec device,socks5hname forwarding,tcp+tlsthrough the proxy plus a URL host the certificate doesn't hold failing, refusing/silent proxy exit codes,--source-addron TCP, UDP and RTU-over-UDP, env vars (flag beats env), every invalid value and transport mismatch as exit 2 on every client command with the proxy seeing nothing.make checkgreen (coverage 99.8 %),make e2egreen.🤖 Generated with Claude Code