Skip to content
Snippets Groups Projects
Commit 7bdbe960 authored by Tumbul, Erwin's avatar Tumbul, Erwin
Browse files

Merge remote-tracking branch 'origin/main' into feature/android_client

parents 6c4eaa1d 9d8a4ae2
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ sys.path.insert(0, '../../shared/netcode') ...@@ -5,7 +5,7 @@ sys.path.insert(0, '../../shared/netcode')
import queue import queue
import grpc import grpc
from shared.netcode.netcode_pb2 import * from shared.netcode.netcode_pb2 import *
from shared.netcode.netcode_pb2_grpc import NotifierComStub from shared.netcode.netcode_pb2_grpc import NotifierCommunicationStub
usage = "Usage:\n- Sender:\n ./client.py 1\n- Receiver:\n ./client.py 0" usage = "Usage:\n- Sender:\n ./client.py 1\n- Receiver:\n ./client.py 0"
...@@ -38,10 +38,10 @@ if __name__ == "__main__": ...@@ -38,10 +38,10 @@ if __name__ == "__main__":
print("Error: Connection to server failed.") print("Error: Connection to server failed.")
exit(1) exit(1)
stub = NotifierComStub(channel) stub = NotifierCommunicationStub(channel)
if is_sender: if is_sender:
response = stub.OpenComm(OpenCommRequest(challenge=1)) response = stub.Open(OpenRequest(id_code=1))
print(response) print(response)
sendQueue = queue.SimpleQueue() sendQueue = queue.SimpleQueue()
...@@ -58,7 +58,7 @@ if __name__ == "__main__": ...@@ -58,7 +58,7 @@ if __name__ == "__main__":
sendQueue.put_nowait(Message(content=text)) sendQueue.put_nowait(Message(content=text))
else: else:
response = stub.AnswerComm(AnswerCommRequest(challenge=1)) response = stub.Answer(AnswerRequest(challenge=1))
print(response) print(response)
for message in stub.ReceiveMessage(Nothing()): for message in stub.ReceiveMessage(Nothing()):
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
1. Authenticate to the server and establish communication. 1. Authenticate to the server and establish communication.
1. A tells the server to open a communication. 1. A tells the server to open a communication.
2. A sends an id_code to the server. 2. A sends an id_code to the server.
3. A gets a comm_id from the server. 3. If someone answered with the same id_code, A gets a comm_id from the server.
2. B tells the server to answer A's communication request. 2. B tells the server to answer A's communication request.
1. B receives A's challenge. 2. B sends A's id_code to the server.
2. B answers the solution to the server. 3. The server checks if it matches and returns a comm_id to B.
3. The server checks the solution and accepts the communication establishment.
2. Generate and exchange an ephemeral key. 2. Generate and exchange an ephemeral key.
1. A and B generate a RSA key-pair.
3. Instantiate symmetric encryption using the ephemeral key. 3. Instantiate symmetric encryption using the ephemeral key.
4. Authenticate each other directly. 4. Authenticate each other directly.
5. (?) Check communication transcript (avoid malicious server). 5. (?) Check communication transcript (avoid malicious server).
...@@ -7,32 +7,33 @@ from shared.netcode.netcode_pb2 import * ...@@ -7,32 +7,33 @@ from shared.netcode.netcode_pb2 import *
from shared.netcode.netcode_pb2_grpc import * from shared.netcode.netcode_pb2_grpc import *
class NotifierService(NotifierComServicer): class NotifierService(NotifierCommunicationServicer):
def OpenComm(self, request, context): def Open(self, request, context):
# TODO: append id_code to list # TODO: append id_code to list
# TODO: wait for id_code answered # TODO: wait for id_code answered
# TODO: return comm_id # TODO: return comm_id
return CommResponse() return CommResponse()
def AnswerComm(self, request, context): def Answer(self, request, context):
# TODO: check if if_code can be answered # TODO: check if if_code can be answered
# TODO: return comm_id # TODO: return comm_id
return CommResponse() return CommResponse()
def ReceiveMessage(self, request, context): def ReceiveMessage(self, request, context):
# TODO: read comm_id and wait for messages # TODO: read comm_id and wait for messages
yield Message(content="test") yield Message(comm_id=-1, content="test")
def SendMessage(self, request_iterator, context): def SendMessage(self, request_iterator, context):
for msg in request_iterator: for msg in request_iterator:
# TODO: read comm_id and route message # TODO: read comm_id and route message
print(msg.comm_id)
print(msg.content) print(msg.content)
return Nothing() return Nothing()
if __name__ == "__main__": if __name__ == "__main__":
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
add_NotifierComServicer_to_server( add_NotifierCommunicationServicer_to_server(
NotifierService(), server) NotifierService(), server)
server.add_insecure_port('[::]:8080') server.add_insecure_port('[::]:8080')
server.start() server.start()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment