Skip to content

Commit

Permalink
Merge pull request #401 from ehang-io/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ffdfgdfg committed Feb 11, 2020
2 parents 5c37505 + a4247eb commit 7ede000
Show file tree
Hide file tree
Showing 28 changed files with 147 additions and 50 deletions.
21 changes: 8 additions & 13 deletions build.android.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#/bin/bash
#sudo apt-get install libgl1-mesa-dev xorg-dev
#go get github.com/ffdfgdfg/fyne-cross
#fyne-cross --targets=linux/amd64,windows/amd64,darwin/amd64 gui/npc/npc.go

cd /go
apt-get install libegl1-mesa-dev libgles2-mesa-dev libx11-dev -y
#go get -u fyne.io/fyne/cmd/fyne fyne.io/fyne
mkdir -p /go/src/fyne.io
cd src/fyne.io
git clone https://github.com/fyne-io/fyne.git
cd fyne
git checkout v1.2.0
go install -v ./cmd/fyne
go get -u fyne.io/fyne/cmd/fyne fyne.io/fyne
#mkdir -p /go/src/fyne.io
#cd src/fyne.io
#git clone https://github.com/fyne-io/fyne.git
#cd fyne
#git checkout v1.2.0
#go install -v ./cmd/fyne
#fyne package -os android fyne.io/fyne/cmd/hello
echo "fyne install success"
mkdir -p /go/src/ehang.io/nps
Expand All @@ -32,8 +29,6 @@ rm -rf vendor
#rm -rf ~/.cache/*
echo "vendor success"
cd gui/npc
#rm -rf /go/src/golang.org/x/mobile
#go get -u fyne.io/fyne/cmd/fyne@v1.2.0
#export ANDROID_NDK_HOME=/usr/local/android_sdk/ndk-bundle
fyne package -appID org.nps.client -os android -icon ../../docs/logo.png
mv npc.apk /app/android_client.apk
echo "android build success"
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bash/sh
export VERSION=0.26.1
export VERSION=0.26.2

