muzea/portfwd: A low performance port forwarding implementation
2019-10-03 20:53:37 Author: github.com(查看原文) 阅读量:228 收藏

Join GitHub today

GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up

Go Shell HTML JavaScript

一个低性能端口转发实现

使用

要求配置文件和程序放在一起,且名字必须是 config.json, 配置文件格式为

interface Config {
  proxy: {
    [localPort: string]: string;
  }
  APIPort: string;
}

其中 APIPort 为 api 监听的端口。

示例参见 示例配置

web 控制台

提供了一个简陋的web

api

  • 均要求数据为 application/json
  • 类型描述为typescript

ping

GET /ping

request

response

interface Resp {
  message: 'pong'
}

add

POST /proxy

request

interface Req {
  local: string // 比如 "10086"
  targrt: string //比如 "127.0.0.1:10010"
}

response

interface Resp {
  message: 'done'
}

update

PATCH /proxy/:localPort

request

interface Req {
  targrt: string //比如 "127.0.0.1:10010"
}

response

interface Resp {
  message: 'done'
}

delete

DELETE /proxy/:localPort

request

response

interface Resp {
  message: 'done'
}

proxy config

GET /proxy

request

response

type Resp = {
    [k in keyof ProxyPool]: string
}

proxy item

GET /proxy/:localPort

request

response

interface Resp {
  local: string
  target: string
}

文章来源: https://github.com/muzea/portfwd
如有侵权请联系:admin#unsafe.sh