npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

proxy-tcp

v0.2.1

Published

map local port to remote address directly or by http tunnel, bypass firewall, expose less service port to external network like internet

Downloads

3

Readme

安装、运行

安装

npm -g install proxy-tcp

运行:推荐使用 pm2

第一个参数为配置文件的路径,其中 .mapping 中设置端口映射关系。

by pm2

cd `npm -g root`/proxy-tcp
pm2 start . --name proxy-tcp --instances 2 -- "./example/pm2.json"

or

pm2 start `npm -g root`/proxy-tcp/example/pm2.json

edit pm2.json, change mapping part to meet your requirement.

direct from shell

proxy-tcp `npm -g root`/proxy-tcp/example/pm2.json

introduce

连接内网被屏蔽互联网访问的 tcp 服务,如 oracle

                               (directly)
                          / -------------------> \
client ------> proxy-tcp                          target(TCP server)
             (TCP server) \ --- http tunnel ---> /
                                    ^
               (http server that accept method:connect request)

客户端侧启动 port mapper,将连接到本地端口的连接接续到最终目标监听地址,包括两种方式:

  1. 直接通过 net.connect 接续到目标地址
  2. 间接通过 http.request({method:'connect',...} 通过 http tunnel 来连接目标地址

配置数据格式,形如

"mapping": {
  "127.0.0.1:6003": {
    "target": "qhtdb1:61521",
    "proxy": "localhost:80"
  },
  ":6001": {
    "target": "qhtdb1:61521"
  }
}
  1. key 为监听地址,格式如 ip:port,其中ip为监听多个地址中的那个地址,可以为空(默认监听所有地址)
  2. 配置项中有 proxy 的代表要通过 http tunnel 接续,target 地址必须是 http tunnel proxy 可以解析和访问的地址
  3. 配置项中没有 proxy 的代表要直接连接最终目标地址,target 地址必须是本 tcp proxy 可以解析和访问的地址

use cases

In DMZ

在 DMZ 区域,防火墙策略经常是内网地址到外网地址之间双向不能直接连接, 只能通过 DMZ 区的地址间接连接。

通过本代理,一方比如说外部要想访问内部服务,可以采用如下方案:

  1. 在 DMZ 区域启动本代理,配置本地端口(外网地址)到内网地址(host:port)的映射关系
  2. 原外网客户端配置访问代理外网地址和端口即可访问到内网服务

意义:

  1. 在DMZ 部署带有应用逻辑的软件不方便,因为受到网络访问限制,更新调试都受到影响
  2. 有了本代理,将DMZ两侧TCP连接接续,又不破坏企业的防火墙配置策略,避免和运维单位人员冲突
  3. 对于内外侧的网络应用程序,开发时完全不用考虑DMZ的影响,只当是可以直连,不必修改架构

hide internal TCP service behind firewall, access through exposed http service

很多时候,组织内部网络中的服务,特别是http服务,通过一个统一的对外 reverse http server 来访问, 外部互联网用户访问该组织的服务,都先访问该对外http服务,并由之反向代理到内部http服务。 但是,当一些内部服务,如 oracle service,他是基于 TCP 而不是 http 的, 那么默认情况下,oracle client 端软件只能直接发出TCP数据,无法使用 http tunnel。 因此,可以做以下三项工作来弥补:

  1. 网关http service支持 http tunnel,将 connect host:port 请求代理到内部目标TCP服务
  2. 客户端侧启动本代理,将本地端口映射为访问http tunnel再转到目标内部TCP服务地址
  3. 客户端从原来的直接指定目标地址,转变为指定本代理的监听地址