mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
[fix] 修复tcp异常断开,云端认证还是true
This commit is contained in:
1
go.mod
1
go.mod
@@ -17,7 +17,6 @@ require (
|
||||
github.com/gin-gonic/gin v1.7.4
|
||||
github.com/go-openapi/spec v0.20.6
|
||||
github.com/go-playground/validator/v10 v10.8.0
|
||||
github.com/go-redis/redis v6.15.9+incompatible
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/golang-queue/queue v0.2.0
|
||||
github.com/google/uuid v1.3.0
|
||||
|
||||
2
go.sum
2
go.sum
@@ -122,8 +122,6 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl
|
||||
github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4=
|
||||
github.com/go-playground/validator/v10 v10.8.0 h1:1kAa0fCrnpv+QYdkdcRzrRM7AyYs5o8+jZdJCz9xj6k=
|
||||
github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk=
|
||||
github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGKFlFgcHWWmHQjg=
|
||||
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
||||
|
||||
@@ -28,7 +28,7 @@ func (rpc RpcRequest) RequestCmd(deviceId, rpcPayload string) error {
|
||||
topic := fmt.Sprintf(RpcReqTopic, rpc.RequestId)
|
||||
value, ok := Session.Load(deviceId)
|
||||
if !ok {
|
||||
return errors.New("为获取到设备的MQTT连接")
|
||||
return errors.New("未获取到设备的MQTT连接")
|
||||
}
|
||||
return Publish(topic, value.(string), rpcPayload)
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ func handleConnection(conn *net.TCPConn, hs *hook_message_work.HookService) {
|
||||
buf := make([]byte, 128)
|
||||
n, err := conn.Read(buf)
|
||||
if err != nil {
|
||||
isAuth = false
|
||||
return
|
||||
}
|
||||
|
||||
@@ -125,4 +126,4 @@ func (hhs *HookTcpService) SendBytes(msg []byte) error {
|
||||
func isHex(str string) bool {
|
||||
_, err := hex.DecodeString(str)
|
||||
return err == nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package starter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"pandax/kit/logger"
|
||||
|
||||
"github.com/go-redis/redis"
|
||||
)
|
||||
|
||||
func ConnRedis(host, password string, db, port int) *redis.Client {
|
||||
// 设置redis客户端
|
||||
logger.Log.Infof("连接redis [%s:%d]", host, port)
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", host, port),
|
||||
Password: password, // no password set
|
||||
DB: db, // use default DB
|
||||
})
|
||||
// 测试连接
|
||||
_, e := rdb.Ping().Result()
|
||||
if e != nil {
|
||||
logger.Log.Panic(fmt.Sprintf("连接redis失败! [%s:%d]", host, port))
|
||||
}
|
||||
return rdb
|
||||
}
|
||||
Reference in New Issue
Block a user