mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-27 01:07:10 +00:00
chore: hub/route module handle websocket itself
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package net
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"math/bits"
|
||||
)
|
||||
@@ -129,3 +131,13 @@ func MaskWebSocket(key uint32, b []byte) uint32 {
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
func GetWebSocketSecAccept(secKey string) string {
|
||||
const magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
|
||||
const nonceSize = 24 // base64.StdEncoding.EncodedLen(nonceKeySize)
|
||||
p := make([]byte, nonceSize+len(magic))
|
||||
copy(p[:nonceSize], secKey)
|
||||
copy(p[nonceSize:], magic)
|
||||
sum := sha1.Sum(p)
|
||||
return base64.StdEncoding.EncodeToString(sum[:])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user