From a87772c77dc769ec03334a0673a16ba7de8ed4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=99=88=E8=8F=8C?= Date: Fri, 22 May 2020 13:51:46 +0800 Subject: [PATCH 1/3] update Stability update --- go.mod | 6 +++--- go.sum | 4 ++-- main.go | 22 +++++++++++++++------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index b227e5f..aaa07d9 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ -module DD-Go +module DDatHome-go -go 1.13 +go 1.14 require ( github.com/kardianos/service v1.0.0 github.com/stretchr/testify v1.5.1 // indirect github.com/tidwall/gjson v1.6.0 - golang.org/x/net v0.0.0-20200513185701-a91f0712d120 + golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 ) diff --git a/go.sum b/go.sum index bd62a81..90b9992 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0 github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= diff --git a/main.go b/main.go index a1a4448..6cc24f6 100644 --- a/main.go +++ b/main.go @@ -35,7 +35,7 @@ type GoResult struct { var ( ddName string = "DD" interval float64 = 500 - version string = "1.0.0" + version string = "1.0.1" ws *websocket.Conn ) @@ -70,8 +70,9 @@ func (p *program) run() { _, err := ws.Write([]byte("DDhttp")) if err != nil { _ = ws.Close() - if err := connect(); err != nil { - panic(err) + for connect() != nil { + _ = ws.Close() + time.Sleep(time.Millisecond * time.Duration(500)) } fmt.Println("reconnect success.") continue @@ -90,8 +91,16 @@ func (p *program) run() { if err != nil { res.Error = err.Error() } - json, _ := json.Marshal(res) - _, _ = ws.Write(json) + json, err := json.Marshal(res) + if err != nil { + fmt.Println("json error:", err) + continue + } + _, err = ws.Write(json) + if err != nil { + fmt.Println("error to write websocket:", err) + continue + } } } @@ -110,7 +119,6 @@ func main() { if err != nil { fmt.Println(err) } - if err != nil { fmt.Println(err) } @@ -155,7 +163,7 @@ func Processor(payload []byte) (string, string, error) { fmt.Println("task", key, "error:", err) return "", key, err } - //fmt.Println("task", key, "handled, url:", json.Get("data.url").Str) + fmt.Println("task", key, "handled, url:", json.Get("data.url").Str) return data, key, nil } From 45fef2712b3881211eb97e37a7d221e1e060ed3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=99=88=E8=8F=8C?= Date: Fri, 22 May 2020 13:53:00 +0800 Subject: [PATCH 2/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 730bafe..b52fee2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,8 @@ DD@Home in golang ./DDatHome uninstall ``` -#### 配置文件 +#### 配置文件 "config.json" +配置文件需要和主程序放在同一个目录下 ``` { "nickname":"DD", //这里是昵称 From 1dc6877652f06707affd6cbec76473b7ef8bab3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=99=88=E8=8F=8C?= Date: Fri, 22 May 2020 13:58:35 +0800 Subject: [PATCH 3/3] Add files via upload --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 6cc24f6..0decd42 100644 --- a/main.go +++ b/main.go @@ -163,7 +163,7 @@ func Processor(payload []byte) (string, string, error) { fmt.Println("task", key, "error:", err) return "", key, err } - fmt.Println("task", key, "handled, url:", json.Get("data.url").Str) + //fmt.Println("task", key, "handled, url:", json.Get("data.url").Str) return data, key, nil }