mirror of
https://github.com/lwch/natpass.git
synced 2024-04-21 12:41:54 +00:00
修改握手时的签名算法
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package global
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/lwch/natpass/code/hash"
|
||||
"github.com/lwch/natpass/code/utils"
|
||||
"github.com/lwch/runtime"
|
||||
"github.com/lwch/yaml"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
// Configure server configure
|
||||
type Configure struct {
|
||||
Listen uint16
|
||||
Enc [md5.Size]byte
|
||||
Hasher *hash.Hasher
|
||||
TLSKey string
|
||||
TLSCrt string
|
||||
ReadTimeout time.Duration
|
||||
@@ -51,7 +51,7 @@ func LoadConf(dir string) *Configure {
|
||||
}
|
||||
return &Configure{
|
||||
Listen: cfg.Listen,
|
||||
Enc: md5.Sum([]byte(cfg.Secret)),
|
||||
Hasher: hash.New(cfg.Secret, 60),
|
||||
TLSKey: cfg.TLS.Key,
|
||||
TLSCrt: cfg.TLS.Crt,
|
||||
ReadTimeout: cfg.Link.ReadTimeout,
|
||||
|
||||
@@ -91,7 +91,7 @@ func (h *Handler) readHandshake(c *network.Conn) (string, error) {
|
||||
if msg.GetXType() != network.Msg_handshake {
|
||||
return "", errNotHandshake
|
||||
}
|
||||
n := bytes.Compare(msg.GetHsp().GetEnc(), h.cfg.Enc[:])
|
||||
n := bytes.Compare(msg.GetHsp().GetEnc(), h.cfg.Hasher.Hash())
|
||||
if n != 0 {
|
||||
return "", errInvalidHandshake
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user