-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
There's no built-in support for this in AsyncSSH today, and as you said aiosocks can't be used for this either. The aiohttp package does support HTTP CONNECT requests, but unfortunately it doesn't support the low level callback-based asyncio APIs for creating transports and protocols, which is what would be needed to work with AsyncSSH. The HTTP CONNECT mechanism is pretty simple, so it wouldn't be hard to built your own tunneling class which sent a "CONNECT host:port HTTP/1.1" followed by a blank line that and parsed the response looking for a response like "HTTP/1.1 200 OK" and skipped past additional header lines until you saw a blank line. After that, all output could be forwarded to AsyncSSH. In the meantime, a workaround would be to use the |
Beta Was this translation helpful? Give feedback.
-
Searching a bit, I was reminded that there was an attempt to implement an HTTP CONNECT tunnel a while back in #429. This still isn't something I'm looking to add directly in AsyncSSH right now, but you could experiment with that to see if it works for you. It would be more efficient than the To use this, you'd instantiate an HTTPConnectorTunnel with arguments of the proxy host & port and an optional SSL context if you wanted to run SSH inside of SSL and then pass this tunnel object to |
Beta Was this translation helpful? Give feedback.
-
Perfect, I've been looking at this initiative to be able to start from the code of these commits https://github.com/ronf/asyncssh/pull/429/files , so far everything works fine but I can't find this part: |
Beta Was this translation helpful? Give feedback.
-
I haven't tried the example code in #429 myself yet, but it looks like the call to protocol_factory() there should instead be a call to session_factory(), or you could rename the session_factory argument to create_connection() to be named protocol_factory. If I get a chance later tonight, I'll take a closer look. |
Beta Was this translation helpful? Give feedback.
The types you're using here (and those in #429) are not quite right. Those types made sense for when tunneling SSH over itself, but not when doing so with transports and protocols coming from asyncio.
One version of this which works for me in terms of typing is: