Exemplo n.º 1
0
func RunClient(clientIpPort string, aserverIpPort string, secret int64) {
	clientConn := common.InitUDPConn(clientIpPort)
	aserverUDPAddr := common.ResolveUDPAddr(aserverIpPort)

	//Set 10 second timeout for ReadFromUDP
	clientConn.SetReadDeadline(time.Now().Add(10 * time.Second))

	//Retrieve nonce from aserver and compute MD5(nonce + secret)
	nonceMsg := RetrieveNonce(clientConn, &aserverUDPAddr)

	hashMsg := common.ComputeHashMessage(nonceMsg.Nonce, secret)

	//Retrieve GoalMessage from aserver
	goalMsg := RetrieveGoalMsg(clientConn, &aserverUDPAddr, hashMsg)
	fmt.Println("Received goal message from aserver: ", goalMsg)
}
Exemplo n.º 2
0
func isValidHashMessage(received common.HashMessage, storedNonce int64, secret int64) bool {
	expected := common.ComputeHashMessage(storedNonce, secret)
	return expected == received
}