mirror of
https://gitee.com/shikong-sk/gofiber-study
synced 2025-02-23 15:22:14 +08:00
mac 校验
This commit is contained in:
parent
14054fc776
commit
6184e52b01
@ -9,6 +9,6 @@ func InitService() {
|
||||
Services = &Service{}
|
||||
}
|
||||
|
||||
func WakeUp(mac string) {
|
||||
func WakeUp(mac string, port int) {
|
||||
|
||||
}
|
||||
|
@ -4,10 +4,27 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRegExp(t *testing.T) {
|
||||
validateMac := func() func(mac string) bool {
|
||||
exp, _ := regexp.Compile("([0-9a-fA-F]{2}(-|:)?){5}([a-fA-F0-9]{2})")
|
||||
return func(mac string) bool {
|
||||
macLen := len(mac)
|
||||
return exp.MatchString(mac) && (macLen == 12 || macLen == 17)
|
||||
}
|
||||
}()
|
||||
|
||||
t.Logf("255.255.255.255 %t", validateMac("255.255.255.255"))
|
||||
t.Logf("FF:FF:FF:FF:FF:FF %t", validateMac("FF:FF:FF:FF:FF:FF"))
|
||||
t.Logf("00-E0-4C-84-50-EB %t", validateMac("00-E0-4C-84-50-EB"))
|
||||
t.Logf("00E04C8450EB %t", validateMac("00E04C8450EB"))
|
||||
t.Logf("00E04C8450EBA %t", validateMac("00E04C8450EBA"))
|
||||
}
|
||||
|
||||
func TestWol(t *testing.T) {
|
||||
udpAddr, err := net.ResolveUDPAddr("udp", "255.255.255.255:9")
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user