Giter Club home page Giter Club logo

ex0's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ex0's Issues

Panic possible in server.processUDPPacket for packet.ClientCommand case.

Here's a panic that happened, causing the server to crash.

...
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
12411.588: Pl#0 ("Unnamed Player") joined team team Red at logic time 167.77/168 [server].
tcp conn ended with: conn prob
panic: runtime error: index out of range

goroutine 118 [running]:
main.(*server).processUDPPacket(0xc420074280, 0x84eba0, 0xc42040e2c0, 0xc4203ea3f0, 0x0, 0xc4203ea3f0, 0x0, 0x0)
	/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:296 +0xbb7
main.(*server).handleUDP(0xc420074280, 0xc4203ea3f0)
	/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:214 +0xbb
created by main.(*server).listenAndHandleTCPWebSocket.func1
	/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:165 +0x13e

It was on this line:

lastState := s.logic.playersState[c.PlayerID].LatestAuthed()

Needs investigation and fix.

(A guess is that the client disconnected at a bad time, just before the UDP packet arrived, and the c.PlayerID might've already been removed from s.logic.playersState.)

Here's the full log in case more context is needed.

Full Log
Started server.
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
8.671: Pl#0 ("Unnamed Player") joined team team Red at logic time 173.42/174 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
6698.009: Pl#0 ("Unnamed Player") joined team team Red at logic time 72.18/73 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
7164.806: Pl#1 ("Unnamed Player") joined team team Red at logic time 192.12/193 [server].
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
7167.124: Pl#0 ("Unnamed Player") joined team team Red at logic time 238.49/239 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
7248.113: Pl#0 ("Unnamed Player") joined team team Red at logic time 66.27/67 [server].
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
7248.224: Pl#1 ("Unnamed Player") joined team team Red at logic time 68.49/69 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
8200.226: Pl#0 ("Unnamed Player") joined team team Red at logic time 164.51/165 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
8821.455: Pl#0 ("Unnamed Player") joined team team Red at logic time 45.11/46 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
10402.472: Pl#0 ("Unnamed Player") joined team team Red at logic time 177.43/178 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
10972.247: Pl#0 ("Unnamed Player") joined team team Red at logic time 52.94/53 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
12148.710: Pl#0 ("Unnamed Player") joined team team Red at logic time 30.21/31 [server].
udp conn ended with: conn prob
tcp conn ended with: conn prob
(packet.JoinServerRequest)(packet.JoinServerRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(26),
		Type:   (packet.Type)(1),
	}),
	Version: (uint16)(1),
	Passphrase: ([16]uint8)([16]uint8{
		(uint8)(115),
		(uint8)(111),
		(uint8)(109),
		(uint8)(101),
		(uint8)(114),
		(uint8)(97),
		(uint8)(110),
		(uint8)(100),
		(uint8)(111),
		(uint8)(109),
		(uint8)(112),
		(uint8)(97),
		(uint8)(115),
		(uint8)(115),
		(uint8)(48),
		(uint8)(49),
	}),
	Signature: (uint64)(123),
})
(packet.Handshake)(packet.Handshake{
	UDPHeader: (packet.UDPHeader)(packet.UDPHeader{
		Type: (packet.Type)(100),
	}),
	Signature: (uint64)(123),
})
(packet.LocalPlayerInfo)(packet.LocalPlayerInfo{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(17),
		Type:   (packet.Type)(30),
	}),
	NameLength: (uint8)(14),
	Name: ([]uint8)([]uint8{
		(uint8)(85),
		(uint8)(110),
		(uint8)(110),
		(uint8)(97),
		(uint8)(109),
		(uint8)(101),
		(uint8)(100),
		(uint8)(32),
		(uint8)(80),
		(uint8)(108),
		(uint8)(97),
		(uint8)(121),
		(uint8)(101),
		(uint8)(114),
	}),
	CommandRate: (uint8)(20),
	UpdateRate:  (uint8)(20),
})
(packet.EnteredGameNotification)(packet.EnteredGameNotification{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(0),
		Type:   (packet.Type)(7),
	}),
})
(packet.JoinTeamRequest)(packet.JoinTeamRequest{
	TCPHeader: (packet.TCPHeader)(packet.TCPHeader{
		Length: (uint16)(1),
		Type:   (packet.Type)(27),
	}),
	PlayerNumber: (*uint8)(nil),
	Team:         (packet.Team)(0),
})
12411.588: Pl#0 ("Unnamed Player") joined team team Red at logic time 167.77/168 [server].
tcp conn ended with: conn prob
panic: runtime error: index out of range

goroutine 118 [running]:
main.(*server).processUDPPacket(0xc420074280, 0x84eba0, 0xc42040e2c0, 0xc4203ea3f0, 0x0, 0xc4203ea3f0, 0x0, 0x0)
	/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:296 +0xbb7
main.(*server).handleUDP(0xc420074280, 0xc4203ea3f0)
	/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:214 +0xbb
created by main.(*server).listenAndHandleTCPWebSocket.func1
	/home/dmitri/go/src/github.com/shurcooL/eX0/eX0-go/server.go:165 +0x13e

eX0-go/net.go: sendUDPPacketBytes: Investigate/confirm possible misuse of Read method.

@@ -94,6 +94,8 @@ func sendUDPPacketBytes(c *Connection, b []byte) error {
 func receiveUDPPacket(c *Connection) ([]byte, packet.UDPHeader, error) {
    var b [packet.MAX_UDP_SIZE]byte
    n, err := c.udp.Read(b[:])
+   // TODO: Use io.ReadFull or check b[n:] here? But it is UDP, so... Figure it out.
+   //       Maybe it's fine because it's Conn.Read, not io.Read?
    if err != nil {
        return nil, packet.UDPHeader{}, err
    }

Originally reported/found by @dominikh.

License?

Seen your comment on the 2d lightning HN article. This code is not really open source yet, though. You might consider putting a license here.

My suggestion is Apache or MIT license if you don't mind what others do with it, and GPLv3+ if you try to make others open their changes to your code as well.

Show some mistakes when I build the Project

Hi,I'm new in golang and learning you project,it's pretty interesting,but when I build you source code in project , it's show some mistakes such as like that:

# command-line-arguments
.\main.go:18: undefined: server
.\main.go:19: undefined: client
.\main.go:20: undefined: view
.\main.go:32: undefined: newClientNetwork
.\main.go:41: undefined: startClient
.\main.go:44: undefined: startServer
too many errors

I'm skilled in Unity'C# but not golang,Isn't I do something wrong?
My golang's version is 1.7
I'm looking forward to your reply.

How to get browser version up and running?

I saw the r/golang post about this project—thought this was super cool!

I was able to get the normal Go server/clients working just fine, however I'm brand new to GopherJS and was wondering how it is that the JS is meant to be generated and then run?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.