go 安装
https://ehang-io.github.io/nps/#/install
- 下载源码
完成后,源码会下载到~/go/src/ehang.io/npsgo get -u ehang.io/nps
- 编译,进入源码目录
go build cmd/nps/nps.go go build cmd/npc/npc.go
make编译安装nps
- 下载源码
https://github.com/ehang-io/nps/archive/refs/tags/v0.26.10.zip
- make
- 编译报错解决
go: ehang.io/nps-mux@v0.0.0-20210407130203-4afa0c10c992: reading https://pkg.go.dev/ehang.io/nps-mux/@v/v0.0.0-20210407130203-4afa0c10c992.mod: 400 Bad Request
原因是原来的gocenter.io官网换了pkg.go.dev
vi Makefile
将 export GOPROXY := https://gocenter.io
改为
export GOPROXY := https://pkg.go.dev/
使用官方二进制安装包安装
安装配置server
- 下载nps_server
mkdir nps_server
cd nps_server
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_arm64_server.tar.gz
- 解压
- 安装
./nps install
在ubuntu上,默认安装到 /etc/nps - 配置系统服务
vi /etc/systemd/system/nps.service
[Unit]
Description=Nps Service
Documentation=https://nps.nineya.com
After=network-online.target
Wants=network-online.target
[Service]
User=root
Type=simple
ExecStart=/usr/bin/nps
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=always
StandOutput=syslog
StandError=inherit
[Install]
WantedBy=multi-user.target
- 设置开机自启动
systemctl enable nps
- web打开 http://your_machine_ip:8080/index
用户名密码 admin 123 - 客户端>新增,然后点击新增后的列表前面+号,可以看到client的启动命令
./npc -server=192.168.200.63:8024 -vkey=5o4he030xbexkry7 -type=tcp
安装配置client
- 下载nps_client
mkdir nps_client
cd nps_client
wget https://github.com/ehang-io/nps/releases/download/v0.26.10/linux_arm64_client.tar.gz
- 解压
- 使用前面得到的client启动命令启动即可
./npc -server=192.168.200.63:8024 -vkey=5o4he030xbexkry7 -type=tcp
安装nps sdk
nps提供了sdk,用户可以使用sdk来对nps做进一步的开发
- 修改构建脚本
cd ~/go/src/ehang.io/nps
vi build.sh
修改第7行为下面代码
env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 CC=gcc go build -ldflags "-s -w " -buildmode=c-shared -o npc_sdk.so cmd/npc/sdk.go
exit
- 设置代理,因为要访问github.com
- 执行
./build.sh
- 将在当前目录生成
npc_sdk.dll npc_sdk.h npc_sdk.so
- 拷贝到系统目录即可