sudo apt-get install gcc-mingw-w64-i686
env GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go build -ldflags "-s -w -extldflags -static -extldflags -static" -buildmode=c-shared -o npc_sdk.dll cmd/npc/sdk.go
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ func (s *TRPClient) handleChan(src net.Conn) {
func (s *TRPClient) handleUdp(serverConn net.Conn) {
// bind a local udp port
local, err := net.ListenUDP("udp", nil)
defer local.Close()
defer serverConn.Close()
if err != nil {
logs.Error("bind local udp port error ", err.Error())
return
}
defer local.Close()
go func() {
defer serverConn.Close()
b := common.BufPoolUdp.Get().([]byte)
Expand Down
2 changes: 2 additions & 0 deletions cmd/npc/npc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
localType = flag.String("local_type", "p2p", "p2p target")
logPath = flag.String("log_path", "", "npc log path")
debug = flag.Bool("debug", true, "npc debug")
pprofAddr = flag.String("pprof", "", "PProf debug addr (ip:port)")
)

const systemdScript = `[Unit]
Expand Down Expand Up @@ -171,6 +172,7 @@ func (p *npc) run() error {
logs.Warning("npc: panic serving %v: %v\n%s", err, string(buf))
}
}()
common.InitPProfFromArg(*pprofAddr)
//p2p or secret command
if *password != "" {
commonConfig := new(config.CommonConfig)
Expand Down
1 change: 1 addition & 0 deletions cmd/nps/nps.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func main() {
if err := beego.LoadAppConfig("ini", filepath.Join(common.GetRunPath(), "conf", "nps.conf")); err != nil {
log.Fatalln("load config file error", err.Error())
}
common.InitPProfFromFile()
if level = beego.AppConfig.String("log_level"); level == "" {
level = "7"
}
Expand Down
1 change: 1 addition & 0 deletions conf/npc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ web_username=user
web_password=1234
crypt=true
compress=true
#pprof_addr=0.0.0.0:9999

[health_check_test1]
health_check_timeout=1
Expand Down
4 changes: 4 additions & 0 deletions conf/nps.conf
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ http_cache_length=100

#get origin ip
http_add_origin_header=false

#pprof debug options
#pprof_ip=0.0.0.0
#pprof_port=9999
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# nps
![](https://img.shields.io/github/stars/cnlh/nps.svg) ![](https://img.shields.io/github/forks/cnlh/nps.svg)
[![Gitter](https://badges.gitter.im/cnlh-nps/community.svg)](https://gitter.im/cnlh-nps/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Build Status](https://travis-ci.org/cnlh/nps.svg?branch=master)](https://travis-ci.org/cnlh/nps)
[![Build Status](https://travis-ci.org/ehang-io/nps.svg?branch=master)](https://travis-ci.org/cnlh/nps)

nps是一款轻量级、高性能、功能强大的**内网穿透**代理服务器。目前支持**tcp、udp流量转发**,可支持任何**tcp、udp**上层协议(访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析等等……),此外还**支持内网http代理、内网socks5代理****p2p等**,并带有功能强大的web管理端。

Expand Down
2 changes: 1 addition & 1 deletion docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![logo](logo.svg)

# NPS <small>0.26.1</small>
# NPS <small>0.26.2</small>

> 一款轻量级、高性能、功能强大的内网穿透代理服务器
Expand Down
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

* 其他

* [FAQ](faq.md)
* [贡献](contribute.md)
* [捐助](donate.md)
* [致谢](thanks.md)
Expand Down
5 changes: 1 addition & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,4 @@ POST /auth/getauthkey
- 解密串编码方式 十六进制

## 详细文档
- **此文档近期可能更新较慢,建议自行抓包**

为方便第三方扩展,在web模式下可利用webAPI进行相关操作,详情见
[webAPI文档](https://github.com/ehang-io/nps/wiki/webAPI%E6%96%87%E6%A1%A3)
- **[详见](webapi.md)** (感谢@avengexyz)
8 changes: 4 additions & 4 deletions docs/example.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 使用示例
## 统一准备工作(必做)
- 开启服务端,假设公网服务器ip为1.1.1.1,配置文件中`bridge_port`为8284,配置文件中`web_port`为8080
- 开启服务端,假设公网服务器ip为1.1.1.1,配置文件中`bridge_port`为8024,配置文件中`web_port`为8080
- 访问1.1.1.1:8080
- 在客户端管理中创建一个客户端,记录下验证密钥
- 内网客户端运行(windows使用cmd运行加.exe)

```shell
./npc -server=1.1.1.1:8284 -vkey=客户端的密钥
./npc -server=1.1.1.1:8024 -vkey=客户端的密钥
```
**注意:运行服务端后,请确保能从客户端设备上正常访问配置文件中所配置的`bridge_port`端口,telnet,netcat这类的来检查**

Expand Down Expand Up @@ -89,7 +89,7 @@
- 在需要连接ssh的机器上以执行命令

```
./npc -server=1.1.1.1:8284 -vkey=vkey -type=tcp -password=secrettest -local_type=secret
./npc -server=1.1.1.1:8024 -vkey=vkey -type=tcp -password=secrettest -local_type=secret
```
如需指定本地端口可加参数`-local_port=xx`,默认为2000

Expand All @@ -112,7 +112,7 @@
- 在使用端机器(本机)执行命令

```
./npc -server=1.1.1.1:8284 -vkey=123 -password=p2pssh -target=10.2.50.2:22
./npc -server=1.1.1.1:8024 -vkey=123 -password=p2pssh -target=10.2.50.2:22
```
如需指定本地端口可加参数`-local_port=xx`,默认为2000

Expand Down
16 changes: 16 additions & 0 deletions docs/faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# FAQ

- 服务端无法启动
```
服务端默认配置启用了8024,8080,80,443端口,端口冲突无法启动,请修改配置
```
- 客户端无法连接服务端
```
请检查配置文件中的所有端口是否在安全组,防火墙放行
请检查vkey是否对应
请检查版本是否对应
```
- 服务端配置文件修改无效
```
install 之后,Linux 配置文件在 /etc/nps
```
8 changes: 7 additions & 1 deletion docs/feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ npc支持环境变量渲染以适应在某些特殊场景下的要求。
**在无配置文件启动模式下:**
设置环境变量
```
export NPC_SERVER_ADDR=1.1.1.1:8284
export NPC_SERVER_ADDR=1.1.1.1:8024
export NPC_SERVER_VKEY=xxxxx
```
直接执行./npc即可运行
Expand Down Expand Up @@ -245,3 +245,9 @@ LevelInformational->6 LevelDebug->7
**对于nps:**

`nps.conf`中设置相关配置即可

## pprof性能分析与调试

可在服务端与客户端配置中开启pprof端口,用于性能分析与调试,注释或留空相应参数为关闭。

默认为关闭状态
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## 源码安装
- 安装源码
```go get -u ehang.io/nps...```
```go get -u ehang.io/nps```
- 编译

服务端```go build cmd/nps/nps.go```
Expand Down
6 changes: 4 additions & 2 deletions docs/nps_use.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
nps.exe stop|restart
```
## 服务端更新
请首先执行`sudo nps stop`或者`nps.exe stop`停止运行,然后
请首先执行 `sudo nps stop` 或者 `nps.exe stop` 停止运行,然后

对于linux
```shell
Expand All @@ -40,6 +40,8 @@
nps-update.exe update
```

更新完成后,执行执行`sudo nps start`或者`nps.exe start`重新运行即可完成升级
更新完成后,执行执行 `sudo nps start` 或者 `nps.exe start` 重新运行即可完成升级

如果无法更新成功,可以直接自行下载releases压缩包然后覆盖原有的nps二进制文件和web目录

注意:`nps install` 之后的 nps 不在原位置,请使用 `whereis nps` 查找具体目录覆盖 nps 二进制文件
2 changes: 2 additions & 0 deletions docs/server_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ log_level|日志输出级别
auth_crypt_key | 获取服务端authKey时的aes加密密钥,16位
p2p_ip| 服务端Ip,使用p2p模式必填
p2p_port|p2p模式开启的udp端口
pprof_ip|debug pprof 服务端ip
pprof_port|debug pprof 端口
20 changes: 11 additions & 9 deletions docs/use.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ npc-update.exe update
#### 全局配置
```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
conn_type=tcp
vkey=123
username=111
Expand All @@ -59,6 +59,7 @@ rate_limit=10000
flow_limit=100
remark=test
max_conn=10
#pprof_addr=0.0.0.0:9999
```
项 | 含义
---|---
Expand All @@ -73,11 +74,12 @@ rate_limit|速度限制,可忽略
flow_limit|流量限制,可忽略
remark|客户端备注,可忽略
max_conn|最大连接数,可忽略
pprof_addr|debug pprof ip:port
#### 域名代理

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[web1]
host=a.proxy.com
Expand All @@ -97,7 +99,7 @@ header_xxx|请求header修改或添加,header_proxy表示添加header proxy:np

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[tcp]
mode=tcp
Expand All @@ -114,7 +116,7 @@ tartget_addr|内网目标

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[udp]
mode=udp
Expand All @@ -130,7 +132,7 @@ target_addr|内网目标

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[http]
mode=httpProxy
Expand All @@ -144,7 +146,7 @@ server_port | 在服务端的代理端口

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[socks5]
mode=socks5
Expand All @@ -160,7 +162,7 @@ multi_account | socks5多账号配置文件(可选),配置后使用basic_usern

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[secret_ssh]
mode=secret
Expand All @@ -177,7 +179,7 @@ target_addr|内网目标

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[p2p_ssh]
mode=p2p
Expand All @@ -196,7 +198,7 @@ target_addr|内网目标

```ini
[common]
server_addr=1.1.1.1:8284
server_addr=1.1.1.1:8024
vkey=123
[file]
mode=file
Expand Down
2 changes: 1 addition & 1 deletion docs/webapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ POST /client/add/
| max\_tunnel | 客户端最大隧道数量 空则为不限制 |

***
修改客户端(25.4版本有问题暂时不能用)
修改客户端

```
POST /client/edit/
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.13

require (
ehang.io/nps-mux v0.0.0-20200116160632-de59baca47b5
fyne.io/fyne v1.2.0
fyne.io/fyne v1.2.2
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/astaxie/beego v1.12.0
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
Expand All @@ -16,7 +16,7 @@ require (
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 // indirect
github.com/kardianos/service v1.0.0
github.com/klauspost/pgzip v1.2.1 // indirect
github.com/panjf2000/ants/v2 v2.2.2
github.com/panjf2000/ants/v2 v2.3.0
github.com/pkg/errors v0.9.1
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/shirou/gopsutil v2.19.11+incompatible
Expand Down

0 comments on commit 7ede000

Please sign in to comment.