-
Notifications
You must be signed in to change notification settings - Fork 300
feat(pyth-lazer-agent): add HTTP proxy support for WebSocket connections #3142
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?
feat(pyth-lazer-agent): add HTTP proxy support for WebSocket connections #3142
Conversation
Add proxy_url configuration option to support connecting through HTTP/HTTPS proxies. Implements manual HTTP CONNECT handshake with Basic authentication support and TLS upgrade for secure WebSocket connections. - Add proxy_url: Option<Url> to Config struct - Implement connect_through_proxy function with HTTP CONNECT method - Support Basic authentication via proxy URL credentials - Add tokio-native-tls dependency for TLS support - Update README with proxy configuration examples - Bump version from 0.6.1 to 0.7.0 Co-Authored-By: Mike Rolish <[email protected]>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
The latest updates on your projects. Learn more about Vercel for GitHub.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
- Use inline format args for cleaner string formatting - Replace slice indexing with safe .get() method - All clippy checks now pass Co-Authored-By: Mike Rolish <[email protected]>
Co-Authored-By: Mike Rolish <[email protected]>
stream | ||
.write_all(connect_request.as_bytes()) | ||
.await | ||
.context("Failed to send CONNECT request to proxy")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you note the proxy url here?
let n = stream | ||
.read(&mut response) | ||
.await | ||
.context("Failed to read CONNECT response from proxy")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you note the proxy url here?
); | ||
} | ||
|
||
tracing::info!("Successfully connected through proxy"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you note the proxy url here?
.context("Failed to complete WebSocket handshake")?; | ||
|
||
tracing::info!( | ||
"WebSocket connection established to relayer at {}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you note that this is through a proxy and the url?
…ging - Add proxy URL to error messages when sending/reading CONNECT requests - Add proxy URL to success log after proxy connection - Add proxy URL to final WebSocket success log for better traceability Co-Authored-By: Mike Rolish <[email protected]>
Summary
Added HTTP/HTTPS proxy support to pyth-lazer-agent to enable WebSocket connections through corporate proxies. The implementation includes:
http://user:pass@proxy:port
)Link to Devin run: https://app.devin.ai/sessions/9950b0a51eae4b2a87edd70073d61223
Requested by: Mike Rolish ([email protected]), @merolish
Rationale
A customer requires proxy support to use pyth-lazer-agent in their corporate environment. The
tokio-tungstenite
library doesn't support proxies directly, requiring manual implementation of the HTTP CONNECT protocol (RFC 2817).Changes
proxy_url: Option<Url>
configuration fieldconnect_through_proxy()
function with HTTP CONNECT handshaketokio-native-tls
dependency for TLS support through proxy tunnelHow has this been tested?
This implementation is untested with an actual proxy server. Key areas requiring careful review:
HTTP CONNECT implementation (lines 27-137 in
relayer_session.rs
):TLS upgrade logic (lines 109-125):
Security - Credential logging (lines 80-81, 88-90, 102, 131-135):
http://user:pass@proxy:port
) will be logged in plaintextBasic authentication (lines 67-73):
Missing validation: