Browse Source

Server code

master
Bottersnike 12 months ago
parent
commit
c84d8f35f6
  1. 7
      eaapi/const.py
  2. 4
      eaapi/crypt.py
  3. 6
      eaapi/decoder.py
  4. 6
      eaapi/encoder.py
  5. 8
      eaapi/node.py
  6. 1
      eaapi/server
  7. 1
      setup.py

7
eaapi/const.py

@ -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"

4
eaapi/crypt.py

@ -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):

6
eaapi/decoder.py

@ -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()

6
eaapi/encoder.py

@ -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()

8
eaapi/node.py

@ -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

@ -0,0 +1 @@
Subproject commit 4b0e64341fa7c7aa2db4b57b53283308997fede7

1
setup.py

@ -3,4 +3,5 @@ from distutils.core import setup
setup(
name="eaapi",
packages=["eaapi"],
install_requires=open("requirements.txt").read().split("\n"),
)

Loading…
Cancel
Save