├── .gitattributes
├── .gitignore
├── .travis.yml
├── Dockerfile.npc
├── Dockerfile.nps
├── LICENSE
├── Makefile
├── README.md
├── README_NPS.md
├── bridge
└── bridge.go
├── build.android.sh
├── build.assets.sh
├── build.sh
├── client
├── client.go
├── control.go
├── health.go
├── local.go
└── register.go
├── cmd
├── npc
│ ├── npc.go
│ └── sdk.go
└── nps
│ └── nps.go
├── conf
├── clients.json
├── global.json
├── hosts.json
├── multi_account.conf
├── npc.conf
├── nps.conf
├── server.key
├── server.pem
└── tasks.json
├── docs
├── .nojekyll
├── README.md
├── _coverpage.md
├── _navbar.md
├── _sidebar.md
├── api.md
├── bt.md
├── contribute.md
├── description.md
├── discuss.md
├── donate.md
├── example.md
├── faq.md
├── feature.md
├── index.html
├── install.md
├── introduction.md
├── logo.png
├── logo.svg
├── npc_extend.md
├── npc_sdk.md
├── nps_extend.md
├── nps_use.md
├── run.md
├── server_config.md
├── thanks.md
├── use.md
├── webapi.md
└── windows_client_service_configuration.png
├── go.mod
├── go.sum
├── gui
└── npc
│ ├── AndroidManifest.xml
│ └── npc.go
├── image
├── bt
│ ├── bt1.jpg
│ ├── bt2.png
│ ├── bt3.png
│ └── bt_1.png
├── cpu1.png
├── cpu2.png
├── donation_wx.png
├── donation_zfb.png
├── http.png
├── httpProxy.png
├── new
│ ├── cmd.png
│ ├── https.png
│ ├── payCode.png
│ └── tcp_limit.png
├── qps.png
├── sock5.png
├── speed.png
├── tcp.png
├── udp.png
├── web.png
├── web2.png
└── work_flow.svg
├── install.sh
├── lib
├── cache
│ └── lru.go
├── common
│ ├── const.go
│ ├── logs.go
│ ├── netpackager.go
│ ├── pool.go
│ ├── pprof.go
│ ├── run.go
│ └── util.go
├── config
│ ├── config.go
│ └── config_test.go
├── conn
│ ├── conn.go
│ ├── link.go
│ ├── listener.go
│ └── snappy.go
├── crypt
│ ├── clientHello.go
│ ├── crypt.go
│ └── tls.go
├── daemon
│ ├── daemon.go
│ └── reload.go
├── file
│ ├── db.go
│ ├── file.go
│ ├── obj.go
│ └── sort.go
├── goroutine
│ └── pool.go
├── install
│ └── install.go
├── nps_mux
│ ├── conn.go
│ ├── map.go
│ ├── mux.go
│ ├── mux_test.go
│ ├── netpackager.go
│ ├── pool.go
│ ├── queue.go
│ ├── rate.go
│ ├── sysGetsock_nowindows.go
│ ├── sysGetsock_windows.go
│ └── tc.go
├── pmux
│ ├── pconn.go
│ ├── plistener.go
│ ├── pmux.go
│ └── pmux_test.go
├── rate
│ ├── conn.go
│ └── rate.go
├── sheap
│ └── heap.go
└── version
│ └── version.go
├── port.png
├── server.png
├── server
├── connection
│ └── connection.go
├── proxy
│ ├── base.go
│ ├── http.go
│ ├── https.go
│ ├── p2p.go
│ ├── socks5.go
│ ├── tcp.go
│ ├── transport.go
│ ├── transport_windows.go
│ ├── udp.go
│ └── websocket.go
├── server.go
├── test
│ └── test.go
└── tool
│ └── utils.go
└── web
├── controllers
├── auth.go
├── base.go
├── client.go
├── global.go
├── index.go
└── login.go
├── routers
└── router.go
├── static
├── css
│ ├── bootstrap-table.min.css
│ ├── bootstrap.min.css
│ ├── datatables.css
│ ├── fontawesome.min.css
│ ├── regular.min.css
│ ├── solid.min.css
│ ├── style.css
│ └── toastr.min.css
├── img
│ └── flag
│ │ ├── en-US.png
│ │ └── zh-CN.png
├── js
│ ├── bootstrap-table-locale-all.min.js
│ ├── bootstrap-table.min.js
│ ├── bootstrap.min.js
│ ├── clipboard.min.js
│ ├── echarts.min.js
│ ├── fontawesome.min.js
│ ├── inspinia.js
│ ├── jquery-3.4.1.min.js
│ ├── language.js
│ ├── layui
│ │ └── laydate
│ │ │ ├── laydate.js
│ │ │ └── theme
│ │ │ └── default
│ │ │ ├── font
│ │ │ ├── iconfont.eot
│ │ │ ├── iconfont.svg
│ │ │ ├── iconfont.ttf
│ │ │ └── iconfont.woff
│ │ │ └── laydate.css
│ ├── popper.min.js
│ └── toastr.min.js
├── page
│ ├── error.html
│ └── languages.xml
└── webfonts
│ ├── fa-solid-900.eot
│ ├── fa-solid-900.svg
│ ├── fa-solid-900.ttf
│ ├── fa-solid-900.woff
│ └── fa-solid-900.woff2
└── views
├── client
├── add.html
├── edit.html
└── list.html
├── global
└── index.html
├── index
├── add.html
├── edit.html
├── hadd.html
├── hedit.html
├── help.html
├── hlist.html
├── index.html
└── list.html
├── login
├── index.html
└── register.html
└── public
├── error.html
└── layout.html
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.js linguist-language=golang
2 | *.css linguist-language=golang
3 | *.html linguist-language=golang
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | nps
3 | npc
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | go:
4 | - 1.14.x
5 | services:
6 | - docker
7 | script:
8 | - GOPROXY=direct go test -v ./cmd/nps/
9 | os:
10 | - linux
11 | before_deploy:
12 | - chmod +x ./build.sh && chmod +x ./build.android.sh && ./build.sh
13 |
14 | deploy:
15 | provider: releases
16 | edge: true
17 | token: ${GH_TOKEN}
18 | cleanup: false
19 | file:
20 | - freebsd_386_client.tar.gz
21 | - freebsd_386_server.tar.gz
22 | - freebsd_amd64_client.tar.gz
23 | - freebsd_amd64_server.tar.gz
24 | - freebsd_arm_client.tar.gz
25 | - freebsd_arm_server.tar.gz
26 | - linux_386_client.tar.gz
27 | - linux_386_server.tar.gz
28 | - linux_amd64_client.tar.gz
29 | - linux_amd64_server.tar.gz
30 | - linux_arm64_client.tar.gz
31 | - linux_arm64_server.tar.gz
32 | - linux_arm_v5_client.tar.gz
33 | - linux_arm_v6_client.tar.gz
34 | - linux_arm_v7_client.tar.gz
35 | - linux_arm_v5_server.tar.gz
36 | - linux_arm_v6_server.tar.gz
37 | - linux_arm_v7_server.tar.gz
38 | - linux_mips64le_client.tar.gz
39 | - linux_mips64le_server.tar.gz
40 | - linux_mips64_client.tar.gz
41 | - linux_mips64_server.tar.gz
42 | - linux_mipsle_client.tar.gz
43 | - linux_mipsle_server.tar.gz
44 | - linux_mips_client.tar.gz
45 | - linux_mips_server.tar.gz
46 | - darwin_amd64_client.tar.gz
47 | - darwin_amd64_server.tar.gz
48 | - windows_386_client.tar.gz
49 | - windows_386_server.tar.gz
50 | - windows_amd64_client.tar.gz
51 | - windows_amd64_server.tar.gz
52 | - npc_syno.spk
53 | - npc_sdk.tar.gz
54 | - android_client.apk
55 | on:
56 | tags: true
57 | all_branches: true
58 |
--------------------------------------------------------------------------------
/Dockerfile.npc:
--------------------------------------------------------------------------------
1 | FROM golang:1.15 as builder
2 | ARG GOPROXY=direct
3 | WORKDIR /go/src/ehang.io/nps
4 | COPY . .
5 | RUN go get -d -v ./...
6 | RUN CGO_ENABLED=0 go build -ldflags="-w -s -extldflags -static" ./cmd/npc/npc.go
7 |
8 | FROM scratch
9 | COPY --from=builder /go/src/ehang.io/nps/npc /
10 | VOLUME /conf
11 | ENTRYPOINT ["/npc"]
12 |
--------------------------------------------------------------------------------
/Dockerfile.nps:
--------------------------------------------------------------------------------
1 | FROM golang:1.15 as builder
2 | ARG GOPROXY=direct
3 | WORKDIR /go/src/ehang.io/nps
4 | COPY . .
5 | RUN go get -d -v ./...
6 | RUN CGO_ENABLED=0 go build -ldflags="-w -s -extldflags -static" ./cmd/nps/nps.go
7 |
8 | FROM scratch
9 | COPY --from=builder /go/src/ehang.io/nps/nps /
10 | COPY --from=builder /go/src/ehang.io/nps/web /web
11 | VOLUME /conf
12 | CMD ["/nps"]
13 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | SOURCE_FILES?=./...
2 | TEST_PATTERN?=.
3 | TEST_OPTIONS?=
4 |
5 | export PATH := ./bin:$(PATH)
6 | export GO111MODULE := on
7 | export GOPROXY := https://gocenter.io
8 |
9 | # Build a beta version of goreleaser
10 | build:
11 | go build cmd/nps/nps.go
12 | go build cmd/npc/npc.go
13 | .PHONY: build
14 |
15 | # Install all the build and lint dependencies
16 | setup:
17 | curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh
18 | curl -L https://git.io/misspell | sh
19 | go mod download
20 | .PHONY: setup
21 |
22 | # Run all the tests
23 | test:
24 | go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=2m
25 | .PHONY: test
26 |
27 | # Run all the tests and opens the coverage report
28 | cover: test
29 | go tool cover -html=coverage.txt
30 | .PHONY: cover
31 |
32 | # gofmt and goimports all go files
33 | fmt:
34 | find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
35 | .PHONY: fmt
36 |
37 | # Run all the linters
38 | lint:
39 | # TODO: fix tests and lll issues
40 | ./bin/golangci-lint run --tests=false --enable-all --disable=lll ./...
41 | ./bin/misspell -error **/*
42 | .PHONY: lint
43 |
44 | # Clean go.mod
45 | go-mod-tidy:
46 | @go mod tidy -v
47 | @git diff HEAD
48 | @git diff-index --quiet HEAD
49 | .PHONY: go-mod-tidy
50 |
51 | # Run all the tests and code checks
52 | ci: build test lint go-mod-tidy
53 | .PHONY: ci
54 |
55 | # Generate the static documentation
56 | static:
57 | @hugo --enableGitInfo --source www
58 | .PHONY: static
59 |
60 | # Show to-do items per file.
61 | todo:
62 | @grep \
63 | --exclude-dir=vendor \
64 | --exclude-dir=node_modules \
65 | --exclude=Makefile \
66 | --text \
67 | --color \
68 | -nRo -E ' TODO:.*|SkipNow' .
69 | .PHONY: todo
70 |
71 | clean:
72 | rm npc nps
73 | .PHONY: clean
74 |
75 | .DEFAULT_GOAL := build
76 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # nps-socks5服务一键搭建脚本
2 | - [x] 稳定版V3.1
3 |
4 | ## 介绍 ##
5 | 基于[nps](https://github.com/ehang-io/nps)的Shell脚本,集成socks5搭建,管理,启动,添加账号等基本操作。方便用户操作,并且支持快速构建socks5服务环境。
6 | - 默认管理页面ip:18080
7 | - 默认管理员账号密码:admin admin
8 | - 默认socks5账号信息: 端口5555、账号验证无(建议开启)
9 | - 支持多端口、多账号管理
10 | - 加密传输、数据压缩
11 | - 服务端、客户端分离安装、可实现国内中专代理,降低被和谐概率
12 | - 脚本只提供学习交流!
13 | 
14 | 
15 | ## 系统支持 ##
16 | * contest、ubuntu、debian、windows
17 | ## 功能 ##
18 | - 全自动无人值守安装,服务端部署只需一条命令
19 | - 全新的web端管理,支持多端口、多账号、多服务器、以及中转代理
20 | - 添加账户、删除用户、开启账户验证、关闭账户验证、一键修改端口
21 |
22 | ## 方法一:一键安装或更新到最新 ##
23 |
curl --progress-bar -O https://raw.githubusercontent.com/wyx176/nps-socks5/master/install.sh && chmod 777 install.sh && ./install.sh
24 | 或者
25 | wget --show-progress -q -N --no-check-certificate https://raw.githubusercontent.com/wyx176/nps-socks5/master/install.sh && chmod 777 install.sh && ./install.sh
26 | ## 方法二:linux、windows均支持,需要安装go语言环境进行编译
27 | [参考NPS文档](https://ehang-io.github.io/nps/#/install)go get -u github.com/wyx176/nps-socks5
30 | 2、编译服务端:进入到nps-socks5文件夹中执行命令
31 | go build cmd/nps/nps.go
32 | 3、编译客户端:进入到nps-socks5文件夹中执行命令
33 | go build cmd/npc/npc.go
34 | ## 相关文件路径、命令 ##
35 | - 1、后台管理的配置文件19 | 适用范围: 小程序开发、微信公众号开发、产品演示 20 |
21 |22 | 假设场景: 23 |
使用步骤:
28 |
33 | ./npc -server={{.ip}}:{{.p}} -vkey=客户端的密钥
34 |
注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,如需使用https请在配置文件中将https端口设置为443,和将对应的证书文件路径添加到配置文件中 38 |
39 |47 | 适用范围: ssh、远程桌面等tcp连接场景 48 |
49 |50 | 假设场景: 想通过访问公网服务器{{.ip}}的8001端口,连接内网机器10.1.50.101的22端口,实现ssh连接 51 |
52 |使用步骤:
53 |
56 | ./npc -server={{.ip}}:{{.p}} -vkey=客户端的密钥
57 |
58 | 注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动
63 |69 | 适用范围: 内网dns解析等udp连接场景 70 |
71 |72 | 假设场景: 内网有一台dns(10.1.50.102:53),在非内网环境下想使用该dns,公网服务器为{{.ip}} 73 |
74 |使用步骤:
75 |
78 | ./npc -server={{.ip}}:{{.p}} -vkey=客户端的密钥
79 |
80 | 注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动
85 |93 | 适用范围: 在外网环境下如同使用vpn一样访问内网设备或者资源 94 |
95 |96 | 假设场景: 想将公网服务器{{.ip}}的8003端口作为socks5代理,达到访问内网任意设备或者资源的效果 97 |
98 |使用步骤:
99 |
102 | ./npc -server={{.ip}}:{{.p}} -vkey=客户端的密钥
103 |
104 | 注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动
109 |115 | 适用范围: 在外网环境下访问内网站点 116 |
117 |118 | 假设场景: 想将公网服务器{{.ip}}的8004端口作为http代理,访问内网网站 119 |
120 |使用步骤:
121 |
124 | ./npc -server={{.ip}}:{{.p}} -vkey=客户端的密钥
125 |
126 | 注:上文中提到公网ip({{.ip}})为系统自动识别,如果是在测试环境中请自行对应,默认内网客户端已经启动
131 |单个客户端可以添加多条隧道或者域名解析
136 |