TLS连接增加握手超时检查

This commit is contained in:
GoEdgeLab
2021-12-18 19:17:40 +08:00
parent 32c5639452
commit 413c0851a8
8 changed files with 60 additions and 17 deletions

View File

@@ -2,10 +2,12 @@ package nodes
import (
"crypto/rand"
"crypto/tls"
"fmt"
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
"github.com/TeaOSLab/EdgeNode/internal/utils"
"io"
"net"
"net/http"
"strconv"
"strings"
@@ -153,3 +155,12 @@ func httpRequestNextId() string {
// timestamp + requestId + nodeId
return strconv.FormatInt(unixTime, 10) + strconv.Itoa(int(atomic.AddInt32(&httpRequestId, 1))) + teaconst.NodeIdString
}
// 检查连接是否为TLS连接
func httpIsTLSConn(conn net.Conn) bool {
if conn == nil {
return false
}
_, ok := conn.(*tls.Conn)
return ok
}