added force_proto config, catch connection errors in ping
This commit is contained in:
parent
15c2fc09dc
commit
d5d1f8c036
1 changed files with 15 additions and 9 deletions
|
@ -205,6 +205,9 @@ class Treepuncher(
|
||||||
self.logger.info("Loaded session from %s", prev_auth.date)
|
self.logger.info("Loaded session from %s", prev_auth.date)
|
||||||
self.storage._set_state(state)
|
self.storage._set_state(state)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def cfg(self) -> ConfigParser:
|
||||||
|
return self.config["Treepuncher"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def playerName(self) -> str:
|
def playerName(self) -> str:
|
||||||
|
@ -256,19 +259,22 @@ class Treepuncher(
|
||||||
return module
|
return module
|
||||||
|
|
||||||
async def _work(self):
|
async def _work(self):
|
||||||
try:
|
if "force_proto" in self.cfg:
|
||||||
server_data = await self.info()
|
self.dispatcher.set_proto(self.cfg.getint('force_proto'))
|
||||||
if "version" in server_data and "protocol" in server_data["version"]:
|
else:
|
||||||
self.dispatcher.set_proto(server_data['version']['protocol'])
|
try:
|
||||||
except Exception:
|
server_data = await self.info()
|
||||||
return self.logger.exception("exception while pinging server")
|
if "version" in server_data and "protocol" in server_data["version"]:
|
||||||
|
self.dispatcher.set_proto(server_data['version']['protocol'])
|
||||||
|
except (ConnectionRefusedError, OSError) as e:
|
||||||
|
self.logger.error("Connection error : %s", str(e))
|
||||||
|
except Exception:
|
||||||
|
self.logger.exception("Unhandled exception while pinging server")
|
||||||
while self._processing:
|
while self._processing:
|
||||||
try:
|
try:
|
||||||
self.dispatcher.whitelist(self.callback_keys(filter=Packet))
|
self.dispatcher.whitelist(self.callback_keys(filter=Packet))
|
||||||
await self.join()
|
await self.join()
|
||||||
except ConnectionRefusedError:
|
except (ConnectionRefusedError, OSError) as e:
|
||||||
self.logger.error("Server rejected connection")
|
|
||||||
except OSError as e:
|
|
||||||
self.logger.error("Connection error : %s", str(e))
|
self.logger.error("Connection error : %s", str(e))
|
||||||
except AuthException as e:
|
except AuthException as e:
|
||||||
self.logger.error("Auth exception : [%s|%d] %s (%s)", e.endpoint, e.code, e.data, e.kwargs)
|
self.logger.error("Auth exception : [%s|%d] %s (%s)", e.endpoint, e.code, e.data, e.kwargs)
|
||||||
|
|
Loading…
Reference in a new issue