-
Notifications
You must be signed in to change notification settings - Fork 25
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
Wrap channel in an asyncio.Transport to eliminate loop back connection #303
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
Breaking change
SniTunClientAioHttp.start()
no longer usesendpoint_connection_error_callback
. Passing it will now generate aDeprecationWarning
that 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 theaiohttp
RequestHandler
(server).hass_nabucasa
currently uses this callback in https://github.com/NabuCasa/hass-nabucasa/blob/cb14a2cad747b882f407e72e69f539f5d8fa20bb/hass_nabucasa/remote.py#L321Its unclear if
hass_nabucasa
can simply remove passing the callback or another change will be needed.Technically Breaking change
The signature of
snitun.client.connector.Connector
has changed since it no longer connects to loop-back. Instead ofend_host
andend_port
it takes thessl_context
andprotocol_factory
(anasyncio.Protocol
factory, in Home Assistant's case this is anaiohttp
RequestHandler
)This doesn't appear to be used externally as
SniTunClientAioHttp
is the entry point that creates these.Deployment considerations
The new
ChannelTransport
is hard coded to pass the remote IP as127.0.0.1
for compatibility with the currently deployed Cloud servers.https://github.com/NabuCasa/snitun/pull/303/files#diff-962be76744351102b2907e3aab99d5a45bc091cac1cc65f53f0fe2db9033c47fR30 should be adjusted to
True
whenchannel.ip_address
is 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
SelectorTransport
is replaced with the newChannelTransport
that 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_tls
Since
aiohttp
gets the ip address from the transport it can be set to whatever is desired in a future up. See Deployment considerationsTesting TODO: