Make clients identify themselves against server
prep for potential later async auth system. Wanted to get this into the 2.3 client update.
This commit is contained in:
parent
dac3c0ca29
commit
d25973989a
|
@ -9,7 +9,7 @@ import functools
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import socket
|
import socket
|
||||||
import uuid
|
|
||||||
from random import randrange
|
from random import randrange
|
||||||
|
|
||||||
from Utils import get_item_name_from_id, get_location_name_from_address, ReceivedItem
|
from Utils import get_item_name_from_id, get_location_name_from_address, ReceivedItem
|
||||||
|
@ -888,7 +888,7 @@ async def server_auth(ctx: Context, password_requested):
|
||||||
ctx.auth = ctx.rom.copy()
|
ctx.auth = ctx.rom.copy()
|
||||||
await ctx.send_msgs([['Connect', {
|
await ctx.send_msgs([['Connect', {
|
||||||
'password': ctx.password, 'rom': ctx.auth, 'version': Utils._version_tuple, 'tags': get_tags(ctx),
|
'password': ctx.password, 'rom': ctx.auth, 'version': Utils._version_tuple, 'tags': get_tags(ctx),
|
||||||
'uuid': uuid.getnode()
|
'uuid': Utils.get_unique_identifier()
|
||||||
}]])
|
}]])
|
||||||
|
|
||||||
|
|
||||||
|
|
15
Utils.py
15
Utils.py
|
@ -226,6 +226,9 @@ def persistent_store(category, key, value):
|
||||||
|
|
||||||
|
|
||||||
def persistent_load() -> typing.Dict[dict]:
|
def persistent_load() -> typing.Dict[dict]:
|
||||||
|
storage = getattr(persistent_load, "storage", None)
|
||||||
|
if storage:
|
||||||
|
return storage
|
||||||
path = local_path("_persistent_storage.yaml")
|
path = local_path("_persistent_storage.yaml")
|
||||||
storage: dict = {}
|
storage: dict = {}
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
|
@ -237,6 +240,7 @@ def persistent_load() -> typing.Dict[dict]:
|
||||||
logging.debug(f"Could not read store: {e}")
|
logging.debug(f"Could not read store: {e}")
|
||||||
if storage is None:
|
if storage is None:
|
||||||
storage = {}
|
storage = {}
|
||||||
|
persistent_load.storage = storage
|
||||||
return storage
|
return storage
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,3 +248,14 @@ class ReceivedItem(typing.NamedTuple):
|
||||||
item: int
|
item: int
|
||||||
location: int
|
location: int
|
||||||
player: int
|
player: int
|
||||||
|
|
||||||
|
|
||||||
|
def get_unique_identifier():
|
||||||
|
uuid = persistent_load().get("client", {}).get("uuid", None)
|
||||||
|
if uuid:
|
||||||
|
return uuid
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
uuid = uuid.getnode()
|
||||||
|
persistent_store("client", "uuid", uuid)
|
||||||
|
return uuid
|
||||||
|
|
Loading…
Reference in New Issue