@2players/jet 中文文档教程

发布于 7年前 浏览 28 更新于 3年前

jet

SOCKS 的 HTTP 预代理。

标准 - JavaScript 风格指南m31271n 制造许可证 - GPL-3.0

“jet”这个名字的灵感来自 Cowboy Bepop 的 Jet Black。

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

格式说明:

VAR - DEFAULT VALUE

通过 3 个环境变量更改 SOCKS 代理设置:

  • JET_SOCKS_ADDR - 127.0.0.1
  • JET_SOCKS_PORT - 1080
  • JET_SOCKS_TYPE - 5

更改监听设置:

  • 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

我想你知道如何设置它。 这很简单。

For CLI

假设 Jet 在 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

将以上脚本添加到您的 shell 初始化文件中,例如 ~/.bashrc。 然后 source 它。

如果你使用的是其他shell,请自行设置以上环境变量。

Test The Effects

Test Jet is Working Or Not

shell> curl --proxy localhost:9527 https://www.google.com/

如果您获得正确的内容,则说明 jet 正在运行。

Test Your Shell Environment Is Set Properly Or Not

shell> curl https://www.google.com/

如果您获得正确的内容,则说明 jet 正在运行。 并且您的 shell 环境也已正确设置。

Advanced Features

Hot switching mode

默认情况下,jet 在 auto 模式下运行(一种根据 GeoIP 路由请求的模式)。 除了这种模式之外,还有另外两种模式:

  • direct - request directly, globally
  • tunnel - request through SOCKS proxy globally

当您在终端中运行 jet 时,您会看到:

[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 模式为例:

[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

如果你觉得jet 不适合你,可以使用以下命令将其移除:

# remove npm package
shell> npm uninstall -g jet

# remove related directory
shell> rm -rf ~/.config/jet

Reference

Similar Tools

jet

An HTTP pre-proxy for SOCKS.

Standard - JavaScript Style GuideMade by m31271nLicense - GPL-3.0

The name "jet" is inspired by Jet Black from Cowboy Bepop.

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

Reference

Similar Tools

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文