private bool getServerList(string data, ref serverUser server, ref Socket socket) { try { /* AppConfig */ AppConfigClass AppConfig = new AppConfigClass(); string user = AppConfig.GetConfig(ref data, "_"); //执行完毕后data为电脑名称 if (user == "") { return(false); } server.user = user; serverComputer b = new serverComputer() { name = data, socket = socket }; server.server.Add(b); return(true); } catch (Exception error) { new MessageClass().writeLog("Server::getServerList Error:" + error.Message); return(false); } }
public bool Sign_in(ref string data) //ToKen(身份)验证 /* AppConfig */ { AppConfigClass AppConfig = new AppConfigClass(); string session = AppConfig.GetConfig(ref data, "|"); string user; if (!Sign_in_w(session, out user)) { return(false); } data = user + "_" + data; return(true); }
private bool getServerList(string data, ref ServerClass.serverUser server) { try { /* AppConfig */ AppConfigClass AppConfig = new AppConfigClass(); /* user */ string user = AppConfig.GetConfig(ref data, "_"); if (user == "") { return(false); } server.user = user; /* shell */ string ComputerName = AppConfig.GetConfig(ref data, "|"); //执行完毕后data为shell if (ComputerName == "") { return(false); } ServerClass.serverComputer b = new ServerClass.serverComputer() { name = ComputerName, data = data }; /* Add List */ server.server.Add(b); return(true); } catch (Exception error) { new MessageClass().writeLog("Client::getServerList Error:" + error.Message); return(false); } }
public bool Entrance(byte[] data, ref Socket socket) { try { string user, computerName; if (data.Length < 6) { return(true); } string w_f = System.Text.Encoding.ASCII.GetString(controlSocketClass.SubByte(data, 0, 6)); //string data_string = System.Text.Encoding.ASCII.GetString(data); //string w_f = data_string.Substring(0, 6); //if (data_string.Length > 100) { // controlSocketClass.WriteMessage("MainClass::debug " + data_string.Substring(0, 10) + " "+ data_string.Substring(data_string.Length-10, 10) + " len:" + data_string.Length + " w_f:" + w_f); //} //else controlSocketClass.WriteMessage("MainClass::debug " + data_string + " len:" + data_string.Length + " w_f:"+w_f); //{ // int i = 0; // if (data_string.IndexOf("|end|") != -1) { i++; } // if (i != 1) { controlSocketClass.WriteMessage("MainClass::debug IndexOf:" + i); } //} if ((w_f == "Server" || w_f == "Client") && (!controlSocketList.TryGetValue(socket, out user))) // Socket查询用户,失败就说明没有验证过身份 { string data_string = System.Text.Encoding.ASCII.GetString(data); int function = getFunction(ref data_string); // 获取操作类型 /* Sign_in */ if (!Login(socket, ref data_string, out user)) { controlSocketClass.WriteMessage("MainClass::socketEntrance " + w_f + ": 捕捉到非法用户访问,身份信息不一致"); return(false); } computerName = appConfigClass.GetConfig(ref data_string, "|w|"); switch (function) { case 1: // Server controlSocketList.Add(socket, user); // 添加Socket对应用户列表 Server(socket, user, computerName); controlSocketClass.sendSocket(socket, controlSocketClass.flac_Start + controlSocketClass.flac_Success + controlSocketClass.flac_End); break; case 2: // Client controlSocketList.Add(socket, user); // 添加Socket对应用户列表 if (!Client(socket, user, computerName)) { controlSocketClass.WriteMessage("Entrance 被控端未上线"); return(false); } // 被控端未上线 controlSocketClass.sendSocket(socket, controlSocketClass.flac_Start + controlSocketClass.flac_Success + controlSocketClass.flac_End); break; default: controlSocketClass.WriteMessage("Entrance 捕捉到非法访问 Data:" + data_string); break; } goto flac_result; } // 如果是桌面信息,判断时间戳 string dataString = System.Text.Encoding.ASCII.GetString(controlSocketClass.SubByte(data, 0, 40)); string image = getConfig(ref dataString); if (image == "Control_image") { long recvTime = long.Parse(getConfig(ref dataString)); long nowTime = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; //if (nowTime - recvTime > 3000) { return true; } // 超过3s的桌面信息丢弃 } ForwardData(socket, data); // 转发数据 flac_result: return(true); } catch (System.Exception error) { controlSocketClass.WriteMessage("ControlMainClass->Entrance" + error.Message); return(false); } }