Skip to content

Commit

Permalink
Fix Epic Online Services (EOS) Protocol
Browse files Browse the repository at this point in the history
Resolve the issue with the Epic Online Services (EOS) Protocol domain name not functioning properly
  • Loading branch information
BattlefieldDuck committed Nov 20, 2023
1 parent 33570b3 commit bd7a8ee
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
8 changes: 6 additions & 2 deletions opengsq/protocols/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from opengsq.exceptions import ServerNotFoundException
from opengsq.protocol_base import ProtocolBase
from opengsq.socket_async import SocketAsync


class EOS(ProtocolBase):
Expand Down Expand Up @@ -59,17 +60,20 @@ async def _get_matchmaking(self, data: dict):
return data

async def get_info(self) -> dict:
address = await SocketAsync.gethostbyname(self._host)
address_bound_port = f':{self._port}'

data = await self._get_matchmaking({
"criteria": [
{
"key": "attributes.ADDRESS_s",
"op": "EQUAL",
"value": self._host
"value": address
},
{
"key": "attributes.ADDRESSBOUND_s",
"op": "CONTAINS",
"value": f':{self._port}'
"value": address_bound_port
},
]
})
Expand Down
2 changes: 1 addition & 1 deletion opengsq/protocols/samp.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def get_rules(self):

async def __send_and_receive(self, data: bytes):
# Format the address
host = SocketAsync.gethostbyname(self._host)
host = await SocketAsync.gethostbyname(self._host)
packet_header = struct.pack('BBBBH', *map(int, host.split('.') + [self._port])) + data
request = self._request_header + packet_header

Expand Down
2 changes: 1 addition & 1 deletion opengsq/protocols/scum.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def get_status(self, master_servers: list = None) -> dict:
you may need to cache the master servers if you had
lots of servers to query.
"""
ip = SocketAsync.gethostbyname(self._host)
ip = await SocketAsync.gethostbyname(self._host)

if master_servers is None:
master_servers = await Scum.query_master_servers()
Expand Down
2 changes: 1 addition & 1 deletion opengsq/protocols/vcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def get_players(self):

async def __send_and_receive(self, data: bytes):
# Format the address
host = SocketAsync.gethostbyname(self._host)
host = await SocketAsync.gethostbyname(self._host)
packet_header = struct.pack('BBBBH', *map(int, host.split('.') + [self._port])) + data
request = self._request_header + packet_header

Expand Down
5 changes: 3 additions & 2 deletions opengsq/socket_async.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
from concurrent.futures import ThreadPoolExecutor
import socket
from enum import Enum, auto

Expand All @@ -18,8 +19,8 @@ async def send_and_receive(host: str, port: int, timeout: float, data: bytes, ki
return await sock.recv()

@staticmethod
def gethostbyname(hostname: str) -> str:
return socket.gethostbyname(hostname)
async def gethostbyname(hostname: str):
return await asyncio.get_running_loop().run_in_executor(None, socket.gethostbyname, hostname)

def __init__(self, kind: SocketKind = SocketKind.SOCK_DGRAM):
self.__timeout = None
Expand Down
2 changes: 1 addition & 1 deletion opengsq/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.2.2'
__version__ = '2.2.3'

0 comments on commit bd7a8ee

Please sign in to comment.