From 383dbd1b7b8afa712d9493197e0a28cc34340c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Fri, 10 May 2019 16:29:55 +0000 Subject: [PATCH 01/58] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20web=5Fbase=5Furl=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE,=20=E7=94=A8=E4=BA=8E=E9=85=8D=E7=BD=AE=20we?= =?UTF-8?q?b=20=E5=90=8E=E5=8F=B0=E5=8F=AF=E7=BD=AE=E4=BA=8E=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=AD=90=E8=B7=AF=E5=BE=84=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 25 ++++++++++++++++++ cmd/nps/nps.go | 3 ++- conf/nps.conf | 3 +++ server/proxy/tcp.go | 2 +- web/controllers/base.go | 5 +++- web/controllers/index.go | 2 ++ web/controllers/login.go | 4 ++- web/routers/router.go | 24 ++++++++++++----- web/static/js/langchange.js | 4 +-- web/views/client/add.html | 2 +- web/views/client/edit.html | 2 +- web/views/client/list.html | 18 ++++++------- web/views/index/add.html | 2 +- web/views/index/edit.html | 2 +- web/views/index/hadd.html | 2 +- web/views/index/hedit.html | 2 +- web/views/index/hlist.html | 6 ++--- web/views/index/list.html | 12 ++++----- web/views/login/index.html | 14 +++++----- web/views/login/register.html | 14 +++++----- web/views/public/layout.html | 49 +++++++++++++++++++---------------- 21 files changed, 124 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 5f08bee3..cb24ffb1 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ nps是一款轻量级、高性能、功能强大的**内网穿透**代理服务 * [配置文件说明](#服务端配置文件) * [使用https](#使用https) * [与nginx配合](#与nginx配合) + * [web使用Caddy代理](#web使用Caddy代理) * [关闭http|https代理](#关闭代理) * [将nps安装到系统](#将nps安装到系统) * [流量数据持久化](#流量数据持久化) @@ -307,6 +308,7 @@ nps是一款轻量级、高性能、功能强大的**内网穿透**代理服务 web_port | web管理端口 web_password | web界面管理密码 web_username | web界面管理账号 +web_base_url | web管理主路径,用于将web管理置于代理子路径后面 bridge_port | 服务端客户端通信端口 https_proxy_port | 域名代理https代理监听端口 http_proxy_port | 域名代理http代理监听端口 @@ -365,6 +367,29 @@ server { } } ``` + +### web使用Caddy代理 + +如果将web配置到Caddy代理,实现子路径访问nps,可以这样配置. + +假设我们想通过 `http://caddy_ip:caddy_port/nps` 来访问后台, Caddyfile 这样配置: + +```Caddyfile +caddy_ip:caddy_port/nps { + #server_ip 为 nps 服务器IP + #web_port 为 nps 后台端口 + proxy / http://server_ip:web_port/nps { + transparent + } +} +``` + +nps.conf 修改 `web_base_url` 为 `/nps` 即可 +``` +web_base_url=/nps +``` + + ### 关闭代理 如需关闭http代理可在配置文件中将http_proxy_port设置为空,如需关闭https代理可在配置文件中将https_proxy_port设置为空。 diff --git a/cmd/nps/nps.go b/cmd/nps/nps.go index 2cb9a28d..369dcf11 100644 --- a/cmd/nps/nps.go +++ b/cmd/nps/nps.go @@ -14,7 +14,7 @@ import ( "github.com/cnlh/nps/server/tool" "github.com/cnlh/nps/vender/github.com/astaxie/beego" "github.com/cnlh/nps/vender/github.com/astaxie/beego/logs" - _ "github.com/cnlh/nps/web/routers" + "github.com/cnlh/nps/web/routers" "log" "os" "path/filepath" @@ -28,6 +28,7 @@ var ( func main() { flag.Parse() beego.LoadAppConfig("ini", filepath.Join(common.GetRunPath(), "conf", "nps.conf")) + routers.Init() if len(os.Args) > 1 { switch os.Args[1] { case "test": diff --git a/conf/nps.conf b/conf/nps.conf index c75a4302..8c22ab1e 100755 --- a/conf/nps.conf +++ b/conf/nps.conf @@ -41,6 +41,9 @@ web_username=admin web_password=123 web_port = 8080 web_ip=0.0.0.0 +web_base_url= +# if web under proxy use sub path. like http://host/nps need this. +#web_base_url=/nps #Web API unauthenticated IP address(the len of auth_crypt_key must be 16) auth_key=test diff --git a/server/proxy/tcp.go b/server/proxy/tcp.go index b7c72674..e263a827 100755 --- a/server/proxy/tcp.go +++ b/server/proxy/tcp.go @@ -62,7 +62,7 @@ func (s *WebServer) Start() error { <-stop } beego.BConfig.WebConfig.Session.SessionOn = true - beego.SetStaticPath("/static", filepath.Join(common.GetRunPath(), "web", "static")) + beego.SetStaticPath(beego.AppConfig.String("web_base_url")+"/static", filepath.Join(common.GetRunPath(), "web", "static")) beego.SetViewsPath(filepath.Join(common.GetRunPath(), "web", "views")) if l, err := connection.GetWebManagerListener(); err == nil { beego.InitBeforeHTTPRun() diff --git a/web/controllers/base.go b/web/controllers/base.go index cbfa1ccc..e58d37d0 100755 --- a/web/controllers/base.go +++ b/web/controllers/base.go @@ -21,6 +21,7 @@ type BaseController struct { //初始化参数 func (s *BaseController) Prepare() { + s.Data["web_base_url"] = beego.AppConfig.String("web_base_url") controllerName, actionName := s.GetControllerAndAction() s.controllerName = strings.ToLower(controllerName[0 : len(controllerName)-10]) s.actionName = strings.ToLower(actionName) @@ -33,7 +34,7 @@ func (s *BaseController) Prepare() { timeNowUnix := time.Now().Unix() if !((math.Abs(float64(timeNowUnix-int64(timestamp))) <= 20) && (crypt.Md5(configKey+strconv.Itoa(timestamp)) == md5Key)) { if s.GetSession("auth") != true { - s.Redirect("/login/index", 302) + s.Redirect(beego.AppConfig.String("web_base_url")+"/login/index", 302) } } if s.GetSession("isAdmin") != nil && !s.GetSession("isAdmin").(bool) { @@ -59,6 +60,7 @@ func (s *BaseController) Prepare() { //加载模板 func (s *BaseController) display(tpl ...string) { + s.Data["web_base_url"] = beego.AppConfig.String("web_base_url") var tplname string if s.Data["menu"] == nil { s.Data["menu"] = s.actionName @@ -82,6 +84,7 @@ func (s *BaseController) display(tpl ...string) { //错误 func (s *BaseController) error() { + s.Data["web_base_url"] = beego.AppConfig.String("web_base_url") s.Layout = "public/layout.html" s.TplName = "public/error.html" } diff --git a/web/controllers/index.go b/web/controllers/index.go index 5ecdb153..ff7370ab 100755 --- a/web/controllers/index.go +++ b/web/controllers/index.go @@ -4,6 +4,7 @@ import ( "github.com/cnlh/nps/lib/file" "github.com/cnlh/nps/server" "github.com/cnlh/nps/server/tool" + "github.com/cnlh/nps/vender/github.com/astaxie/beego" ) type IndexController struct { @@ -11,6 +12,7 @@ type IndexController struct { } func (s *IndexController) Index() { + s.Data["web_base_url"] = beego.AppConfig.String("web_base_url") s.Data["data"] = server.GetDashboardData() s.SetInfo("dashboard") s.display("index/index") diff --git a/web/controllers/login.go b/web/controllers/login.go index 7b8a55df..6c62a0d1 100755 --- a/web/controllers/login.go +++ b/web/controllers/login.go @@ -13,6 +13,7 @@ type LoginController struct { } func (self *LoginController) Index() { + self.Data["web_base_url"] = beego.AppConfig.String("web_base_url") self.Data["register_allow"], _ = beego.AppConfig.Bool("allow_user_register") self.TplName = "login/index.html" } @@ -59,6 +60,7 @@ func (self *LoginController) Verify() { } func (self *LoginController) Register() { if self.Ctx.Request.Method == "GET" { + self.Data["web_base_url"] = beego.AppConfig.String("web_base_url") self.TplName = "login/register.html" } else { if b, err := beego.AppConfig.Bool("allow_user_register"); err != nil || !b { @@ -90,5 +92,5 @@ func (self *LoginController) Register() { func (self *LoginController) Out() { self.SetSession("auth", false) - self.Redirect("/login/index", 302) + self.Redirect(beego.AppConfig.String("web_base_url")+"/login/index", 302) } diff --git a/web/routers/router.go b/web/routers/router.go index 690df3b3..82d4ad25 100755 --- a/web/routers/router.go +++ b/web/routers/router.go @@ -5,10 +5,22 @@ import ( "github.com/cnlh/nps/web/controllers" ) -func init() { - beego.Router("/", &controllers.IndexController{}, "*:Index") - beego.AutoRouter(&controllers.IndexController{}) - beego.AutoRouter(&controllers.LoginController{}) - beego.AutoRouter(&controllers.ClientController{}) - beego.AutoRouter(&controllers.AuthController{}) +func Init() { + web_base_url := beego.AppConfig.String("web_base_url") + if len(web_base_url) > 0 { + ns := beego.NewNamespace(web_base_url, + beego.NSRouter("/", &controllers.IndexController{}, "*:Index"), + beego.NSAutoRouter(&controllers.IndexController{}), + beego.NSAutoRouter(&controllers.LoginController{}), + beego.NSAutoRouter(&controllers.ClientController{}), + beego.NSAutoRouter(&controllers.AuthController{}), + ) + beego.AddNamespace(ns) + } else { + beego.Router("/", &controllers.IndexController{}, "*:Index") + beego.AutoRouter(&controllers.IndexController{}) + beego.AutoRouter(&controllers.LoginController{}) + beego.AutoRouter(&controllers.ClientController{}) + beego.AutoRouter(&controllers.AuthController{}) + } } diff --git a/web/static/js/langchange.js b/web/static/js/langchange.js index 54961d70..e7a60fbf 100644 --- a/web/static/js/langchange.js +++ b/web/static/js/langchange.js @@ -12,7 +12,7 @@ $.ajax({ type: "GET", - url: defaults.file, + url: window.nps.web_base_url + defaults.file, dataType: "xml", success: function (xml) { $(xml).find('text').each(function () { @@ -65,4 +65,4 @@ $(document).ready(function () { setCookie("lang", "zh") $("body").cloudLang({lang: "zh", file: "/static/page/lang-example.xml"}); }); -}); \ No newline at end of file +}); diff --git a/web/views/client/add.html b/web/views/client/add.html index 07719bd0..30563c2d 100755 --- a/web/views/client/add.html +++ b/web/views/client/add.html @@ -134,7 +134,7 @@

add client

$("#add").on("click", function () { $.ajax({ type: "POST", - url: "/client/add", + url: "{{.web_base_url}}/client/add", data: $("form").serializeArray(), success: function (res) { alert(res.msg) diff --git a/web/views/client/edit.html b/web/views/client/edit.html index 20db215b..0ae06a2d 100755 --- a/web/views/client/edit.html +++ b/web/views/client/edit.html @@ -145,7 +145,7 @@

add client

$("#add").on("click", function () { $.ajax({ type: "POST", - url: "/client/edit", + url: "{{.web_base_url}}/client/edit", data: $("form").serializeArray(), success: function (res) { alert(res.msg) diff --git a/web/views/client/list.html b/web/views/client/list.html index ce49bfe2..60a4fc64 100755 --- a/web/views/client/list.html +++ b/web/views/client/list.html @@ -20,7 +20,7 @@
client list
@@ -42,7 +42,7 @@
client list
if (confirm("Are you sure you want to delete it??")) { $.ajax({ type: "POST", - url: "/client/del", + url: "{{.web_base_url}}/client/del", data: {"id": id}, success: function (res) { alert(res.msg) @@ -58,7 +58,7 @@
client list
if (confirm("Are you sure you want to start it??")) { $.ajax({ type: "POST", - url: "/client/changestatus", + url: "{{.web_base_url}}/client/changestatus", data: {"id": id, "status": 1}, success: function (res) { alert(res.msg) @@ -74,7 +74,7 @@
client list
if (confirm("Are you sure you want to stop it?")) { $.ajax({ type: "POST", - url: "/client/changestatus", + url: "{{.web_base_url}}/client/changestatus", data: { "id": id, "status": 0 }, @@ -90,26 +90,26 @@
client list
} function edit(id) { - window.location.href = "/client/edit?id=" + id + window.location.href = "{{.web_base_url}}/client/edit?id=" + id } function add() { - window.location.href = "/client/add" + window.location.href = "{{.web_base_url}}/client/add" } function tunnel(id) { - window.location.href = "/index/all?client_id=" + id + window.location.href = "{{.web_base_url}}/index/all?client_id=" + id } function host(id) { - window.location.href = "/index/hostlist?client_id=" + id + window.location.href = "{{.web_base_url}}/index/hostlist?client_id=" + id } /*bootstrap table*/ $('#table').bootstrapTable({ toolbar: "#toolbar", method: 'post', // 服务器数据的请求方式 get or post - url: "/client/list", // 服务器数据的加载地址 + url: "{{.web_base_url}}/client/list", // 服务器数据的加载地址 contentType: "application/x-www-form-urlencoded", striped: true, // 设置为true会有隔行变色效果 search: true, diff --git a/web/views/index/add.html b/web/views/index/add.html index c2208a76..302553aa 100755 --- a/web/views/index/add.html +++ b/web/views/index/add.html @@ -162,7 +162,7 @@

add

$("#add").on("click", function () { $.ajax({ type: "POST", - url: "/index/add", + url: "{{.web_base_url}}/index/add", data: $("form").serializeArray(), success: function (res) { alert(res.msg) diff --git a/web/views/index/edit.html b/web/views/index/edit.html index ef48ad04..32e3c3fe 100755 --- a/web/views/index/edit.html +++ b/web/views/index/edit.html @@ -160,7 +160,7 @@

编辑

$("#add").on("click", function () { $.ajax({ type: "POST", - url: "/index/edit", + url: "{{.web_base_url}}/index/edit", data: $("form").serializeArray(), success: function (res) { alert(res.msg) diff --git a/web/views/index/hadd.html b/web/views/index/hadd.html index ac2a5cc7..1a4482d2 100755 --- a/web/views/index/hadd.html +++ b/web/views/index/hadd.html @@ -112,7 +112,7 @@

add host

$("#add").on("click", function () { $.ajax({ type: "POST", - url: "/index/addhost", + url: "{{.web_base_url}}/index/addhost", data: $("form").serializeArray(), success: function (res) { alert(res.msg) diff --git a/web/views/index/hedit.html b/web/views/index/hedit.html index 5b430e98..9e17f455 100644 --- a/web/views/index/hedit.html +++ b/web/views/index/hedit.html @@ -116,7 +116,7 @@

add host

$("#add").on("click", function () { $.ajax({ type: "POST", - url: "/index/edithost", + url: "{{.web_base_url}}/index/edithost", data: $("form").serializeArray(), success: function (res) { alert(res.msg) diff --git a/web/views/index/hlist.html b/web/views/index/hlist.html index 6d2ccaa2..d2ec24e1 100755 --- a/web/views/index/hlist.html +++ b/web/views/index/hlist.html @@ -18,7 +18,7 @@
host list
- 新增
@@ -158,7 +158,7 @@
host list
if (confirm("Are you sure you want to delete it??")) { $.ajax({ type: "POST", - url: "/index/delhost", + url: "{{.web_base_url}}/index/delhost", data: {"id": id}, success: function (res) { alert(res.msg) @@ -171,7 +171,7 @@
host list
} function edit(id) { - window.location.href = "/index/edithost?id=" + id + window.location.href = "{{.web_base_url}}/index/edithost?id=" + id } diff --git a/web/views/index/list.html b/web/views/index/list.html index 5537f67a..248d2cbe 100755 --- a/web/views/index/list.html +++ b/web/views/index/list.html @@ -18,7 +18,7 @@
{{.name}}
- 新增
{{.name}} $('#table').bootstrapTable({ toolbar: "#toolbar", method: 'post', // 服务器数据的请求方式 get or post - url: "/index/gettunnel", // 服务器数据的加载地址 + url: "{{.web_base_url}}/index/gettunnel", // 服务器数据的加载地址 queryParams: function (params) { return { "offset": params.offset, @@ -191,7 +191,7 @@
{{.name}}
if (confirm("Are you sure you want to delete it??")) { $.ajax({ type: "POST", - url: "/index/del", + url: "{{.web_base_url}}/index/del", data: {"id": id}, success: function (res) { alert(res.msg) @@ -207,7 +207,7 @@
{{.name}}
if (confirm("Are you sure you want to start it??")) { $.ajax({ type: "POST", - url: "/index/start", + url: "{{.web_base_url}}/index/start", data: {"id": id}, success: function (res) { alert(res.msg) @@ -223,7 +223,7 @@
{{.name}}
if (confirm("Are you sure you want to stop it??")) { $.ajax({ type: "POST", - url: "/index/stop", + url: "{{.web_base_url}}/index/stop", data: {"id": id}, success: function (res) { alert(res.msg) @@ -236,7 +236,7 @@
{{.name}}
} function edit(id) { - window.location.href = "/index/edit?id=" + id + window.location.href = "{{.web_base_url}}/index/edit?id=" + id } diff --git a/web/views/login/index.html b/web/views/login/index.html index a28ae870..ffe89d04 100755 --- a/web/views/login/index.html +++ b/web/views/login/index.html @@ -8,10 +8,10 @@ nps admin login - - + + - + @@ -49,7 +49,7 @@

nps

{{if eq true .register_allow}} - register + register {{end}} @@ -59,7 +59,7 @@

nps

- + @@ -68,11 +68,11 @@

nps

function login() { $.ajax({ type: "POST", - url: "/login/verify", + url: "{{.web_base_url}}/login/verify", data: $("form").serializeArray(), success: function (res) { if (res.status) { - window.location.href = "/index/index" + window.location.href = "{{.web_base_url}}/index/index" } else { alert(res.msg) } diff --git a/web/views/login/register.html b/web/views/login/register.html index 88d6e3b6..a67e8c5c 100644 --- a/web/views/login/register.html +++ b/web/views/login/register.html @@ -8,10 +8,10 @@ nps register - - + + - + @@ -34,22 +34,22 @@

register NPS

- login + login - + + + + + - - - + + + - + - - + + - + @@ -35,7 +35,7 @@ @@ -115,7 +115,7 @@
  • - + logout
  • @@ -142,6 +142,9 @@ \ No newline at end of file + From 01a4bcf13db7d2aeed77e198a11fddb1e5317f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 01:54:23 +0800 Subject: [PATCH 39/58] update npc sdk and version --- .travis.yml | 10 ++++++++-- cmd/npc/sdk.go | 35 +++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64c4aa00..345d47f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,9 @@ services: - docker script: - go test -v ./cmd/nps/ - +os: + - linux + - windows before_deploy: - wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz - tar -xvf upx-3.95-amd64_linux.tar.xz @@ -162,7 +164,7 @@ before_deploy: - tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe - - export VERSION=0.24.2 + - export VERSION=0.24.3 - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get update @@ -174,6 +176,9 @@ before_deploy: - docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make' - cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk + - if [ "$TRAVIS_OS_NAME" = "windows" ]; then go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go ; fi + - tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - export DOCKER_CLI_EXPERIMENTAL=enabled - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d @@ -220,6 +225,7 @@ deploy: - win_amd64_client.tar.gz - win_amd64_server.tar.gz - npc_$VERSION.spk + - nnpc_sdk.tar.gz on: tags: true all_branches: true diff --git a/cmd/npc/sdk.go b/cmd/npc/sdk.go index bf247fa1..b4b60f9f 100644 --- a/cmd/npc/sdk.go +++ b/cmd/npc/sdk.go @@ -2,32 +2,47 @@ package main import "C" import ( - "fmt" "github.com/cnlh/nps/client" "time" ) -//export PrintBye -func PrintBye() { - fmt.Println("From DLL: Bye!") -} - var status bool +var closeBefore bool +var cl *client.TRPClient -//export Sum -func StartClientByVerifyKey(a int, b int) bool { - c := client.NewRPClient(*serverAddr, *verifyKey, *connType, *proxyUrl, nil) +//export StartClientByVerifyKey +func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl string) bool { + if cl != nil { + closeBefore = true + cl.Close() + } + cl = client.NewRPClient(serverAddr, verifyKey, connType, proxyUrl, nil) + closeBefore = false go func() { for { status = true - c.Start() + cl.Start() status = false + if closeBefore { + return + } time.Sleep(time.Second * 5) } }() return true } +//export GetClientStatus +func GetClientStatus() bool { + return status +} + +//export CloseClient +func CloseClient() { + cl.Close() + closeBefore = true +} + func main() { // Need a main function to make CGO compile package as C shared library } From 509c81a2b58646c4dbf9294dc081ff0602199da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 02:36:45 +0800 Subject: [PATCH 40/58] update trivas --- .travis.yml | 178 ++------------------------------------------------- build.sh | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++ update.sh | 50 +++++++++++++++ 3 files changed, 233 insertions(+), 174 deletions(-) create mode 100644 build.sh create mode 100644 update.sh diff --git a/.travis.yml b/.travis.yml index 345d47f3..cb8c8ae7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,181 +10,11 @@ script: os: - linux - windows +jobs: + allow_failures: + - os: windows before_deploy: - - wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz - - tar -xvf upx-3.95-amd64_linux.tar.xz - - cp upx-3.95-amd64_linux/upx ./ - - - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_amd64_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_386_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf freebsd_386_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf freebsd_amd64_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf freebsd_arm_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_arm_v7_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_arm_v6_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_arm_v5_client.tar.gz npc conf/npc.conf - - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_arm64_client.tar.gz npc conf/npc.conf - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_mips64_client.tar.gz npc conf/npc.conf - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_mips64le_client.tar.gz npc conf/npc.conf - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_mipsle_client.tar.gz npc conf/npc.conf - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf linux_mips_client.tar.gz npc conf/npc.conf - - - - CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf win_386_client.tar.gz npc.exe conf/npc.conf - - - - CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf win_amd64_client.tar.gz npc.exe conf/npc.conf - - - - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - - - tar -czvf macos_client.tar.gz npc conf/npc.conf - - - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_arm_v5_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_arm_v6_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_arm_v7_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_arm64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf freebsd_arm_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf freebsd_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf freebsd_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_mips_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_mips64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_mips64le_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf linux_mipsle_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf macos_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - - - - CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf win_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe - - - - CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - - - tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe - - - export VERSION=0.24.3 - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - - sudo apt-get update - - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - - docker --version - - git clone https://github.com/cnlh/spksrc.git ~/spksrc - - mkdir ~/spksrc/nps && cp -rf ./* ~/spksrc/nps/ - - docker run -itd --name spksrc --env VERSION=$VERSION -v ~/spksrc:/spksrc synocommunity/spksrc /bin/bash - - docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make' - - cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk - - - if [ "$TRAVIS_OS_NAME" = "windows" ]; then go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go ; fi - - tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h - - - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - - export DOCKER_CLI_EXPERIMENTAL=enabled - - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d - - docker buildx create --use --name mybuilder - - docker buildx build --tag ffdfgdfg/nps:$VERSION --output type=image,push=true --file Dockerfile.nps --platform=linux/amd64,linux/arm64,linux/386,linux/arm . - - docker buildx build --tag ffdfgdfg/npc:$VERSION --output type=image,push=true --file Dockerfile.npc --platform=linux/amd64,linux/arm64,linux/386,linux/arm . + - ./build.sh deploy: provider: releases diff --git a/build.sh b/build.sh new file mode 100644 index 00000000..4be7456d --- /dev/null +++ b/build.sh @@ -0,0 +1,179 @@ +#/bash/sh + +if [ "$TRAVIS_OS_NAME" = "windows" ]; then + go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go + tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h +else + wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz + tar -xvf upx-3.95-amd64_linux.tar.xz + cp upx-3.95-amd64_linux/upx ./ + + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_amd64_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_386_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf freebsd_386_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf freebsd_amd64_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf freebsd_arm_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_arm_v7_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_arm_v6_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_arm_v5_client.tar.gz npc conf/npc.conf + + + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_arm64_client.tar.gz npc conf/npc.conf + + + CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_mips64_client.tar.gz npc conf/npc.conf + + + CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_mips64le_client.tar.gz npc conf/npc.conf + + + CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_mipsle_client.tar.gz npc conf/npc.conf + + + CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf linux_mips_client.tar.gz npc conf/npc.conf + + + CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf win_386_client.tar.gz npc.exe conf/npc.conf + + + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf win_amd64_client.tar.gz npc.exe conf/npc.conf + + + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go + + tar -czvf macos_client.tar.gz npc conf/npc.conf + + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_arm_v5_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_arm_v6_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_arm_v7_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_arm64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf freebsd_arm_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf freebsd_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf freebsd_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + + CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_mips_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_mips64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_mips64le_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf linux_mipsle_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf macos_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf win_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe + + + CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go + + tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe + + export VERSION=0.24.3 + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + sudo apt-get update + sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce + docker --version + git clone https://github.com/cnlh/spksrc.git ~/spksrc + mkdir ~/spksrc/nps && cp -rf ./* ~/spksrc/nps/ + docker run -itd --name spksrc --env VERSION=$VERSION -v ~/spksrc:/spksrc synocommunity/spksrc /bin/bash + docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make' + cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk + + + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + export DOCKER_CLI_EXPERIMENTAL=enabled + docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d + docker buildx create --use --name mybuilder + docker buildx build --tag ffdfgdfg/nps:$VERSION --output type=image,push=true --file Dockerfile.nps --platform=linux/amd64,linux/arm64,linux/386,linux/arm . + docker buildx build --tag ffdfgdfg/npc:$VERSION --output type=image,push=true --file Dockerfile.npc --platform=linux/amd64,linux/arm64,linux/386,linux/arm . +fi diff --git a/update.sh b/update.sh new file mode 100644 index 00000000..3e0bfe38 --- /dev/null +++ b/update.sh @@ -0,0 +1,50 @@ +#/bash/sh +echo "start upgrading to the latest version" +if [ $1 == "latest" ] +then + version=`wget -qO- -t1 -T2 "https://api.github.com/repos/cnlh/nps/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g'` +else + version=$1 +fi +echo "the current latest version is "$version"" +download_base_url=https://github.com/cnlh/nps/releases/download/$version/ + +if [ $4 ] +then + filename=""$2"_"$3"_v"$4"_"server".tar.gz" +else + filename=""$2"_"$3"_"server".tar.gz" +fi +complete_download_url=""$download_base_url""$filename"" +echo "start download file from "$complete_download_url"" + +dir_name=`echo $RANDOM` +mkdir $dir_name && cd $dir_name +wget $complete_download_url >/dev/null 2>&1 +if [ ! -f "$filename" ]; then + echo "download file failed!" + rm -rf $dir_name + exit +fi + +echo "start extracting files" +mkdir nps +tar -xvf $filename -C ./nps >/dev/null 2>&1 +cd nps + +if [ -f "../../nps" ]; then + echo "replace "../../nps"!" + cp -rf nps ../../ +fi + +usr_dir=`which nps` + +if [ -f "$usr_dir" ]; then + echo "replace "$usr_dir"!" + cp -rf nps $usr_dir +fi + +cd ../../ && rm -rf $dir_name + +echo "update complete!" +echo -e "\033[32m please restart nps \033[0m" From 6de4877f2473fe08d3cce3e8b546384f8599d733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 02:44:39 +0800 Subject: [PATCH 41/58] remove docker for test --- build.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 4be7456d..0ee6f009 100644 --- a/build.sh +++ b/build.sh @@ -170,10 +170,5 @@ else cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - export DOCKER_CLI_EXPERIMENTAL=enabled - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d - docker buildx create --use --name mybuilder - docker buildx build --tag ffdfgdfg/nps:$VERSION --output type=image,push=true --file Dockerfile.nps --platform=linux/amd64,linux/arm64,linux/386,linux/arm . - docker buildx build --tag ffdfgdfg/npc:$VERSION --output type=image,push=true --file Dockerfile.npc --platform=linux/amd64,linux/arm64,linux/386,linux/arm . + fi From 78c71c2fa34fff21dab8f6c12be5d9af168f2f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 02:51:30 +0800 Subject: [PATCH 42/58] update travis ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb8c8ae7..7e370adc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ jobs: allow_failures: - os: windows before_deploy: - - ./build.sh + - chmod +x ./build.sh && ./build.sh deploy: provider: releases From 1dca14fc01ff955d5dec79a19abd64584215ab72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 02:57:34 +0800 Subject: [PATCH 43/58] update travis ci --- .travis.yml | 3 +- build.sh | 167 ++++++++++++++++++++++++++-------------------------- 2 files changed, 86 insertions(+), 84 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e370adc..5a29a756 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,8 @@ jobs: allow_failures: - os: windows before_deploy: - - chmod +x ./build.sh && ./build.sh + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then chmod +x ./build.sh && ./build.sh; fi + - if [ "$TRAVIS_OS_NAME" = "windows" ]; go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go && tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h fi deploy: provider: releases diff --git a/build.sh b/build.sh index 0ee6f009..43f72a1a 100644 --- a/build.sh +++ b/build.sh @@ -1,174 +1,175 @@ #/bash/sh -if [ "$TRAVIS_OS_NAME" = "windows" ]; then - go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go - tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h -else - wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz - tar -xvf upx-3.95-amd64_linux.tar.xz - cp upx-3.95-amd64_linux/upx ./ - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz +tar -xvf upx-3.95-amd64_linux.tar.xz +cp upx-3.95-amd64_linux/upx ./ - tar -czvf linux_amd64_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_amd64_client.tar.gz npc conf/npc.conf - tar -czvf linux_386_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_386_client.tar.gz npc conf/npc.conf - tar -czvf freebsd_386_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf freebsd_386_client.tar.gz npc conf/npc.conf - tar -czvf freebsd_amd64_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf freebsd_amd64_client.tar.gz npc conf/npc.conf - tar -czvf freebsd_arm_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf freebsd_arm_client.tar.gz npc conf/npc.conf - tar -czvf linux_arm_v7_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_arm_v7_client.tar.gz npc conf/npc.conf - tar -czvf linux_arm_v6_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_arm_v6_client.tar.gz npc conf/npc.conf - tar -czvf linux_arm_v5_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_arm_v5_client.tar.gz npc conf/npc.conf - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf linux_arm64_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_arm64_client.tar.gz npc conf/npc.conf - CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf linux_mips64_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_mips64_client.tar.gz npc conf/npc.conf - CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf linux_mips64le_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_mips64le_client.tar.gz npc conf/npc.conf - CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf linux_mipsle_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_mipsle_client.tar.gz npc conf/npc.conf - CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf linux_mips_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf linux_mips_client.tar.gz npc conf/npc.conf - CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf win_386_client.tar.gz npc.exe conf/npc.conf +CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf win_386_client.tar.gz npc.exe conf/npc.conf - CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf win_amd64_client.tar.gz npc.exe conf/npc.conf +CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +tar -czvf win_amd64_client.tar.gz npc.exe conf/npc.conf - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - tar -czvf macos_client.tar.gz npc conf/npc.conf +CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf macos_client.tar.gz npc conf/npc.conf - tar -czvf linux_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - tar -czvf linux_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - tar -czvf linux_arm_v5_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_arm_v5_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - tar -czvf linux_arm_v6_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_arm_v6_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - tar -czvf linux_arm_v7_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_arm_v7_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf linux_arm64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_arm64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf freebsd_arm_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf freebsd_arm_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf freebsd_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf freebsd_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf freebsd_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf freebsd_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf linux_mips_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_mips_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf linux_mips64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_mips64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf linux_mips64le_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_mips64le_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf linux_mipsle_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf linux_mipsle_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf macos_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps +CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf macos_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps - CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf win_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe +CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +tar -czvf win_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe - CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe +CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go - export VERSION=0.24.3 - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get update - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce - docker --version - git clone https://github.com/cnlh/spksrc.git ~/spksrc - mkdir ~/spksrc/nps && cp -rf ./* ~/spksrc/nps/ - docker run -itd --name spksrc --env VERSION=$VERSION -v ~/spksrc:/spksrc synocommunity/spksrc /bin/bash - docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make' - cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk +tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe +export VERSION=0.24.3 +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" +sudo apt-get update +sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce +docker --version +git clone https://github.com/cnlh/spksrc.git ~/spksrc +mkdir ~/spksrc/nps && cp -rf ./* ~/spksrc/nps/ +docker run -itd --name spksrc --env VERSION=$VERSION -v ~/spksrc:/spksrc synocommunity/spksrc /bin/bash +docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make' +cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk -fi +echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +export DOCKER_CLI_EXPERIMENTAL=enabled +docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d +docker buildx create --use --name mybuilder +docker buildx build --tag ffdfgdfg/nps:$VERSION --output type=image,push=true --file Dockerfile.nps --platform=linux/amd64,linux/arm64,linux/386,linux/arm . +docker buildx build --tag ffdfgdfg/npc:$VERSION --output type=image,push=true --file Dockerfile.npc --platform=linux/amd64,linux/arm64,linux/386,linux/arm . From 5d2b3a53a019871a2c1504434212f3bb098d5692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 03:06:14 +0800 Subject: [PATCH 44/58] update travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a29a756..cb169925 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ jobs: - os: windows before_deploy: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then chmod +x ./build.sh && ./build.sh; fi - - if [ "$TRAVIS_OS_NAME" = "windows" ]; go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go && tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h fi + - if [ "$TRAVIS_OS_NAME" = "windows" ]; then go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go; fi deploy: provider: releases @@ -56,7 +56,8 @@ deploy: - win_amd64_client.tar.gz - win_amd64_server.tar.gz - npc_$VERSION.spk - - nnpc_sdk.tar.gz + - npc_sdk.dll + - npc_sdk.h on: tags: true all_branches: true From 3e26af308c81a34d7cba7ed3f11fd81ccc3b26b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 03:12:03 +0800 Subject: [PATCH 45/58] update travis.yml --- .travis.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index cb169925..c1417fd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,13 +9,8 @@ script: - go test -v ./cmd/nps/ os: - linux - - windows -jobs: - allow_failures: - - os: windows before_deploy: - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then chmod +x ./build.sh && ./build.sh; fi - - if [ "$TRAVIS_OS_NAME" = "windows" ]; then go build -buildmode=c-shared -o npc_sdk.dll cmd\npc\sdk.go; fi + - chmod +x ./build.sh && ./build.sh deploy: provider: releases @@ -56,8 +51,6 @@ deploy: - win_amd64_client.tar.gz - win_amd64_server.tar.gz - npc_$VERSION.spk - - npc_sdk.dll - - npc_sdk.h on: tags: true all_branches: true From eccf3c2be1b591b005466377f5777341802dc4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 03:56:04 +0800 Subject: [PATCH 46/58] fix bug 250 --- lib/conn/conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/conn/conn.go b/lib/conn/conn.go index 8f19e6c3..db03c40f 100755 --- a/lib/conn/conn.go +++ b/lib/conn/conn.go @@ -87,7 +87,7 @@ func (s *Conn) GetShortContent(l int) (b []byte, err error) { //读取指定长度内容 func (s *Conn) ReadLen(cLen int, buf []byte) (int, error) { - if cLen > len(buf) { + if cLen > len(buf) || cLen <= 0 { return 0, errors.New("长度错误" + strconv.Itoa(cLen)) } if n, err := io.ReadFull(s, buf[:cLen]); err != nil || n != cLen { From 627ea612e64b7db5a8c6d8592f3f1894e9542965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 04:04:05 +0800 Subject: [PATCH 47/58] fix nil pointer --- server/proxy/http.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/proxy/http.go b/server/proxy/http.go index 31ec81c1..936aae3f 100644 --- a/server/proxy/http.go +++ b/server/proxy/http.go @@ -171,11 +171,11 @@ reset: } }() for { - if resp, err := http.ReadResponse(bufio.NewReader(connClient), r); err != nil { + if resp, err := http.ReadResponse(bufio.NewReader(connClient), r); err != nil || resp == nil { return } else { //if the cache is start and the response is in the extension,store the response to the cache list - if s.useCache && strings.Contains(r.URL.Path, ".") { + if s.useCache && r.URL != nil && strings.Contains(r.URL.Path, ".") { b, err := httputil.DumpResponse(resp, true) if err != nil { return From fd71e0821fcd2b7982c0955efd21f5843ff30ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 04:45:52 +0800 Subject: [PATCH 48/58] fix compress --- lib/conn/snappy.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/conn/snappy.go b/lib/conn/snappy.go index 3f22aa05..2ea10341 100644 --- a/lib/conn/snappy.go +++ b/lib/conn/snappy.go @@ -3,7 +3,6 @@ package conn import ( "io" - "github.com/cnlh/nps/lib/common" "github.com/golang/snappy" ) @@ -32,13 +31,7 @@ func (s *SnappyConn) Write(b []byte) (n int, err error) { //snappy压缩读 func (s *SnappyConn) Read(b []byte) (n int, err error) { - buf := common.BufPool.Get().([]byte) - defer common.BufPool.Put(buf) - if n, err = s.r.Read(buf); err != nil { - return - } - copy(b, buf[:n]) - return + return s.r.Read(b) } func (s *SnappyConn) Close() error { From 5da5bf16286164704f721fdf345b8712e4afaf51 Mon Sep 17 00:00:00 2001 From: ffdfgdfg Date: Wed, 4 Dec 2019 13:04:25 +0800 Subject: [PATCH 49/58] fix p2p connection race condition --- client/local.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/local.go b/client/local.go index a66f9c0c..9c903f69 100644 --- a/client/local.go +++ b/client/local.go @@ -1,8 +1,10 @@ package client import ( + "errors" "net" "net/http" + "runtime" "sync" "time" @@ -31,6 +33,14 @@ type p2pBridge struct { } func (p2pBridge *p2pBridge) SendLinkInfo(clientId int, link *conn.Link, t *file.Tunnel) (target net.Conn, err error) { + for i := 0; muxSession == nil; i++ { + if i >= 20 { + err = errors.New("p2pBridge:too many times to get muxSession") + logs.Error(err) + return + } + runtime.Gosched() // waiting for another goroutine establish the mux connection + } nowConn, err := muxSession.NewConn() if err != nil { udpConn = nil From 50180e5b7f9902215f1e151d94bbc4e55eb0e423 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Dec 2019 17:41:46 +0800 Subject: [PATCH 50/58] add npc sdk dll --- .travis.yml | 1 + build.sh | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index c1417fd3..a0f65825 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,6 +51,7 @@ deploy: - win_amd64_client.tar.gz - win_amd64_server.tar.gz - npc_$VERSION.spk + - npc_sdk.tar.gz on: tags: true all_branches: true diff --git a/build.sh b/build.sh index 43f72a1a..5e8d93f4 100644 --- a/build.sh +++ b/build.sh @@ -173,3 +173,8 @@ docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f docker buildx create --use --name mybuilder docker buildx build --tag ffdfgdfg/nps:$VERSION --output type=image,push=true --file Dockerfile.nps --platform=linux/amd64,linux/arm64,linux/386,linux/arm . docker buildx build --tag ffdfgdfg/npc:$VERSION --output type=image,push=true --file Dockerfile.npc --platform=linux/amd64,linux/arm64,linux/386,linux/arm . + + +apt-get install gcc-mingw-w64-i686 +env GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go build -buildmode=c-shared -o npc_sdk.dll cmd/npc/sdk.go +tar -czvf npc_sdk.tar.gz -xvf npc_sdk.dll npc_sdk.h \ No newline at end of file From 036a17a3d94acb7159b1d6b4a50a4d7988ad33b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Dec 2019 17:52:32 +0800 Subject: [PATCH 51/58] change version --- build.sh | 2 +- lib/version/version.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 5e8d93f4..3db2d4be 100644 --- a/build.sh +++ b/build.sh @@ -154,7 +154,7 @@ CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -stat tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe -export VERSION=0.24.3 +export VERSION=0.25.0 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" sudo apt-get update diff --git a/lib/version/version.go b/lib/version/version.go index 0f395a82..c46c0102 100644 --- a/lib/version/version.go +++ b/lib/version/version.go @@ -1,8 +1,8 @@ package version -const VERSION = "0.24.3" +const VERSION = "0.25.0" // Compulsory minimum version, Minimum downward compatibility to this version func GetVersion() string { - return "0.24.3" + return "0.25.0" } From 391fdbd9202b7633dd3f85fb52a2be9f866e90c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Dec 2019 18:11:24 +0800 Subject: [PATCH 52/58] change sdk --- cmd/npc/sdk.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/npc/sdk.go b/cmd/npc/sdk.go index b4b60f9f..07693ee0 100644 --- a/cmd/npc/sdk.go +++ b/cmd/npc/sdk.go @@ -11,12 +11,12 @@ var closeBefore bool var cl *client.TRPClient //export StartClientByVerifyKey -func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl string) bool { +func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) bool { if cl != nil { closeBefore = true cl.Close() } - cl = client.NewRPClient(serverAddr, verifyKey, connType, proxyUrl, nil) + cl = client.NewRPClient(C.GoString(serverAddr), C.GoString(verifyKey), C.GoString(connType), C.GoString(proxyUrl), nil) closeBefore = false go func() { for { From 34fcd151014375db3c0ff4165858a9cf179a4813 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Dec 2019 18:21:54 +0800 Subject: [PATCH 53/58] add sudo in apt-get --- build.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 3db2d4be..c5b5f4e8 100644 --- a/build.sh +++ b/build.sh @@ -1,5 +1,8 @@ #/bash/sh +sudo apt-get install gcc-mingw-w64-i686 +env GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go build -buildmode=c-shared -o npc_sdk.dll cmd/npc/sdk.go +tar -czvf npc_sdk.tar.gz -xvf npc_sdk.dll npc_sdk.h wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz tar -xvf upx-3.95-amd64_linux.tar.xz @@ -173,8 +176,3 @@ docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f docker buildx create --use --name mybuilder docker buildx build --tag ffdfgdfg/nps:$VERSION --output type=image,push=true --file Dockerfile.nps --platform=linux/amd64,linux/arm64,linux/386,linux/arm . docker buildx build --tag ffdfgdfg/npc:$VERSION --output type=image,push=true --file Dockerfile.npc --platform=linux/amd64,linux/arm64,linux/386,linux/arm . - - -apt-get install gcc-mingw-w64-i686 -env GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go build -buildmode=c-shared -o npc_sdk.dll cmd/npc/sdk.go -tar -czvf npc_sdk.tar.gz -xvf npc_sdk.dll npc_sdk.h \ No newline at end of file From cb1cc67e6bcb59f70d4d551992b9be92092af595 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Dec 2019 18:36:29 +0800 Subject: [PATCH 54/58] add log for sdk --- cmd/npc/sdk.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/npc/sdk.go b/cmd/npc/sdk.go index 07693ee0..cf41af96 100644 --- a/cmd/npc/sdk.go +++ b/cmd/npc/sdk.go @@ -2,45 +2,50 @@ package main import "C" import ( + "github.com/astaxie/beego/logs" "github.com/cnlh/nps/client" "time" ) -var status bool -var closeBefore bool +func init() { + logs.SetLogger(logs.AdapterFile, `{"filename":"npc.log","daily":false,"maxlines":100000,"color":true}`) +} + +var status int +var closeBefore int var cl *client.TRPClient //export StartClientByVerifyKey -func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) bool { +func StartClientByVerifyKey(serverAddr, verifyKey, connType, proxyUrl *C.char) int { if cl != nil { - closeBefore = true + closeBefore = 1 cl.Close() } cl = client.NewRPClient(C.GoString(serverAddr), C.GoString(verifyKey), C.GoString(connType), C.GoString(proxyUrl), nil) - closeBefore = false + closeBefore = 0 go func() { for { - status = true + status = 1 cl.Start() - status = false - if closeBefore { + status = 0 + if closeBefore == 1 { return } time.Sleep(time.Second * 5) } }() - return true + return 1 } //export GetClientStatus -func GetClientStatus() bool { +func GetClientStatus() int { return status } //export CloseClient func CloseClient() { + closeBefore = 1 cl.Close() - closeBefore = true } func main() { From d66f8724e9209f4f58252f39689d004afb320f6a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Dec 2019 18:40:29 +0800 Subject: [PATCH 55/58] update build.sh --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index c5b5f4e8..beb80606 100644 --- a/build.sh +++ b/build.sh @@ -1,8 +1,8 @@ #/bash/sh sudo apt-get install gcc-mingw-w64-i686 -env GOOS=windows GOARCH=386 CGO_ENABLED=1 CC=i686-w64-mingw32-gcc go build -buildmode=c-shared -o npc_sdk.dll cmd/npc/sdk.go -tar -czvf npc_sdk.tar.gz -xvf npc_sdk.dll npc_sdk.h +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 +tar -czvf npc_sdk.tar.gz npc_sdk.dll npc_sdk.h wget https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz tar -xvf upx-3.95-amd64_linux.tar.xz From f365973bb9fbdbc8d3b41cde2e2cc6607bedf527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 21:07:19 +0800 Subject: [PATCH 56/58] update build.sh --- build.bash | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 build.bash diff --git a/build.bash b/build.bash new file mode 100755 index 00000000..b7296cac --- /dev/null +++ b/build.bash @@ -0,0 +1,136 @@ +#!/bin/bash +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_amd64_client.tar.gz npc conf/npc.conf + +CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_386_client.tar.gz npc conf/npc.conf + +CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf freebsd_386_client.tar.gz npc conf/npc.conf + +CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf freebsd_amd64_client.tar.gz npc conf/npc.conf + +CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf freebsd_arm_client.tar.gz npc conf/npc.conf + +CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_arm_client.tar.gz npc conf/npc.conf + + +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_arm64_client.tar.gz npc conf/npc.conf + + +CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_mips64_client.tar.gz npc conf/npc.conf + + +CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_mips64le_client.tar.gz npc conf/npc.conf + + +CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_mipsle_client.tar.gz npc conf/npc.conf + + +CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf linux_mips_client.tar.gz npc conf/npc.conf + + +CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf win_386_client.tar.gz npc.exe conf/npc.conf + + +CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf win_amd64_client.tar.gz npc.exe conf/npc.conf + + +CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/npc/npc.go +upx npc +tar -czvf macos_client.tar.gz npc conf/npc.conf + + + +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + +CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + +CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_arm_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_arm64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf freebsd_arm_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf freebsd_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf freebsd_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + +CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_mips_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_mips64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_mips64le_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf linux_mipsle_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + + +CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps +tar -czvf macos_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps + + +CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps.exe +tar -czvf win_amd64_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe + + +CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "-s -w -extldflags -static -extldflags -static" ./cmd/nps/nps.go +upx nps.exe +tar -czvf win_386_server.tar.gz conf/nps.conf conf/tasks.json conf/clients.json conf/hosts.json conf/server.key conf/server.pem web/views web/static nps.exe + From e33b0be3b8a0a9f419d6c9ca7b4599f0af4540c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B2=B3?= Date: Wed, 4 Dec 2019 21:35:43 +0800 Subject: [PATCH 57/58] update build.sh --- .travis.yml | 2 +- build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a0f65825..f076c5cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ deploy: - win_386_server.tar.gz - win_amd64_client.tar.gz - win_amd64_server.tar.gz - - npc_$VERSION.spk + - npc_syno.spk - npc_sdk.tar.gz on: tags: true diff --git a/build.sh b/build.sh index beb80606..1df36fba 100644 --- a/build.sh +++ b/build.sh @@ -167,7 +167,7 @@ git clone https://github.com/cnlh/spksrc.git ~/spksrc mkdir ~/spksrc/nps && cp -rf ./* ~/spksrc/nps/ docker run -itd --name spksrc --env VERSION=$VERSION -v ~/spksrc:/spksrc synocommunity/spksrc /bin/bash docker exec -it spksrc /bin/bash -c 'cd /spksrc && make setup && cd /spksrc/spk/npc && make' -cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_$VERSION.spk +cp ~/spksrc/packages/npc_noarch-all_$VERSION-1.spk ./npc_syno.spk echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin From c7e7d2bac65d5d3f8eb4a4462fef0f49742ce687 Mon Sep 17 00:00:00 2001 From: ffdfgdfg Date: Thu, 5 Dec 2019 22:43:22 +0800 Subject: [PATCH 58/58] Update README.md ci status image --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b11bbd1f..9d679391 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,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) nps是一款轻量级、高性能、功能强大的**内网穿透**代理服务器。目前支持**tcp、udp流量转发**,可支持任何**tcp、udp**上层协议(访问内网网站、本地支付接口调试、ssh访问、远程桌面,内网dns解析等等……),此外还**支持内网http代理、内网socks5代理**、**p2p等**,并带有功能强大的web管理端。