29 lines
520 B
Go
29 lines
520 B
Go
|
package controller
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"goweb/wol"
|
||
|
"net"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/labstack/echo/v4"
|
||
|
)
|
||
|
|
||
|
func Get_send_start(c echo.Context) error {
|
||
|
mac := c.Param("mac")
|
||
|
println("开始发送wol 地址为" + mac)
|
||
|
a, err := net.Interfaces()
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
for i := range a {
|
||
|
if int(a[i].Flags) > 50 {
|
||
|
fmt.Printf("正在往 %s 接口发送\n", a[i].Name)
|
||
|
wol.WakespecifyInterfac(mac, "255.255.255.255", "9", a[i].Name)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return c.String(http.StatusOK, "已经发送请求MAC :"+mac)
|
||
|
|
||
|
}
|