static void GatewayRemoteThread() { try { while (true) { lock (exit_lock) { if (should_exit) { break; } } if (gw_remote_stream.DataAvailable) { gw_remote_recv_buffer.Offset = 0; gw_remote_recv_buffer.Size = gw_remote_stream.Read(gw_remote_recv_buffer.Buffer, 0, gw_remote_recv_buffer.Buffer.Length); gw_remote_security.Recv(gw_remote_recv_buffer); } gw_remote_recv_packets = gw_remote_security.TransferIncoming(); if (gw_remote_recv_packets != null) { foreach (Packet packet in gw_remote_recv_packets) { //print debug packet PrintDebugPacket(packet, TransferType.StoP, ProxyType.GW_RM); // Do not pass through these packets. if (packet.Opcode == 0x5000 || packet.Opcode == 0x9000) { continue; } PacketManagerClientless.Manager(packet); } } gw_remote_send_buffers = gw_remote_security.TransferOutgoing(); if (gw_remote_send_buffers != null) { foreach (var kvp in gw_remote_send_buffers) { //print debug packet PrintDebugPacket(kvp.Value, TransferType.PtoS, ProxyType.GW_RM); TransferBuffer buffer = kvp.Key; gw_remote_stream.Write(buffer.Buffer, 0, buffer.Size); } } Thread.Sleep(1); } } catch (System.Exception ex) { Views.BindingFrom.WriteLine(String.Format("[GatewayRemoteThread] Exception: {0}" + Environment.NewLine, ex)); } }
static void AgentRemoteThread() { try { while (true) { lock (exit_lock) { if (should_exit) { break; } } if (ag_remote_stream.DataAvailable) { ag_remote_recv_buffer.Offset = 0; ag_remote_recv_buffer.Size = ag_remote_stream.Read(ag_remote_recv_buffer.Buffer, 0, ag_remote_recv_buffer.Buffer.Length); ag_remote_security.Recv(ag_remote_recv_buffer); } ag_remote_recv_packets = ag_remote_security.TransferIncoming(); if (ag_remote_recv_packets != null) { foreach (Packet packet in ag_remote_recv_packets) { //print debug packet PrintDebugPacket(packet, TransferType.StoP, ProxyType.GW_RM); // Do not pass through these packets. if (packet.Opcode == 0x5000 || packet.Opcode == 0x9000) { continue; } PacketManagerClientless.Manager(packet); #region //Packet p; //switch (packet.Opcode) //{ // #region Login //ok // case 0x2001://ok // #region AGENT_SERVER = 0x2001 // string text = packet.ReadAscii(); // if (text == "AgentServer") // { // var packetLoginRequest = GeneratePacket.LoginRequest(Globals.clientInfo.Locale, Globals.loginUser, Globals.loginPass, Globals.session); // ag_remote_security.Send(packetLoginRequest); // difference: this seds the packts that came from client to the server(remote) // //continue; // } // #endregion // break; // case 0xA103://ok // #region SERVER_AGENT_LOGIN_RESPONSE = 0xA103 // if (packet.ReadUInt8() == 1) // { // Packet response = new Packet(0x7007);//CLIENT_CHARACTERLISTING = 0x7007 // response.WriteUInt8(2); // ag_remote_security.Send(response); // //continue; //important so we can see chars #2 // } // #endregion // break; // case 0xB007://ok // #region CLIENT_AGENT_CHARACTER_SELECTION_REQUEST = 0xB007 // //List<string> characters = new List<string>(); // //SroBasicAuto.Logic.Login.GetCharacterList listChar = new Logic.Login.GetCharacterList(); // //characters = listChar.CharacterList(packet); // //Globals.frmMain.listBox_char_Box.Invoke( // // (MethodInvoker)(() => { Globals.frmMain.listBox_char_Box.Items.Clear(); })); // //foreach (string sc in characters) // //{ // // Globals.frmMain.listBox_char_Box.Invoke( // // (MethodInvoker)(() => { Globals.frmMain.listBox_char_Box.Items.Add(sc); })); // //} // //Globals.frmMain.btn_selectChar.SetPropertyValue(a => a.Enabled, true); // //continue; //this is the right important to see char // #endregion // break; // case 0x3013://ok // #region SERVER_AGENT_CHARACTER_DATA = 0x3013; // //f1.Radar_refr.Start(); // //Globals.log("Sent Character.char_Packet = packet;"); // //CharData.char_Packet = packet; // #endregion // break; // case 0xB624: // if (packet.ReadUInt8() == 1) // { // //Globals.frmMain.btn_sendCaptcha.SetPropertyValue(a => a.Enabled, true); // } // break; // #endregion //} #endregion } } ag_remote_send_buffers = ag_remote_security.TransferOutgoing(); if (ag_remote_send_buffers != null) { foreach (var kvp in ag_remote_send_buffers) { //print debug packet PrintDebugPacket(kvp.Value, TransferType.PtoS, ProxyType.GW_RM); TransferBuffer buffer = kvp.Key; ag_remote_stream.Write(buffer.Buffer, 0, buffer.Size); } } Thread.Sleep(1); } } catch (Exception ex) { Views.BindingFrom.WriteLine(String.Format("[AgentRemoteThread] Exception: {0}" + Environment.NewLine, ex)); } }