Skip to content

Commit

Permalink
Merge pull request #328 from cnlh/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ffdfgdfg authored Dec 24, 2019
2 parents a2f5665 + b138447 commit 346cb58
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 17 deletions.
1 change: 1 addition & 0 deletions build.android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

cd /go
go get -u fyne.io/fyne fyne.io/fyne/cmd/fyne

mkdir -p /go/src/github.com/cnlh/nps
cp -R /app/* /go/src/github.com/cnlh/nps
cd /go/src/github.com/cnlh/nps
Expand Down
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.25.2
export VERSION=0.25.3

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
12 changes: 8 additions & 4 deletions cmd/nps/nps.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

var (
level string
level string
)

func main() {
Expand Down Expand Up @@ -57,6 +57,12 @@ func main() {
Description: "一款轻量级、功能强大的内网穿透代理服务器。支持tcp、udp流量转发,支持内网http代理、内网socks5代理,同时支持snappy压缩、站点保护、加密传输、多路复用、header修改等。支持web图形化管理,集成多用户模式。",
Option: options,
}
svcConfig.Arguments = append(svcConfig.Arguments, "service")
if len(os.Args) > 1 && os.Args[1] == "service" {
logs.SetLogger(logs.AdapterFile, `{"level":`+level+`,"filename":"`+logPath+`","daily":false,"maxlines":100000,"color":true}`)
} else {
logs.SetLogger(logs.AdapterConsole, `{"level":`+level+`,"color":true}`)
}
if !common.IsWindows() {
svcConfig.Dependencies = []string{
"Requires=network.target",
Expand All @@ -69,8 +75,7 @@ func main() {
logs.Error(err)
return
}
logs.SetLogger(logs.AdapterConsole, `{"level":`+level+`,"color":true}`)
if len(os.Args) > 1 {
if len(os.Args) > 1 && os.Args[1] != "service" {
switch os.Args[1] {
case "reload":
daemon.InitDaemon("nps", common.GetRunPath(), common.GetTmpPath())
Expand All @@ -93,7 +98,6 @@ func main() {
}
return
case "start", "restart", "stop", "uninstall":
logs.SetLogger(logs.AdapterFile, `{"level":`+level+`,"filename":"`+logPath+`","daily":false,"maxlines":100000,"color":true}`)
err := service.Control(s, os.Args[1])
if err != nil {
logs.Error("Valid actions: %q\n", service.ControlAction, err.Error())
Expand Down
3 changes: 3 additions & 0 deletions docs/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
## 热更新支持
对于绝大多数配置,在web管理中的修改将实时使用,无需重启客户端或者服务端

## web端保护
在一分钟内,如果密码错误次数超过10次,该ip在一分钟内将不能再次登陆。

## 客户端地址显示
在web管理中将显示客户端的连接地址

Expand Down
2 changes: 1 addition & 1 deletion docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

停止和重启可用,stop和restart

**如果发现没有启动成功,可以使用`nps(.exe) debug`运行调试,或查看日志**(Windows日志文件位于当前运行目录下,linux和darwin位于/var/log/nps.log)
**如果发现没有启动成功,可以使用`nps(.exe) stop`,然后运行`nps.(exe)`运行调试,或查看日志**(Windows日志文件位于当前运行目录下,linux和darwin位于/var/log/nps.log)
- 访问服务端ip:web服务端口(默认为8080)
- 使用用户名和密码登陆(默认admin/123,正式使用一定要更改)
- 创建客户端
Expand Down
4 changes: 2 additions & 2 deletions docs/use.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
## 无配置文件模式
此模式的各种配置在服务端web管理中完成,客户端除运行一条命令外无需任何其他设置
```
./npc -debug=true -server=ip:port -vkey=web界面中显示的密钥
./npc -server=ip:port -vkey=web界面中显示的密钥
```
## 注册到系统服务
## 注册到系统服务(开机启动、守护进程)
对于linux、darwin
- 注册:`sudo ./npc install 其他参数(例如-server=xx -vkey=xx或者-config=xxx)`
- 启动:`sudo npc start`
Expand Down
37 changes: 37 additions & 0 deletions gui/npc/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="0.25.3"
package="org.nps.client"
platformBuildVersionCode="15"
platformBuildVersionName="4.0.4-1406430">

<uses-permission
android:name="android.permission.INTERNET"/>

<application
android:label="Npc"
android:debuggable="true">

<activity
android:label="Npc"
android:name="org.golang.app.GoNativeActivity"
android:configChanges="0xa0">

<meta-data
android:name="android.app.lib_name"
android:value="npc"/>

<intent-filter>

<action
android:name="android.intent.action.MAIN"/>

<category
android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

5 changes: 3 additions & 2 deletions lib/mux/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Mux struct {
func NewMux(c net.Conn, connType string) *Mux {
//c.(*net.TCPConn).SetReadBuffer(0)
//c.(*net.TCPConn).SetWriteBuffer(0)
_ = c.SetDeadline(time.Time{})
m := &Mux{
conn: c,
connMap: NewConnMap(),
Expand Down Expand Up @@ -173,7 +174,7 @@ func (s *Mux) ping() {
s.sendInfo(common.MUX_PING_FLAG, common.MUX_PING, now)
// send the ping flag and get the latency first
ticker := time.NewTicker(time.Second * 5)
defer ticker.Stop()
defer ticker.Stop()
for {
if s.IsClose {
break
Expand All @@ -198,7 +199,7 @@ func (s *Mux) ping() {
}
atomic.AddUint32(&s.pingOk, 1)
}
return
return
}()
}

Expand Down
2 changes: 1 addition & 1 deletion lib/version/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package version

const VERSION = "0.25.2"
const VERSION = "0.25.3"

// Compulsory minimum version, Minimum downward compatibility to this version
func GetVersion() string {
Expand Down
2 changes: 1 addition & 1 deletion web/views/client/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h3 class="ibox-title">add client</h3>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-success" href="#" id="add"><i
<button class="btn btn-success" type="button" id="add"><i
class="fa fa-fw fa-lg fa-eye"></i>新增
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/views/client/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h3 class="ibox-title">add client</h3>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-success" href="#" id="add"><i
<button class="btn btn-success" type="button" id="add"><i
class="fa fa-fw fa-lg fa-eye"></i><span langtag="info-save">保存</span>
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/views/index/add.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h3 class="ibox-title">add</h3>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
&nbsp;<button class="btn btn-success" href="#" id="add"><i
&nbsp;<button class="btn btn-success" type="button" id="add"><i
class="fa fa-fw fa-lg fa-eye"></i>新增
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/views/index/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h3 class="ibox-title">编辑</h3>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<button class="btn btn-success" href="#" id="add"><i
<button class="btn btn-success" type="button" id="add"><i
class="fa fa-fw fa-lg fa-eye"></i><span langtag="info-save">保存</span>
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/views/index/hadd.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h3 class="ibox-title">add host</h3>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
&nbsp;<button class="btn btn-success" href="#" id="add"><i
&nbsp;<button class="btn btn-success" type="button" id="add"><i
class="fa fa-fw fa-lg fa-eye"></i>新增
</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/views/index/hedit.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ <h3 class="ibox-title">add host</h3>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
&nbsp;<button class="btn btn-success" href="#" id="add"><i
&nbsp;<button class="btn btn-success" type="button" id="add"><i
class="fa fa-fw fa-lg fa-eye"></i><span langtag="info-save">保存</span>
</button>
</div>
Expand Down

0 comments on commit 346cb58

Please sign in to comment.