优化数据

This commit is contained in:
bjdgyc
2022-09-30 16:03:43 +08:00
parent c2642bc183
commit e03bd60b1d
8 changed files with 27 additions and 15 deletions

View File

@@ -1,9 +1,11 @@
package handler
import (
"crypto/md5"
"encoding/xml"
"fmt"
"io"
"net"
"net/http"
"strings"
"text/template"
@@ -87,6 +89,15 @@ func LinkAuth(w http.ResponseWriter, r *http.Request) {
sess.Group = cr.GroupSelect
sess.MacAddr = strings.ToLower(cr.MacAddressList.MacAddress)
sess.UniqueIdGlobal = cr.DeviceId.UniqueIdGlobal
// 获取客户端mac地址
macHw, err := net.ParseMAC(sess.MacAddr)
if err != nil {
sum := md5.Sum([]byte(sess.UniqueIdGlobal))
macHw = sum[0:5] // 5个byte
macHw = append([]byte{0x02}, macHw...)
sess.MacAddr = macHw.String()
}
sess.MacHw = macHw
other := &dbdata.SettingOther{}
_ = dbdata.SettingGet(other)
rd := RequestData{SessionId: sess.Sid, SessionToken: sess.Sid + "@" + sess.Token,

View File

@@ -12,6 +12,7 @@ import (
)
func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSession) {
base.Debug("LinkCstp connect ip:", cSess.IpAddr, "user:", cSess.Username, "rip:", conn.RemoteAddr())
defer func() {
base.Debug("LinkCstp return", cSess.IpAddr)
_ = conn.Close()

View File

@@ -10,7 +10,7 @@ import (
)
func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
base.Debug("LinkDtls connect ip:", cSess.IpAddr, "udp-rip:", conn.RemoteAddr())
base.Debug("LinkDtls connect ip:", cSess.IpAddr, "user:", cSess.Username, "udp-rip:", conn.RemoteAddr())
dSess := cSess.NewDtlsConn()
if dSess == nil {
// 创建失败,直接关闭链接

0
server/handler/pool.go Executable file → Normal file
View File