mirror of
https://gitea.tendokyu.moe/eamuse/eaapi.git
synced 2024-11-23 22:10:58 +01:00
Server code
This commit is contained in:
parent
e8ccee4a10
commit
c84d8f35f6
@ -149,3 +149,10 @@ class Type(enum.Enum):
|
||||
if i.value.id == value & ARRAY_MASK:
|
||||
return i
|
||||
raise ValueError(f"Unknown node type {value}")
|
||||
|
||||
|
||||
class ServicesMode(enum.Enum):
|
||||
Operation = "operation"
|
||||
Debug = "debug"
|
||||
Test = "test"
|
||||
Factory = "factory"
|
||||
|
@ -34,8 +34,8 @@ def validate_key(info):
|
||||
return seconds, rng
|
||||
|
||||
|
||||
def get_key():
|
||||
return f"1-{int(time.time()):08x}-{(next(prng) & 0xffff):04x}"
|
||||
def get_key(prng_=None):
|
||||
return f"1-{int(time.time()):08x}-{(next(prng_ or prng) & 0xffff):04x}"
|
||||
|
||||
|
||||
def ea_symmetric_crypt(data, info):
|
||||
|
@ -186,6 +186,12 @@ class Decoder:
|
||||
return walk(tree)
|
||||
|
||||
def unpack(self):
|
||||
try:
|
||||
return self._unpack()
|
||||
except struct.error as e:
|
||||
raise DecodeError(e)
|
||||
|
||||
def _unpack(self):
|
||||
if self.is_xml_string:
|
||||
return self._read_xml_string()
|
||||
|
||||
|
@ -124,6 +124,12 @@ class Encoder:
|
||||
self.stream.write(struct.pack(">BBBB", 0xA0, contents, self.encoding, enc_comp))
|
||||
|
||||
def pack(self, node):
|
||||
try:
|
||||
return self._pack(node)
|
||||
except struct.error as e:
|
||||
return EncodeError(e)
|
||||
|
||||
def _pack(self, node):
|
||||
self._compressed = node.can_compress # Opportunically compress if we can
|
||||
self._write_magic()
|
||||
|
||||
|
@ -68,6 +68,14 @@ class XMLNode:
|
||||
for i in self.children:
|
||||
yield i
|
||||
|
||||
def get(self, name, default=None):
|
||||
try:
|
||||
return self[name]
|
||||
except IndexError:
|
||||
return default
|
||||
except KeyError:
|
||||
return default
|
||||
|
||||
def __getitem__(self, name):
|
||||
if isinstance(name, int):
|
||||
return self.children[name]
|
||||
|
1
eaapi/server
Submodule
1
eaapi/server
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 4b0e64341fa7c7aa2db4b57b53283308997fede7
|
Loading…
Reference in New Issue
Block a user