diff --git a/client/client_sniffer.go b/client/client_sniffer.go index 8dbba44..b4a5900 100644 --- a/client/client_sniffer.go +++ b/client/client_sniffer.go @@ -81,6 +81,7 @@ func checkPacket(packet gopacket.Packet) { //todoļ¼š udp connection can be reused. func call(msg []byte) { + //fixme when quickly send 2 packets it goes wrong! lAddr := &net.UDPAddr{IP: net.ParseIP("localhost"), Port: constant.MapSendPort} rAddr := &net.UDPAddr{IP: net.ParseIP(constant.ServerIp), Port: utils.GetMapPort()} conn, err := net.DialUDP("udp", lAddr, rAddr) diff --git a/main/cohvs_main.go b/main/cohvs_main.go index ad660e7..c04e316 100644 --- a/main/cohvs_main.go +++ b/main/cohvs_main.go @@ -22,7 +22,9 @@ func main() { for _, arg := range os.Args { if arg=="server"{ serverMode = true - break + } + if arg=="cson"{ + server.SwitchOnCompatiSymmetric() } if arg=="mock"{ fmt.Println("start up as mock mode") diff --git a/server/multi_server.go b/server/multi_server.go index 03c9164..67b4b1d 100644 --- a/server/multi_server.go +++ b/server/multi_server.go @@ -46,6 +46,7 @@ func GetMultiServer() *MultiServer { func (server *MultiServer) Work() { fmt.Println("Server start......") + fmt.Println("compatiSymmetric switch is ",compatiSymmetric) server.controller.work() diff --git a/server/v_player.go b/server/v_player.go index 7ae55a8..8902904 100644 --- a/server/v_player.go +++ b/server/v_player.go @@ -64,13 +64,30 @@ func (p *VPlayer) handle(msg []byte, raddr *net.UDPAddr) { func (controller *VPlayerController) findUser(addr *net.UDPAddr) *VPlayer { for i := range controller.players { p := &controller.players[i] - if p.playerAddr != nil && p.playerAddr.String() == addr.String() { + if ipUserCheck(p.playerAddr,addr){ return p } } return nil } +func SwitchOnCompatiSymmetric(){ + compatiSymmetric = true +} + +var compatiSymmetric = false + +func ipUserCheck(local *net.UDPAddr,remote *net.UDPAddr) bool{ + if local==nil{ + return false + } + if compatiSymmetric{ + return local.IP.String()==remote.IP.String() + }else{ + return local.String()==remote.String() + } +} + func (controller *VPlayerController) register(addr *net.UDPAddr) string{ for i := range controller.players { p := &controller.players[i]