internal static Rcon Authorize(ConnectionInfo conInfo, string msg) { return(new QueryMasterBase().Invoke <Rcon>(() => { RconSource obj = new RconSource(conInfo); obj.socket = new TcpQuery(conInfo); byte[] recvData = new byte[50]; RconSrcPacket packet = new RconSrcPacket() { Body = msg, Id = (int)PacketId.ExecCmd, Type = (int)PacketType.Auth }; recvData = obj.socket.GetResponse(RconUtil.GetBytes(packet)); int header; try { header = BitConverter.ToInt32(recvData, 4); } catch (Exception e) { e.Data.Add("ReceivedData", recvData == null ? new byte[1] : recvData); throw; } if (header != -1) { return obj; } return obj; }, conInfo.Retries + 1, null, conInfo.ThrowExceptions)); }
public override bool GetControl(string pass) { ThrowIfDisposed(); bool isSuccess = false; Rcon = RconSource.CreateRconConnection(ConInfo, pass); if (Rcon != null) { isSuccess = true; } return(isSuccess); }
public override bool GetControl(string pass, bool useWebRcon) { ThrowIfDisposed(); bool isSuccess = false; Rcon = useWebRcon ? RconWeb.Authorize(ConInfo, pass) : RconSource.Authorize(ConInfo, pass); if (Rcon != null) { isSuccess = true; } return(isSuccess); }
internal static Rcon CreateRconConnection(ConnectionInfo conInfo, string msg) { return(new QueryMasterBase().Invoke <Rcon>(() => { RconSource rcon = null; try { rcon = new RconSource(conInfo, msg); if (!rcon.Reconnect()) { throw new QueryMasterException("Failed to connect"); } return rcon; } catch (Exception ex) { rcon?.Dispose(); rcon = null; throw; } }, conInfo.Retries + 1, null, conInfo.ThrowExceptions)); }