Skip to content

Commit

Permalink
V1.2.3 修复某个RCON连接可能出现的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
hualuoo committed Feb 2, 2024
1 parent b3a4199 commit d78d000
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions utils/PalRcon/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@ def __init__(self, rcon_addr, rcon_port, rcon_password):
self.rcon_password = rcon_password

def send_command(self, command):

try:
with Client(host=self.rcon_addr,
port=self.rcon_port,
passwd=self.rcon_password,
timeout=1) as pal_client:
response = pal_client.run(command)
return True, response


except utils.PalRcon.rcon.exceptions.WrongPassword:
return False, "RCON 密码错误,请检查密码是否正确"
except utils.PalRcon.rcon.exceptions.SessionTimeout:
return False, "会话超时,请检查服务端是否正常开启"
except utils.PalRcon.rcon.exceptions.EmptyResponse:
return False, "回复为空"
except utils.PalRcon.rcon.exceptions.UserAbort:
return False, "用户中断"
except TimeoutError:
return False, "连接超时,请检查服务端是否正常开启"
except ConnectionResetError:
return False, "远程主机强迫关闭了一个现有的连接,请重连RCON"
except:
return False, "未知错误,请联系开发人员"

0 comments on commit d78d000

Please sign in to comment.