mirror of
https://github.com/lucheng0127/virtuallan.git
synced 2025-12-24 13:17:50 +08:00
Support build windows client. Use in windows, make sure you have been install tap-windows properly. After launch, the windows client will now listen udp multicast so if you need to config routes by yourself
28 lines
523 B
Go
28 lines
523 B
Go
package server
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strings"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func HandleKeepalive(ipAddr, raddr string, svc *Server) error {
|
|
c, ok := UPool[raddr]
|
|
if !ok {
|
|
return errors.New("unauthed client")
|
|
}
|
|
|
|
log.Debugf("handle keepalive pkt for %s with ip %s", raddr, ipAddr)
|
|
|
|
if c.IP.String() != strings.Split(ipAddr, "/")[0] {
|
|
return fmt.Errorf("client %s ip should be %s, wrong ip %s in keepalive pkt", c.RAddr.String(), c.IP.String(), ipAddr)
|
|
}
|
|
|
|
// Heartbeat
|
|
c.Beat <- "ok"
|
|
|
|
return nil
|
|
}
|