diff --git a/services/wol/wol.go b/services/wol/wol.go index 88c963d..35b068d 100644 --- a/services/wol/wol.go +++ b/services/wol/wol.go @@ -9,6 +9,6 @@ func InitService() { Services = &Service{} } -func WakeUp(mac string) { +func WakeUp(mac string, port int) { } diff --git a/services/wol/wol_test.go b/services/wol/wol_test.go index c508933..9c19551 100644 --- a/services/wol/wol_test.go +++ b/services/wol/wol_test.go @@ -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 {