From c5a11b858f253de6235e9696fa3b64e79b3f5eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 15 Oct 2023 01:17:41 +0900 Subject: [PATCH] fix tls --- bot.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bot.go b/bot.go index e12cd7e..46da3c5 100644 --- a/bot.go +++ b/bot.go @@ -1,6 +1,7 @@ package nano import ( + "crypto/tls" "encoding/base64" "encoding/json" "net" @@ -28,15 +29,15 @@ type Bot struct { Intents uint32 // Intents 欲接收的事件 Properties json.RawMessage // Properties 一些环境变量, 目前没用 - gateway string // gateway 获得的网关 - shard [2]byte // shard 分片 - seq uint32 - handlers map[string]GeneralHandleType // handlers 方便调用的 handler - mu sync.Mutex // 写锁 - conn *websocket.Conn + gateway string // gateway 获得的网关 + shard [2]byte // shard 分片 + seq uint32 // seq 最新的 s + handlers map[string]GeneralHandleType // handlers 方便调用的 handler + mu sync.Mutex // 写锁 + conn *websocket.Conn // conn 目前的 wss 连接 + heartbeat uint32 // heartbeat 心跳周期, 单位毫秒 - ready EventReady - heartbeat uint32 // heartbeat 心跳周期, 单位毫秒 + ready EventReady // } // Init 初始化, 只需执行一次 @@ -90,7 +91,7 @@ func (bot *Bot) Connect() { addr = BytesToString(filepath) } } - return net.Dial(network, addr) // support unix socket transport + return tls.Dial(network, addr, websocket.DefaultDialer.TLSClientConfig) // support unix socket transport }, } for {