Using Advanced Network Transports
Relevant source files
The following files were used as context for generating this wiki page:
GeekEZ Browser integrates the powerful Xray-core as its fundamental network engine, providing advanced and flexible networking capabilities. This system is designed for robust network isolation, security, and bypassing sophisticated detection mechanisms by supporting a wide array of modern proxy protocols and transport layers. The entire networking stack for each browser profile is routed through a dedicated Xray-core instance, ensuring complete separation from the host system and other profiles.
The core of this feature is the ability to configure not only a primary proxy for each profile but also an optional "Pre-Proxy" or "Proxy Chain." This allows for complex routing scenarios, such as hiding the user's real IP from the final proxy provider. The system is managed through a dedicated UI, supporting manual configuration, proxy subscriptions, and automated latency testing.
Sources: README.md:16-19, main.js:13-15, main.js:410-413
Core Architecture
The networking architecture of GeekEZ Browser is centered around Xray-core, which is automatically downloaded and configured during the application's initial setup.
Xray-core Integration
During the npm install process, a postinstall script executes setup.js. This script detects the user's operating system, architecture, and network location (checking for access to Google to decide between direct download and a mirror). It then downloads the appropriate version of the Xray-core binary into the resources/bin directory. This ensures that the browser has a compatible and ready-to-use network engine without manual user intervention.
Sources: package.json:10, setup.js:122-132
This diagram illustrates the Xray-core setup process.
Sources: setup.js:122-167
Supported Protocols and Transports
Thanks to Xray-core, the browser supports a comprehensive list of protocols and advanced transport mechanisms. This allows users to connect to a wide variety of proxy services and utilize modern obfuscation techniques.
| Type | Supported |
|---|---|
| Protocols | VMess, VLESS, Trojan, Shadowsocks (including 2022), Socks5, HTTP |
| Transports | REALITY, gRPC, mKCP, WebSocket, H2, XHTTP |
Sources: README.md:50-54
Network Configuration and Management
The browser provides a sophisticated UI for managing network configurations, accessible via the "Proxy Chain" button on the main toolbar.
Sources: index.html:813-816, renderer.js:1042-1046
Profile-Level Proxy
Each browser profile is configured with a primary proxy link (proxyStr). This link is the main endpoint that the browser profile will use to connect to the internet. When a profile is launched, this proxyStr is used to generate the primary outbound configuration for the dedicated Xray-core instance.
Sources: main.js:324-326, renderer.js:705-714
Proxy Chain (Pre-Proxy)
A key feature is the ability to establish a proxy chain, referred to as "Pre-Proxy." This creates a [Local] -> [Pre-Proxy] -> [Target Node] -> [Web] architecture. This is useful for hiding the user's real IP address from the main proxy server or for routing traffic through a specific network gateway before reaching the final destination.
The Pre-Proxy feature can be enabled globally or on a per-profile basis.
- Global Setting: A master switch on the main toolbar enables or disables the Pre-Proxy for all profiles that are set to "default."
- Per-Profile Override: Each profile can be configured to "Force ON," "Force OFF," or "Follow Global" for the Pre-Proxy setting.
This diagram shows the network flow with and without the Pre-Proxy enabled.
Sources: README.md:55-56, renderer.js:611-619, main.js:421-424
Proxy Manager UI
The "Proxy Chain" modal is the central hub for managing Pre-Proxy nodes. It features a tabbed interface to organize proxies from different sources (manual additions vs. subscriptions).
Key management features include:
- Manual Addition: Users can manually add proxy links with custom remarks.
- Subscription Support: Users can add subscription URLs to automatically import and update lists of proxy nodes.
- Latency Testing: Test the connection speed of individual nodes or an entire group.
- Mode Selection: Choose how the Pre-Proxy nodes are utilized.
This sequence diagram shows how a user adds a new Pre-Proxy node manually.
Sources: renderer.js:847-867, index.html:902-911
Pre-Proxy Modes
The Proxy Manager allows users to select one of three operational modes for the Pre-Proxy pool.
| Mode | Description |
|---|---|
| Single Node | Manually select one specific node from the list to be used as the Pre-Proxy. |
| Load Balance | Randomly selects a node from the enabled pool for each new profile launch. |
| Failover | Uses the first enabled node in the list. (The implementation suggests it always picks the first, with failover logic potentially handled by Xray itself, though not explicitly detailed). |
These modes are controlled in the UI and the selection is saved to the global settings. The launch-profile function in main.js then uses this mode to select the appropriate Pre-Proxy node when generating the Xray configuration.
Sources: renderer.js:885-894, renderer.js:1052-1058, main.js:425-434
Launch and Routing Flow
When a user clicks the "Launch" button for a profile, a sequence of events is triggered to configure and start the isolated network environment.
- IPC Call: The UI in
renderer.jscallswindow.electronAPI.launchProfile(id). - Configuration Generation: The
launch-profilehandler inmain.jsis invoked. It retrieves the profile data and global network settings. - Pre-Proxy Selection: It determines if a Pre-Proxy should be used based on global and profile-specific settings. If so, it selects a node based on the configured mode (Single, Balance, etc.).
- Xray Config: It calls
generateXrayConfigto create a JSON configuration file specific to this launch, incorporating the main proxy and any selected Pre-Proxy. - Process Spawning: It spawns a new Xray-core process using the generated config file.
- Browser Launch: It launches a new Puppeteer browser instance with arguments that force all its traffic through the local SOCKS5 port opened by the Xray process (
--proxy-server=socks5://127.0.0.1:${localPort}).
This sequence diagram details the entire launch process.
Sources: main.js:410-539, preload.js:7
Advanced Features
Subscription Management
The system supports importing proxy nodes from remote subscription URLs. This automates the process of keeping proxy lists up-to-date.
- Adding/Editing Subscriptions: A dedicated modal allows users to add or edit subscriptions, specifying a name, URL, and an automatic update interval (e.g., every 24 hours).
- Fetching and Parsing: When a subscription is updated (either manually or on schedule), the application sends a
fetch-urlrequest to the main process. The returned content, typically Base64 encoded, is decoded, and individual proxy links are parsed and added to the Pre-Proxy list under a group associated with that subscription.
Sources: renderer.js:930-972, renderer.js:990-1011
Latency Testing
To help users select the best-performing nodes, the browser includes a latency testing feature.
- Mechanism: The
test-proxy-latencyIPC handler inmain.jsimplements this. For a given proxy URL, it dynamically creates a temporary Xray configuration, starts an Xray instance, and then attempts to make an HTTP request tohttp://cp.cloudflare.com/generate_204through it using asocks-proxy-agent. - Measurement: The time taken for the request to complete is recorded as the latency. A failure or timeout results in an error status.
- UI Integration: The UI allows testing single nodes or an entire group. After testing, the latencies are displayed next to each node, color-coded for easy interpretation. For "Single Node" mode, the "Test Group & Auto-Switch" button will automatically select the node with the lowest latency.
Sources: main.js:121-140, renderer.js:1013-1021, renderer.js:1023-1040