-
Notifications
You must be signed in to change notification settings - Fork 92
feat: Add SOCKS5 Proxy Support with Bootstrap Only Mode #1752
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
Open
scrense-hash
wants to merge
28
commits into
session-foundation:dev
Choose a base branch
from
scrense-hash:feature/socks5-proxy-for-pr
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
71e1612
feat: add SOCKS proxy support
scrense-hash 7d35afd
Fix proxy agent TLS caching
scrense-hash 27c0267
Fix TLS options flag in proxy agent
scrense-hash 9187eca
fix: show Save button when proxy is disabled to allow saving disabled…
scrense-hash e78cbfd
feat: add Bootstrap Only mode for SOCKS5 proxy
scrense-hash 896c90b
fix: add proxy-bootstrap-only to SettingsToggles type
scrense-hash e73d988
Merge upstream/dev into feature/socks5-proxy-for-pr
scrense-hash e3c90e6
chore: add generated locales.ts file
scrense-hash 1c2ce05
fix: add missing proxy localization tokens
scrense-hash 59c2559
fix: add missing proxy translations for Russian
scrense-hash 1a0984e
chore: update proxy settings and localization files
scrense-hash 9cd92f1
CI: fallback when yarn.lock is stale
scrense-hash bdf18be
Fix TS build errors (Flex padding, CrowdinLocale wrapper)
scrense-hash f7cdc43
Lint: remove console.error from proxy apply error path
scrense-hash fbb63e2
CI: make dedup step non-blocking on forks
scrense-hash a789110
ci: trigger clean build without cache
scrense-hash 6e14f4a
Proxy UI: ProxySettingsPage.tsx now loads settings synchronously, rem…
scrense-hash f0c0a85
Updated the dependencies: ran yarn install --ignore-scripts in the re…
scrense-hash dc8d5cb
Fix proxy build errors
scrense-hash 17e54a4
Fix updater lint error (remove unused session import)
scrense-hash 4272d13
Route auto-updater through proxy
scrense-hash ef19932
Fix proxy config for updater
scrense-hash 4e6432c
Docs: update SOCKS5 proxy PR description
scrense-hash 91b50c0
Docs: refresh SOCKS5 proxy PR description
scrense-hash d7a8b70
Refactor proxy settings + reduce log noise
scrense-hash 2e4ba72
Refactor proxy agent construction
scrense-hash 72600dc
Fix proxy agent typing and toggle handlers
scrense-hash 62b0eb7
fix: guard checkServerIdentity when building TLS cache key
scrense-hash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| # SOCKS5 Proxy Support Patch for Session Desktop | ||
|
|
||
| This patch adds full SOCKS5 proxy support to Session Desktop, allowing all application traffic (including onion requests) to be routed through a SOCKS proxy server. | ||
|
|
||
| ## Features | ||
|
|
||
| - ✅ SOCKS5 proxy support with authentication | ||
| - ✅ Proper timeout handling for proxy connections (30s vs 5s for direct) | ||
| - ✅ TLS/SSL certificate validation through proxy | ||
| - ✅ Certificate pinning preservation | ||
| - ✅ Agent caching for performance optimization | ||
| - ✅ Detailed error logging for debugging | ||
| - ✅ UI for proxy configuration in Settings | ||
| - ✅ Auto-updater disabled when proxy is enabled (prevents traffic leaks) | ||
|
|
||
| ## Changes Summary | ||
|
|
||
| ### Critical Changes (Required for functionality) | ||
|
|
||
| 1. **InsecureNodeFetch.ts** - Core proxy implementation | ||
| - `SocksProxyAgentWithTls` class for TLS options propagation | ||
| - Proxy agent priority over sslAgent | ||
| - TLS options extraction from original agent | ||
| - Agent caching with TLS configuration support | ||
|
|
||
| 2. **SeedNodeAPI.ts** - Timeout adjustment | ||
| - Increased timeout from 5s to 30s when proxy is enabled | ||
|
|
||
| 3. **onionPath.ts** - Timeout adjustment | ||
| - Increased timeout from 10s to 30s when proxy is enabled | ||
|
|
||
| ### Optional Improvements | ||
|
|
||
| 4. **Enhanced error logging** - Better debugging capabilities | ||
| 5. **Patch stamp tracking** - Version verification tool | ||
| 6. **Agent caching** - Performance optimization | ||
|
|
||
| ## Security Considerations | ||
|
|
||
| - TLS settings are extracted from the original `sslAgent` and preserved through the proxy | ||
| - Certificate pinning continues to work through SOCKS proxy | ||
| - `rejectUnauthorized` is only set to `false` if it was already disabled in the original agent | ||
| - No security regression for production seed nodes | ||
| - **Auto-updater is disabled when proxy is enabled** to prevent traffic leaks | ||
| - electron-updater uses native HTTP clients that bypass our proxy configuration | ||
| - Users must update manually when using proxy mode | ||
| - This ensures 100% traffic routing through proxy with no leaks | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Apply the patch: | ||
|
|
||
| ```bash | ||
| cd ~/Nextcloud/WORKSPACE/PROJECTS/session-desktop | ||
| git apply socks-proxy-support.patch | ||
| ``` | ||
|
|
||
| ### Build and install: | ||
|
|
||
| ```bash | ||
| # Build the application | ||
| PATH=~/.nvm/versions/node/v20.18.2/bin:/bin:/usr/bin:$PATH npx yarn build | ||
|
|
||
| # Build release package | ||
| PATH=~/.nvm/versions/node/v20.18.2/bin:/bin:/usr/bin:$PATH \ | ||
| NODE_OPTIONS='--max-old-space-size=8192' \ | ||
| npx yarn build-release | ||
|
|
||
| # Install the package | ||
| sudo dpkg -i release/session-desktop-linux-amd64-1.17.5.deb | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| 1. Open Session Desktop | ||
| 2. Go to **Settings** → **Proxy** | ||
| 3. Enable proxy and configure: | ||
| - **Proxy Server**: Your SOCKS5 proxy address (e.g., 192.168.1.254) | ||
| - **Port**: SOCKS5 proxy port (e.g., 1080) | ||
| - **Username** (optional): For authenticated proxies | ||
| - **Password** (optional): For authenticated proxies | ||
| 4. Click **Save** | ||
|
|
||
| **⚠️ Important Notes:** | ||
| - **Auto-updates are disabled** when proxy is enabled to prevent traffic leaks | ||
| - To update Session Desktop while using proxy, download new version manually from GitHub Releases | ||
| - All application traffic (messages, media, metadata) routes through proxy | ||
| - Disable proxy to re-enable auto-updates | ||
|
|
||
| ## Testing | ||
|
|
||
| To verify the proxy is working, check the logs: | ||
|
|
||
| ```bash | ||
| tail -f ~/.config/Session/logs/app.log | grep -i "proxy" | ||
| ``` | ||
|
|
||
| You should see: | ||
| - `Creating new SOCKS5 agent` on first connection | ||
| - `Using cached agent` on subsequent connections | ||
| - No `self signed certificate` errors | ||
| - Successful connections through proxy | ||
|
|
||
| ## Files Modified | ||
|
|
||
| - `ts/session/utils/InsecureNodeFetch.ts` - Core proxy logic | ||
| - `ts/session/apis/seed_node_api/SeedNodeAPI.ts` - Timeout adjustment | ||
| - `ts/session/onions/onionPath.ts` - Timeout adjustment | ||
| - `ts/components/dialog/user-settings/pages/ProxySettingsPage.tsx` - UI component | ||
| - `ts/data/settings-key.ts` - Proxy settings keys | ||
| - `ts/state/ducks/modalDialog.tsx` - Modal state | ||
| - `_locales/en/messages.json` - Localization strings | ||
| - `_locales/ru/messages.json` - Russian localization | ||
| - `package.json` - Dependencies (socks-proxy-agent, etc.) | ||
|
|
||
| ## Dependencies Added | ||
|
|
||
| - `socks-proxy-agent` - SOCKS5 proxy support | ||
| - `socks` - SOCKS protocol implementation | ||
| - `smart-buffer` - Buffer utilities for SOCKS | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Timeouts after 30 seconds | ||
| - Check if your SOCKS proxy is accessible | ||
| - Verify proxy address and port are correct | ||
| - Test proxy with curl: `curl --socks5 host:port https://example.com` | ||
|
|
||
| ### Self-signed certificate errors | ||
| - Ensure you're not using a local devnet with custom certificates | ||
| - Check if the issue occurs without proxy (to isolate the problem) | ||
|
|
||
| ### Connection works without proxy but fails with proxy | ||
| - Verify SOCKS5 proxy supports HTTPS/TLS connections | ||
| - Check proxy logs for connection attempts | ||
| - Enable debug logging in Session to see detailed errors | ||
|
|
||
| ## Credits | ||
|
|
||
| Patch created: 2025-12-23 | ||
| Session Desktop version: 1.17.5 | ||
| Node.js version: 20.18.2 | ||
|
|
||
| ## License | ||
|
|
||
| This patch maintains the same license as Session Desktop (GPL-3.0). |
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.