Skip to content

Commit bd7a8ee

Browse files
Fix Epic Online Services (EOS) Protocol
Resolve the issue with the Epic Online Services (EOS) Protocol domain name not functioning properly
1 parent 33570b3 commit bd7a8ee

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

opengsq/protocols/eos.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from opengsq.exceptions import ServerNotFoundException
66
from opengsq.protocol_base import ProtocolBase
7+
from opengsq.socket_async import SocketAsync
78

89

910
class EOS(ProtocolBase):
@@ -59,17 +60,20 @@ async def _get_matchmaking(self, data: dict):
5960
return data
6061

6162
async def get_info(self) -> dict:
63+
address = await SocketAsync.gethostbyname(self._host)
64+
address_bound_port = f':{self._port}'
65+
6266
data = await self._get_matchmaking({
6367
"criteria": [
6468
{
6569
"key": "attributes.ADDRESS_s",
6670
"op": "EQUAL",
67-
"value": self._host
71+
"value": address
6872
},
6973
{
7074
"key": "attributes.ADDRESSBOUND_s",
7175
"op": "CONTAINS",
72-
"value": f':{self._port}'
76+
"value": address_bound_port
7377
},
7478
]
7579
})

opengsq/protocols/samp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async def get_rules(self):
5050

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

opengsq/protocols/scum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def get_status(self, master_servers: list = None) -> dict:
1616
you may need to cache the master servers if you had
1717
lots of servers to query.
1818
"""
19-
ip = SocketAsync.gethostbyname(self._host)
19+
ip = await SocketAsync.gethostbyname(self._host)
2020

2121
if master_servers is None:
2222
master_servers = await Scum.query_master_servers()

opengsq/protocols/vcmp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def get_players(self):
4141

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

opengsq/socket_async.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import asyncio
2+
from concurrent.futures import ThreadPoolExecutor
23
import socket
34
from enum import Enum, auto
45

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

2021
@staticmethod
21-
def gethostbyname(hostname: str) -> str:
22-
return socket.gethostbyname(hostname)
22+
async def gethostbyname(hostname: str):
23+
return await asyncio.get_running_loop().run_in_executor(None, socket.gethostbyname, hostname)
2324

2425
def __init__(self, kind: SocketKind = SocketKind.SOCK_DGRAM):
2526
self.__timeout = None

opengsq/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.2.2'
1+
__version__ = '2.2.3'

0 commit comments

Comments
 (0)