-
Notifications
You must be signed in to change notification settings - Fork 29
Wrap channel in an asyncio.Transport to eliminate loop back connection #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
Last step is to replace all the connector tests with ones that test connecting to the handler |
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #303 +/- ##
=======================================
Coverage ? 84.59%
=======================================
Files ? 20
Lines ? 1298
Branches ? 127
=======================================
Hits ? 1098
Misses ? 168
Partials ? 32 ☔ View full report in Codecov by Sentry. |
51befd7 to
8757bea
Compare
27a149b to
04993e8
Compare
31128d2 to
ad98e36
Compare
8bcc0f4 to
ba155d2
Compare
ba155d2 to
3cc126a
Compare
|
Whatever changed in pytest-asyncio broke the test, and it's not immediately apparent what's wrong |
Breaking change
SniTunClientAioHttp.start()no longer usesendpoint_connection_error_callback. Passing it will now generate aDeprecationWarningthat it will be removed in a future release. This failure condition is no longer possible since there is no longer a loop back connection, and the protocol is connected directly to theaiohttpRequestHandler(server).hass_nabucasacurrently uses this callback in https://github.com/NabuCasa/hass-nabucasa/blob/cb14a2cad747b882f407e72e69f539f5d8fa20bb/hass_nabucasa/remote.py#L321Its unclear if
hass_nabucasacan simply remove passing the callback or another change will be needed.Technically Breaking change
The signature of
snitun.client.connector.Connectorhas changed since it no longer connects to loop-back. Instead ofend_hostandend_portit takes thessl_contextandprotocol_factory(anasyncio.Protocolfactory, in Home Assistant's case this is anaiohttpRequestHandler)This doesn't appear to be used externally as
SniTunClientAioHttpis the entry point that creates these.Deployment considerations
The new
ChannelTransportis hard coded to pass the remote IP as127.0.0.1for compatibility with the currently deployed Cloud servers.https://github.com/NabuCasa/snitun/pull/303/files#diff-962be76744351102b2907e3aab99d5a45bc091cac1cc65f53f0fe2db9033c47fR30 should be adjusted to
Truewhenchannel.ip_addressis the actual remote IP address of the client that connected to the cloud server and not the IP Address of the internal forwarder.Proposed change
The concept is that the
SelectorTransportis replaced with the newChannelTransportthat is a wrapper around the channel so we don't need to connect back to localhost since we can create the request handler, connect up the transport and protocol andstart_tlsSince
aiohttpgets the ip address from the transport it can be set to whatever is desired in a future up. See Deployment considerationsTesting TODO: