jet
An HTTP pre-proxy for SOCKS.
The name "jet" is inspired by Jet Black from Cowboy Bepop.
Index
- Index
What does Jet do?
┌──────────────────────┐
│SOCKS v4/v4a/v5 Proxy │
┌────▶│ (ShadowSocks etc.) │──────┐
│ └──────────────────────┘ │
│ ▼
┌──────────────────┐ ┌───┐ ┌────────┐
│ User Application │────▶│Jet│───────────────────────────▶│Internet│
└──────────────────┘ └───┘ └────────┘
Features
- support SOCKS v4/v4a/v5
- support DNS cache
- route requests via GeoIP CN automatically
- hot switching between auto / direct / tunnel mode
Requirements
- Node.js >= 8.0.0
Installation
npm install -g @2players/jet
Setting Jet via environment variables
Format instruction:
VAR - DEFAULT VALUE
Change SOCKS Proxy setting via 3 environment variables:
-
JET_SOCKS_ADDR
-127.0.0.1
-
JET_SOCKS_PORT
-1080
-
JET_SOCKS_TYPE
-5
Change setting of listening:
-
JET_LISTEN_ADDR
-127.0.0.1
-
JET_LISTEN_PORT
-9527
Running Jet
# sync GeoIP info
shell> jet sync-geoip
# jet runs on 127.0.0.1:9527 by default
shell> jet run
# run jet on another port, like 9600
shell> JET_LISTEN_PORT=9600 jet run
# after a period of time, you maybe want to update GeoIP info,
# just sync it again
shell> jet sync-geoip
Configure All Your Application To Use Jet.
For GUI
I think you know how to set this. It's simple.
For CLI
Suppose that Jet is running at 127.0.0.1:9527
.
CHANNEL="http://127.0.0.1:9527"
NO_CHANNEL="localhost,127.0.0.1"
PROXY_ENV="http_proxy ftp_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY FTP_PROXY ALL_PROXY"
NO_PROXY_ENV="no_proxy NO_PROXY"
for envar in $PROXY_ENV; do
export $envar=$CHANNEL
done
for envar in $NO_PROXY_ENV; do
export $envar=$NO_CHANNEL
done
unset CHANNEL
unset NO_CHANNEL
unset PROXY_ENV
unset NO_PROXY_ENV
Add above script to your shell init file, like ~/.bashrc
. Then source
it.
If you are using other shell, set above environment variables by yourself.
Test The Effects
Test Jet is Working Or Not
shell> curl --proxy localhost:9527 https://www.google.com/
If you get right content, then jet is working.
Test Your Shell Environment Is Set Properly Or Not
shell> curl https://www.google.com/
If you get right content, then jet is working. And your shell environment is set properly, too.
Advanced Features
Hot switching mode
By defaut, jet is running in auto mode (a mode that routes request according GeoIP). In addition to this mode, there are two other mode:
- direct - request directly, globally
- tunnel - request through SOCKS proxy globally
When you run jet in terminal, you'll get this:
[INFO] Reading GeoIP info.
[INFO] DNS: 127.0.0.1
[INFO] Listening on 127.0.0.1:9527.
> TUNNEL 127.0.0.1 -> https://live.github.com:443/
> TUNNEL 127.0.0.1 -> https://live.github.com:443/
In order to hot switch current mode, just type supported mode directly. Take direct mode as an example:
[INFO] Reading GeoIP info.
[INFO] DNS: 127.0.0.1
[INFO] Listening on 127.0.0.1:9527.
> TUNNEL 127.0.0.1 -> https://live.github.com:443/
> TUNNEL 127.0.0.1 -> https://live.github.com:443/
direct <- the mode you type
[INFO] Switch to direct mode
> DIRECT 127.0.0.1 -> https://live.github.com:443/
Uninstallation
If you think jet is not suitable for you, remove it with following commands:
# remove npm package
shell> npm uninstall -g jet
# remove related directory
shell> rm -rf ~/.config/jet