public void EmptyRequestStream() { var sr = new StringReader(""); var serializer = new XmlRpcSerializer(); XmlRpcRequest request = serializer.DeserializeRequest(sr, null); }
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; if (request.Params[3] != null) { IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]); if (ep != null) { // Bang! remoteClient = ep; } } if (requestData != null) { // Debug code to show exactly what login parameters the viewer is sending us. // TODO: Extract into a method that can be generally applied if one doesn't already exist. // foreach (string key in requestData.Keys) // { // object value = requestData[key]; // Console.WriteLine("{0}:{1}", key, value); // if (value is ArrayList) // { // ICollection col = value as ICollection; // foreach (object item in col) // Console.WriteLine(" {0}", item); // } // } if (((requestData.ContainsKey("first") && requestData["first"] != null && requestData.ContainsKey("last") && requestData["last"] != null) || (requestData.ContainsKey("username") && requestData["username"] != null)) && ( (requestData.ContainsKey("passwd") && requestData["passwd"] != null) || (!requestData.ContainsKey("passwd") && requestData.ContainsKey("web_login_key") && requestData["web_login_key"] != null && requestData["web_login_key"].ToString() != UUID.Zero.ToString()) )) { string first = null; string last = null; if (requestData.ContainsKey("username")) { first = requestData["username"].ToString(); last = "Resident"; } else { first = requestData["first"].ToString(); last = requestData["last"].ToString(); } string passwd = null; if (requestData.ContainsKey("passwd")) { passwd = requestData["passwd"].ToString(); } else if (requestData.ContainsKey("web_login_key")) { passwd = "$1$" + requestData["web_login_key"].ToString(); m_log.InfoFormat("[LOGIN]: XMLRPC Login Req key {0}", passwd); } string startLocation = string.Empty; UUID scopeID = UUID.Zero; if (requestData["scope_id"] != null) { scopeID = new UUID(requestData["scope_id"].ToString()); } if (requestData.ContainsKey("start")) { startLocation = requestData["start"].ToString(); } string clientVersion = "Unknown"; if (requestData.Contains("version") && requestData["version"] != null) { clientVersion = requestData["version"].ToString(); } // We should do something interesting with the client version... string channel = "Unknown"; if (requestData.Contains("channel") && requestData["channel"] != null) { channel = requestData["channel"].ToString(); } string mac = "Unknown"; if (requestData.Contains("mac") && requestData["mac"] != null) { mac = requestData["mac"].ToString(); } string id0 = "Unknown"; if (requestData.Contains("id0") && requestData["id0"] != null) { id0 = requestData["id0"].ToString(); } //m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); bool agree_to_tos = false; if (requestData.Contains("agree_to_tos") && requestData["agree_to_tos"] != null) { agree_to_tos = requestData["agree_to_tos"].ToString() == "1"; } LoginResponse reply = null; reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, clientVersion, channel, mac, id0, remoteClient, agree_to_tos); XmlRpcResponse response = new XmlRpcResponse(); response.Value = reply.ToHashtable(); return(response); } } return(FailedXMLRPCResponse()); }
/* * TODO: More work on the response codes. Right now * returning 200 for success or 499 for exception */ public void SendRequest() { Hashtable param = new Hashtable(); // Check if channel is an UUID // if not, use as method name UUID parseUID; string mName = "llRemoteData"; if ((Channel != null) && (Channel != "")) { if (!UUID.TryParse(Channel, out parseUID)) { mName = Channel; } else { param["Channel"] = Channel; } } param["StringValue"] = Sdata; param["IntValue"] = Convert.ToString(Idata); ArrayList parameters = new ArrayList(); parameters.Add(param); XmlRpcRequest req = new XmlRpcRequest(mName, parameters); try { XmlRpcResponse resp = req.Send(DestURL, 30000); if (resp != null) { Hashtable respParms; if (resp.Value.GetType().Equals(typeof(Hashtable))) { respParms = (Hashtable)resp.Value; } else { ArrayList respData = (ArrayList)resp.Value; respParms = (Hashtable)respData[0]; } if (respParms != null) { if (respParms.Contains("StringValue")) { Sdata = (string)respParms["StringValue"]; } if (respParms.Contains("IntValue")) { Idata = Convert.ToInt32(respParms["IntValue"]); } if (respParms.Contains("faultString")) { Sdata = (string)respParms["faultString"]; } if (respParms.Contains("faultCode")) { Idata = Convert.ToInt32(respParms["faultCode"]); } } } } catch (Exception we) { Sdata = we.Message; m_log.Warn("[SendRemoteDataRequest]: Request failed"); m_log.Warn(we.StackTrace); } _finished = true; }
public ConexionXmlRpc(XmlRpcClient clientXmlRpc, XmlRpcRequest requestXmlRpc = null, XmlRpcResponse responseXmlRpc = null) { this.clientXmlRpc = clientXmlRpc; this.requestXmlRpc = requestXmlRpc; this.responseXmlRpc = responseXmlRpc; }
private Hashtable XMLRPCRequest(Hashtable ReqParams, string method) { ArrayList SendParams = new ArrayList(); SendParams.Add(ReqParams); XmlRpcResponse Resp; try { XmlRpcRequest Req = new XmlRpcRequest(method, SendParams); Resp = Req.Send(m_connectionString, 30000); } catch (WebException ex) { m_log.ErrorFormat( "[UserLogModule]: XmlRpcDataConnector::WebException > Url:{0}, Method: {1}, Params: {2}, " + "Exception: {3}", m_connectionString, method, SendParams.ToString(), ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to log User data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } catch (SocketException ex) { m_log.ErrorFormat( "[UserLogModule]: XmlRpcDataConnector::SocketException > Url:{0}, Method: {1}, Params: {2}, " + "Exception: {3}", m_connectionString, method, SendParams.ToString(), ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to log user data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } catch (XmlException ex) { m_log.ErrorFormat( "[UserLogModule]: XmlRpcDataConnector::XmlException > Url:{0}, Method: {1}, Params: {2}, " + "Exception: {3}", m_connectionString, method, SendParams.ToString(), ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to log user data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } if (Resp.IsFault) { Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to log user data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } Hashtable RespData = (Hashtable)Resp.Value; return(RespData); }
public string XmlRpcTransaction(HttpContext context, string seruri, string resptype, int number, int currentPage, Hashtable reqParms) { ArrayList arrayParm = new ArrayList(); HttpRequest request = context.Request; // arrayParm.Add(reqParms); XmlRpcResponse serResp = null; string respxml = string.Empty; Hashtable RespData = new Hashtable(); Hashtable XmlData = new Hashtable(); Hashtable Cache = new Hashtable(); string sessionID = reqParms["sessionID"] as string; string method = string.Empty; int startindex = 1; if (currentPage == 1) { method = request.Form.Get("method").ToString(); startindex = 1; } else { method = "WebGetTransaction"; Cache = WebFrameWork.GetCurrentCache(sessionID); startindex = (currentPage / 10) * 10 + 1; } string html = string.Empty; WebFrameWork.ReleaseCache(sessionID); int maxnumber = number - (currentPage - 1) * 10; int maxpage = maxnumber >= 100 ? 10 : (number - 1) / 10 + 1; // MessageBox.Show(startindex.ToString() + " /" + maxpage.ToString()); for (int i = startindex; i <= maxpage; i++) { html = string.Empty; html += "<br/><br/><br/><h1>User Transaction Records (" + number.ToString() + ")</h1>"; html += "<table id ='dtable' align='left' style='border: 1px solid #dfdfdf; left : 0px; top:0px; width: 100% ;height:100%' >"; html += "<thead><tr style='vertical-align:middle;'><td class='top'>Index</td><td class='top' >transaction UUID</td><td class='top'>sender Name</td><td class='top'>receiver Name</td><td class='top'>amount</td><td class='top'>type</td><td class='top'>time</td><td class='top'>status</td><td class='top'>description</td></tr></thead>"; html += "<tbody>"; for (int ix = 0; ix < MAX_TRANSACTION_NUM; ix++) { try { arrayParm = new ArrayList(); //MessageBox.Show("mehtod: " + method); //MessageBox.Show("https " + seruri); if (ix == 0 && (int)reqParms["lastIndex"] == -1) { reqParms["lastIndex"] = Convert.ToInt32(reqParms["lastIndex"]) + 0; } else { reqParms["lastIndex"] = Convert.ToInt32(reqParms["lastIndex"]) + 1; } //foreach (DictionaryEntry de in reqParms) //{ // MessageBox.Show(de.Key + " " + de.Value); //} arrayParm.Add(reqParms); XmlRpcRequest serReq = new XmlRpcRequest(method, arrayParm); serResp = serReq.Send(seruri);//, _REQUEST_TIMEOUT); } catch (Exception ex) { XmlData["success"] = false; XmlData["method"] = method; XmlData["message"] = ex.Message.ToString(); XmlData["seruri"] = seruri; break; } if (serResp.IsFault) { XmlData["success"] = false; XmlData["method"] = method; XmlData["message"] = "Failed to Connet server: " + seruri.ToString(); XmlData["seruri"] = seruri; break; } else { RespData = (Hashtable)serResp.Value; html += "<tr>"; html += "<td class='rowstate'>" + RespData["transactionIndex"].ToString() + "</td>"; html += "<td class='rowstate'>" + RespData["transactionUUID"].ToString() + "</td>"; html += "<td class='rowstate'>" + RespData["senderName"].ToString() + "</td>"; html += "<td class='rowstate'>" + RespData["receiverName"].ToString() + "</td>"; html += "<td class='rowstate'>" + RespData["amount"].ToString() + "</td>"; html += "<td class='rowstate'>" + RespData["type"].ToString() + "</td>"; html += "<td class='rowstate'>" + getDataTime((int)RespData["time"]) + "</td>"; html += "<td class='rowstate'>" + getStatus((int)RespData["status"]) + "</td>"; html += "<td class='rowstate'>" + RespData["description"].ToString() + "</td>"; html += "</tr>"; if ((bool)RespData["isEnd"] || ix == MAX_TRANSACTION_NUM - 1 || Convert.ToInt32(reqParms["lastIndex"]) == (number - 2)) { //XmlData["method"] = method; XmlData["success"] = true; //MessageBox.Show(reqParms["lastIndex"].ToString() + "/" + number.ToString()+"-"+i.ToString()); //if (i > 10) // MessageBox.Show(((i - 1) * 10 + ix).ToString()+"/"+(number-1).ToString()); //XmlData["seruri"] = seruri; break; } } } html += "</tbody></table>"; html += getNavigationhtml(i, number); if ((bool)XmlData["success"]) { Cache[i] = html; } } Cache["startTime"] = Convert.ToInt32(reqParms["startTime"]); Cache["endTime"] = Convert.ToInt32(reqParms["endTime"]); Cache["number"] = number; Cache["lastIndex"] = Convert.ToInt32(reqParms["lastIndex"]); WebFrameWork.RegisterCache(sessionID, (object)Cache); XmlData.Clear(); XmlData = WebFrameWork.TransactionHash(currentPage, sessionID, method, seruri); //XmlData[ respxml = AssemblerDictionary.AssemblerPlugins[resptype].GenerateXml(context, XmlData); // MessageBox.Show(respxml); return(respxml); }
private void Save() { string pressfit_qr = ""; string gear_qr = ""; string pinion_qr = ""; if (txtPressfit.Text != null) { pressfit_qr = txtPressfit.Text.Trim(); } if (txtGear.Text != null) { gear_qr = txtGear.Text.Trim(); } if (txtPinion.Text != null) { pinion_qr = txtPinion.Text.Trim(); } if (pressfit_qr == "" && gear_qr == "" && pinion_qr == "") { MessageBox.Show("請掃描 QR Code", "錯誤"); } else { try { Cursor.Current = Cursors.WaitCursor; XmlRpcClient client = new XmlRpcClient(); client.Url = odooUrl; client.Path = "common"; // LOGIN XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate"); requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct()); XmlRpcResponse responseLogin = client.Execute(requestLogin); if (responseLogin.IsFault()) { Cursor.Current = Cursors.Default; MessageBox.Show("無法連線到資料庫,請通知 IT 人員", "錯誤"); } else { client.Path = "object"; List <object> domain = new List <object>(); if (pressfit_qr != "") { domain.Add(XmlRpcParameter.AsArray("pressfit_qr", "=", pressfit_qr)); } if (gear_qr != "") { domain.Add(XmlRpcParameter.AsArray("gear_qr", "=", gear_qr)); } if (pinion_qr != "") { domain.Add(XmlRpcParameter.AsArray("pinion_qr", "=", pinion_qr)); } if (domain.Count >= 2) { if (domain.Count == 3) { domain.Insert(0, "|"); } domain.Insert(0, "|"); } XmlRpcRequest requestSearch = new XmlRpcRequest("execute_kw"); requestSearch.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "search_read", XmlRpcParameter.AsArray( domain ), XmlRpcParameter.AsStruct( XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("pressfit_qr", "gear_qr", "pinion_qr")) // ,XmlRpcParameter.AsMember("limit", 2) ) ); XmlRpcResponse responseSearch = client.Execute(requestSearch); if (responseSearch.IsFault()) { MessageBox.Show(responseSearch.GetFaultString(), "錯誤"); } else if (!responseSearch.IsArray()) { Cursor.Current = Cursors.Default; MessageBox.Show("查詢資料庫異常,請通知 IT 人員", "錯誤"); } else { List <Object> valueList = responseSearch.GetArray(); if (valueList.Count == 0) { Dictionary <string, object> values = new Dictionary <string, object>(); if (pressfit_qr != "") { values["pressfit_qr"] = pressfit_qr; } if (gear_qr != "") { values["gear_qr"] = gear_qr; } if (pinion_qr != "") { values["pinion_qr"] = pinion_qr; } XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw"); requestCreate.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "create", XmlRpcParameter.AsArray(values) ); XmlRpcResponse responseCreate = client.Execute(requestCreate); if (responseCreate.IsFault()) { MessageBox.Show(responseCreate.GetFaultString(), "錯誤"); } else { AutoClosingMessageBox.Show("已儲存", "完成", 1000); ClearFields(); } } else { string db_pressfit_qr = ""; string db_gear_qr = ""; string db_pinion_qr = ""; int id = -1; foreach (Dictionary <string, object> valueDictionary in valueList) { foreach (KeyValuePair <string, object> kvp in valueDictionary) { if (kvp.Key == "id") { id = (int)kvp.Value; } else if (kvp.Key == "pressfit_qr" && kvp.Value is string) { db_pressfit_qr = (string)kvp.Value; } else if (kvp.Key == "gear_qr" && kvp.Value is string) { db_gear_qr = (string)kvp.Value; } else if (kvp.Key == "pinion_qr" && kvp.Value is string) { db_pinion_qr = (string)kvp.Value; } } } if ((pressfit_qr == "" || pressfit_qr == db_pressfit_qr) && (gear_qr == "" || gear_qr == db_gear_qr) && (pinion_qr == "" || pinion_qr == db_pinion_qr)) { Cursor.Current = Cursors.Default; MessageBox.Show("QR code 組合已存在", "錯誤"); } else if (ValueConflict(pressfit_qr, db_pressfit_qr) || ValueConflict(gear_qr, db_gear_qr) || ValueConflict(pinion_qr, db_pinion_qr)) { Cursor.Current = Cursors.Default; MessageBox.Show("與資料庫中下列 QR code 組合衝突,無法儲存:\n\n" + "總成:" + db_pressfit_qr + "\n" + "軸: " + db_pinion_qr + "\n" + "餅: " + db_gear_qr, "錯誤" ); } else { Dictionary <string, object> values = new Dictionary <string, object>(); if (pressfit_qr != "") { values["pressfit_qr"] = pressfit_qr; } if (gear_qr != "") { values["gear_qr"] = gear_qr; } if (pinion_qr != "") { values["pinion_qr"] = pinion_qr; } XmlRpcRequest requestWrite = new XmlRpcRequest("execute_kw"); requestWrite.AddParams(db, responseLogin.GetInt(), pass, "batom.tesla.qrcode", "write", XmlRpcParameter.AsArray(XmlRpcParameter.AsArray(id), values) ); XmlRpcResponse responseWrite = client.Execute(requestWrite); if (responseWrite.IsFault()) { MessageBox.Show(responseWrite.GetFaultString(), "錯誤"); } else { AutoClosingMessageBox.Show("已儲存", "完成", 1000); ClearFields(); } } } } Cursor.Current = Cursors.Default; } } catch { MessageBox.Show("無法儲存,請通知IT人員", "錯誤"); } } }
// // Make external XMLRPC request // private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method) { if (m_Debug) { m_log.DebugFormat("[{0}] GenericXMLRPCRequest for method {1}", m_moduleName, method); } ArrayList SendParams = new ArrayList(); SendParams.Add(ReqParams); // Send Request XmlRpcResponse Resp; try { XmlRpcRequest Req = new XmlRpcRequest(method, SendParams); Resp = Req.Send(m_ProfileServer, 30000); } catch (WebException ex) { m_log.ErrorFormat("[{0}]: Unable to connect to Profile Server {1}. Exception {2}", m_moduleName, m_ProfileServer, ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } catch (SocketException ex) { m_log.ErrorFormat( "[{0}]: Unable to connect to Profile Server {1}. Method {2}, params {3}. Exception {4}", m_moduleName, m_ProfileServer, method, ReqParams, ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } catch (XmlException ex) { m_log.ErrorFormat( "[{0}]: Unable to connect to Profile Server {1}. Method {2}, params {3}. Exception {4}", m_moduleName, m_ProfileServer, method, ReqParams.ToString(), ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } if (Resp.IsFault) { Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } Hashtable RespData = (Hashtable)Resp.Value; return(RespData); }
public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID, UUID agentID, string agentHomeURI, out string message) { Hashtable hash = new Hashtable(); hash["region_uuid"] = regionID.ToString(); if (agentID != UUID.Zero) { hash["agent_id"] = agentID.ToString(); if (agentHomeURI != null) { hash["agent_home_uri"] = agentHomeURI; } } IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + gatekeeper.ServerURI); XmlRpcResponse response = null; try { response = request.Send(gatekeeper.ServerURI, 10000); } catch (Exception e) { message = "Error contacting grid."; m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); return(null); } if (response.IsFault) { message = "Error contacting grid."; m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return(null); } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse((string)hash["result"], out success); if (hash["message"] != null) { message = (string)hash["message"]; } else if (success) { message = null; } else { message = "The teleport destination could not be found."; // probably the dest grid is old and doesn't send 'message', but the most common problem is that the region is unavailable } if (success) { GridRegion region = new GridRegion(); UUID.TryParse((string)hash["uuid"], out region.RegionID); //m_log.Debug(">> HERE, uuid: " + region.RegionID); int n = 0; if (hash["x"] != null) { Int32.TryParse((string)hash["x"], out n); region.RegionLocX = n; //m_log.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["y"] != null) { Int32.TryParse((string)hash["y"], out n); region.RegionLocY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["size_x"] != null) { Int32.TryParse((string)hash["size_x"], out n); region.RegionSizeX = n; //m_log.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["size_y"] != null) { Int32.TryParse((string)hash["size_y"], out n); region.RegionSizeY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["region_name"] != null) { region.RegionName = (string)hash["region_name"]; //m_log.Debug(">> HERE, region_name: " + region.RegionName); } if (hash["hostname"] != null) { region.ExternalHostName = (string)hash["hostname"]; //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); } if (hash["http_port"] != null) { uint p = 0; UInt32.TryParse((string)hash["http_port"], out p); region.HttpPort = p; //m_log.Debug(">> HERE, http_port: " + region.HttpPort); } if (hash["internal_port"] != null) { int p = 0; Int32.TryParse((string)hash["internal_port"], out p); region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); } if (hash["server_uri"] != null) { region.ServerURI = (string)hash["server_uri"]; //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); } // Successful return return(region); } } catch (Exception e) { message = "Error parsing response from grid."; m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return(null); } return(null); }
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; if (m_Proxy && request.Params[3] != null) { IPEndPoint ep = NetworkUtils.GetClientIPFromXFF((string)request.Params[3]); if (ep != null) { // Bang! remoteClient = ep; } } if (requestData != null) { if (((requestData.ContainsKey("first") && requestData["first"] != null && requestData.ContainsKey("last") && requestData["last"] != null) || requestData.ContainsKey("username") && requestData["username"] != null) && ((requestData.ContainsKey("passwd") && requestData["passwd"] != null) || (requestData.ContainsKey("web_login_key") && requestData["web_login_key"] != null))) { string first = requestData.ContainsKey("first") ? requestData["first"].ToString() : ""; string last = requestData.ContainsKey("last") ? requestData["last"].ToString() : ""; string name = requestData.ContainsKey("username") ? requestData["username"].ToString() : ""; string passwd = ""; if (!requestData.ContainsKey("web_login_key")) { passwd = requestData["passwd"].ToString(); } else { passwd = requestData["web_login_key"].ToString(); } string startLocation = string.Empty; if (requestData.ContainsKey("start")) { startLocation = requestData["start"].ToString(); } string clientVersion = "Unknown"; if (requestData.Contains("version") && requestData["version"] != null) { clientVersion = requestData["version"].ToString(); } //MAC BANNING START string mac = (string)requestData["mac"]; if (mac == "") { return(FailedXMLRPCResponse("Bad Viewer Connection.")); } string channel = "Unknown"; if (requestData.Contains("channel") && requestData["channel"] != null) { channel = requestData["channel"].ToString(); } if (channel == "") { return(FailedXMLRPCResponse("Bad Viewer Connection.")); } string id0 = "Unknown"; if (requestData.Contains("id0") && requestData["id0"] != null) { id0 = requestData["id0"].ToString(); } LoginResponse reply = null; string loginName = (name == "" || name == null) ? first + " " + last : name; reply = m_loginService.Login(UUID.Zero, loginName, "UserAccount", passwd, startLocation, clientVersion, channel, mac, id0, remoteClient, requestData); XmlRpcResponse response = new XmlRpcResponse { Value = reply.ToHashtable() }; return(response); } } return(FailedXMLRPCResponse()); }
public static XmlRpcResponse SendXmlRpcCommand(string url, string methodName, object[] args) { XmlRpcRequest client = new XmlRpcRequest(methodName, args); return(client.Send(url, 6000)); }
private Hashtable XmlRpcCall(GroupRequestID requestID, string function, Hashtable param) { if (requestID == null) { requestID = new GroupRequestID(); } param.Add("RequestingAgentID", requestID.AgentID.ToString()); param.Add("RequestingAgentUserService", requestID.UserServiceURL); param.Add("RequestingSessionID", requestID.SessionID.ToString()); param.Add("ReadKey", m_groupReadKey); param.Add("WriteKey", m_groupWriteKey); IList parameters = new ArrayList(); parameters.Add(param); XmlRpcResponse resp = null; try { XmlRpcRequest req; /* * if (!m_disableKeepAlive) * req = new XmlRpcRequest(function, parameters); * else * // This seems to solve a major problem on some windows servers * req = new NoKeepAliveXmlRpcRequest(function, parameters); */ req = new XmlRpcRequest(function, parameters); resp = req.Send(Util.XmlRpcRequestURI(m_serviceURL, function), 10000); } catch (Exception e) { m_log.ErrorFormat("[XMLRPCGROUPDATA]: An error has occured while attempting to access the XmlRpcGroups server method: {0}", function); m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} ", e.ToString()); foreach (string key in param.Keys) { m_log.WarnFormat("[XMLRPCGROUPDATA]: {0} :: {1}", key, param[key].ToString()); } Hashtable respData = new Hashtable(); respData.Add("error", e.ToString()); return(respData); } if (resp.Value is Hashtable) { Hashtable respData = (Hashtable)resp.Value; if (respData.Contains("error") && !respData.Contains("succeed")) { LogRespDataToConsoleError(respData); } return(respData); } m_log.ErrorFormat("[XMLRPCGROUPDATA]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); if (resp.Value is ArrayList) { ArrayList al = (ArrayList)resp.Value; m_log.ErrorFormat("[XMLRPCGROUPDATA]: Contains {0} elements", al.Count); foreach (object o in al) { m_log.ErrorFormat("[XMLRPCGROUPDATA]: {0} :: {1}", o.GetType().ToString(), o.ToString()); } } else { m_log.ErrorFormat("[XMLRPCGROUPDATA]: Function returned: {0}", resp.Value.ToString()); } Hashtable error = new Hashtable(); error.Add("error", "invalid return value"); return(error); }
public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep) { Hashtable requestData = (Hashtable)request.Params[0]; XmlRpcResponse ret = new XmlRpcResponse(); Hashtable retparam = new Hashtable(); Hashtable membershiplevels = new Hashtable(); membershiplevels.Add("levels", membershiplevels); Hashtable landuse = new Hashtable(); Hashtable level = new Hashtable { { "id", "00000000-0000-0000-0000-000000000000" }, { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" } }; if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) { UUID agentId; UUID.TryParse((string)requestData["agentId"], out agentId); UserCurrency currency = m_connector.GetUserCurrency(agentId); IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>("IProfileConnector").GetUserProfile(agentId); OSDMap replyData = null; bool response = false; UserInfo user = m_agentInfoService.GetUserInfo(agentId.ToString()); if (user == null) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { OSDMap map = new OSDMap(); map["Method"] = "GetLandData"; map["AgentID"] = agentId; m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) => { replyData = o; response = true; }); while (!response) { Thread.Sleep(10); } if (replyData == null || replyData["Success"] == false) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { if (replyData.ContainsKey("SalePrice")) { int landTierNeeded = (int)(currency.LandInUse + replyData["Area"].AsInteger()); bool needsUpgrade = false; switch (profile.MembershipGroup) { case "Premium": case "": needsUpgrade = landTierNeeded >= currency.Tier; break; case "Banned": needsUpgrade = true; break; } landuse.Add("action", needsUpgrade); retparam.Add("success", true); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } } } } return(ret); }
public XmlRpcResponse GetbalanceFunc(XmlRpcRequest request, IPEndPoint ep) { MainConsole.Instance.Error("Remote procedure calls GetbalanceFunc was called."); throw new NotImplementedException(); }
private Hashtable GenericXMLRPCRequestRemote(Hashtable ReqParams, string method) { ArrayList SendParams = new ArrayList(); SendParams.Add(ReqParams); // Send Request XmlRpcResponse Resp; try { XmlRpcRequest Req = new XmlRpcRequest(method, SendParams); Resp = Req.Send(value, 30000); } catch (WebException ex) { m_log.ErrorFormat("[OpenSimEmail]: Unable to connect to Email " + "Server {0}. Exception {1}", m_EmailServer, ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to send email at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } catch (SocketException ex) { m_log.ErrorFormat( "[OpenSimEmail]: Unable to connect to Email Server {0}. " + "Exception {1}", m_EmailServer, ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to send email at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } catch (XmlException ex) { m_log.ErrorFormat( "[OpenSimEmail]: Unable to connect to Email Server {0}. " + "Exception {1}", m_EmailServer, ex); Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to send email at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } if (Resp.IsFault) { Hashtable ErrorHash = new Hashtable(); ErrorHash["success"] = false; ErrorHash["errorMessage"] = "Unable to send email at this time. "; ErrorHash["errorURI"] = ""; return(ErrorHash); } Hashtable RespData = (Hashtable)Resp.Value; return(RespData); }
public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string externalName, out string imageURL, out string reason, out int sizeX, out int sizeY) { regionID = UUID.Zero; imageURL = string.Empty; realHandle = 0; externalName = string.Empty; reason = string.Empty; sizeX = (int)Constants.RegionSize; sizeY = (int)Constants.RegionSize; Hashtable hash = new Hashtable(); hash["region_name"] = info.RegionName; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + info.ServerURI); XmlRpcResponse response = null; try { response = request.Send(info.ServerURI, 10000); } catch (Exception e) { m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); reason = "Error contacting remote server"; return(false); } if (response.IsFault) { reason = response.FaultString; m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return(false); } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse((string)hash["result"], out success); if (success) { UUID.TryParse((string)hash["uuid"], out regionID); //m_log.Debug(">> HERE, uuid: " + regionID); if ((string)hash["handle"] != null) { realHandle = Convert.ToUInt64((string)hash["handle"]); //m_log.Debug(">> HERE, realHandle: " + realHandle); } if (hash["region_image"] != null) { imageURL = (string)hash["region_image"]; //m_log.Debug(">> HERE, imageURL: " + imageURL); } if (hash["external_name"] != null) { externalName = (string)hash["external_name"]; //m_log.Debug(">> HERE, externalName: " + externalName); } if (hash["size_x"] != null) { Int32.TryParse((string)hash["size_x"], out sizeX); } if (hash["size_y"] != null) { Int32.TryParse((string)hash["size_y"], out sizeY); } } } catch (Exception e) { reason = "Error parsing return arguments"; m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return(false); } return(true); }
public List <UUID> GetOnlineFriends(UUID userID, List <string> friends) { Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); int i = 0; foreach (string s in friends) { hash["friend_" + i.ToString()] = s; i++; } IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_online_friends", paramList); // string reason = string.Empty; // Send and get reply List <UUID> online = new List <UUID>(); XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch { m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURLHost); // reason = "Exception: " + e.Message; return(online); } if (response.IsFault) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURLHost, response.FaultString); // reason = "XMLRPC Fault"; return(online); } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { if (hash == null) { m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost); // reason = "Internal error 1"; return(online); } // Here is the actual response foreach (object key in hash.Keys) { if (key is string && ((string)key).StartsWith("friend_") && hash[key] != null) { UUID uuid; if (UUID.TryParse(hash[key].ToString(), out uuid)) { online.Add(uuid); } } } } catch { m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetOnlineFriends response."); // reason = "Exception: " + e.Message; } return(online); }
/// <summary> /// Performed when a region connects to the grid server initially. /// </summary> /// <param name="request">The XML RPC Request</param> /// <returns>Startup parameters</returns> public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) { RegionProfileData sim; RegionProfileData existingSim; Hashtable requestData = (Hashtable)request.Params[0]; UUID uuid; if (!requestData.ContainsKey("UUID") || !UUID.TryParse((string)requestData["UUID"], out uuid)) { m_log.Debug("[LOGIN PRELUDE]: Region connected without a UUID, sending back error response."); return(ErrorResponse("No UUID passed to grid server - unable to connect you")); } try { sim = RegionFromRequest(requestData); } catch (FormatException e) { m_log.Debug("[LOGIN PRELUDE]: Invalid login parameters, sending back error response."); return(ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString())); } m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); if (!m_config.AllowRegionRegistration) { m_log.DebugFormat( "[LOGIN END]: Disabled region registration blocked login request from simulator: {0}", sim.regionName); return(ErrorResponse("This grid is currently not accepting region registrations.")); } int majorInterfaceVersion = 0; if (requestData.ContainsKey("major_interface_version")) { int.TryParse((string)requestData["major_interface_version"], out majorInterfaceVersion); } if (majorInterfaceVersion != VersionInfo.MajorInterfaceVersion) { return(ErrorResponse( String.Format( "Your region service implements OGS1 interface version {0}" + " but this grid requires that the region implement OGS1 interface version {1} to connect." + " Try changing to {2}", majorInterfaceVersion, VersionInfo.MajorInterfaceVersion, VersionInfo.ShortVersion))); } existingSim = m_gridDBService.GetRegion(sim.regionHandle); if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) { try { if (existingSim == null) { ValidateNewRegionKeys(sim); } else { ValidateOverwriteKeys(sim, existingSim); } ValidateRegionContactable(sim); } catch (LoginException e) { string logMsg = e.Message; if (e.InnerException != null) { logMsg += ", " + e.InnerException.Message; } m_log.WarnFormat("[LOGIN END]: {0}", logMsg); return(e.XmlRpcErrorResponse); } DataResponse insertResponse = m_gridDBService.AddUpdateRegion(sim, existingSim); switch (insertResponse) { case DataResponse.RESPONSE_OK: m_log.Info("[LOGIN END]: " + (existingSim == null ? "New" : "Existing") + " sim login successful: " + sim.regionName); break; case DataResponse.RESPONSE_ERROR: m_log.Warn("[LOGIN END]: Sim login failed (Error): " + sim.regionName); break; case DataResponse.RESPONSE_INVALIDCREDENTIALS: m_log.Warn("[LOGIN END]: " + "Sim login failed (Invalid Credentials): " + sim.regionName); break; case DataResponse.RESPONSE_AUTHREQUIRED: m_log.Warn("[LOGIN END]: " + "Sim login failed (Authentication Required): " + sim.regionName); break; } XmlRpcResponse response = CreateLoginResponse(sim); return(response); } else { m_log.Warn("[LOGIN END]: Failed to login region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName); return(ErrorResponse("Another region already exists at that location. Please try another.")); } }
public string XmlRpcResponse(HttpContext context, string seruri, string resptype, System.Collections.Hashtable reqParams) { ArrayList arrayParm = new ArrayList(); HttpRequest request = context.Request; arrayParm.Add(reqParams); XmlRpcResponse serResp = null; Hashtable RespData = new Hashtable(); string method = request.Form.Get("method").ToString(); string respxml = string.Empty; //MessageBox.Show(seruri); //MessageBox.Show(method); //foreach (DictionaryEntry de in reqParams) //{ // MessageBox.Show(de.Value + " " + de.Key); //} try { XmlRpcRequest serReq = new XmlRpcRequest(method, arrayParm); serResp = serReq.Send(seruri);//, _REQUEST_TIMEOUT); } catch (Exception ex) { RespData["success"] = false; RespData["method"] = method; RespData["message"] = ex.Message.ToString(); RespData["seruri"] = seruri; } if (serResp.IsFault) { RespData["success"] = false; RespData["method"] = method; RespData["message"] = "Failed to Connet server: " + seruri.ToString(); RespData["seruri"] = seruri; } else if (method.Equals("get_user_by_name")) { //MessageBox.Show(request.Form.Get("verifynumber").ToUpper() + " " + request.Cookies["CheckCode"].Value.ToString()); if (String.IsNullOrEmpty(request.Form.Get("verifynumber").ToString())) { RespData["success"] = false; RespData["method"] = method; RespData["message"] = "Verify number is empty!"; RespData["seruri"] = seruri; RespData["error_type"] = "verify_error"; } else { if (request.Cookies["CheckCode"] == null) { RespData["success"] = false; RespData["method"] = method; RespData["message"] = "Your webbrowser must forbid the cookies!"; RespData["seruri"] = seruri; RespData["error_type"] = "verify_error"; } else if (request.Form.Get("verifynumber").ToUpper() != request.Cookies["CheckCode"].Value.ToString()) { RespData["success"] = false; RespData["method"] = method; RespData["message"] = "Verify number is error!"; RespData["seruri"] = seruri; RespData["error_type"] = "verify_error"; } else { RespData = (Hashtable)serResp.Value; if (RespData.ContainsKey("error_type")) { RespData["success"] = false; RespData["message"] = RespData["error_desc"]; } else { RespData["success"] = true; RespData["username"] = request.Form.Get("avatar_name").ToString(); RespData["userID"] = (string)RespData["uuid"] + "@" + request.Form.Get("seruri").ToString();//"23cc97ee-6fa1-46cc-83bd-80fdafc1255a" + "@" + "127.0.0.1";// RespData["moneyserver"] = request.Form.Get("seruris").ToString(); //WebFrameWork.ReleaseSession(); // WebFrameWork.ReleaseCookieUserInfo(); // WebFrameWork.RegisterCookieUserInfo(request, (string)RespData["uuid"]); } RespData["method"] = method; RespData["seruri"] = seruri; } } } else { RespData = (Hashtable)serResp.Value; if (method.Equals("WebLogin")) { WebFrameWork.ReleaseCookieUserInfo(); WebFrameWork.RegisterCookieUserInfo(request, reqParams["sessionID"].ToString()); RespData["username"] = request.Form.Get("userName").ToString(); RespData["userserver"] = request.Form.Get("userID").ToString().Split('@')[1].ToString(); RespData["moneyserver"] = request.Form.Get("seruris").ToString(); WebFrameWork.RegisterCookieServerInfo(request.Form.Get("userID").ToString().Split('@')[1].ToString(), request.Form.Get("seruris").ToString()); } RespData["success"] = true; RespData["method"] = method; RespData["seruri"] = seruri; } // MessageBox.Show(AssemblerDictionary.AssemblerPlugins[resptype].AssemblerType); respxml = AssemblerDictionary.AssemblerPlugins[resptype].GenerateXml(context, RespData); return(respxml); // return RespData; // AssemblerDictionary.AssemblerPlugins[resptype].GenerateXml( }
/// <summary> /// Returns an XML RPC response to a simulator profile request /// </summary> /// <param name="request"></param> /// <returns></returns> public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable(); RegionProfileData simData = null; if (requestData.ContainsKey("region_UUID")) { UUID regionID = new UUID((string)requestData["region_UUID"]); simData = m_gridDBService.GetRegion(regionID); } else if (requestData.ContainsKey("region_handle")) { //CFK: The if/else below this makes this message redundant. //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]); ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]); simData = m_gridDBService.GetRegion(regionHandle); if (simData == null) { m_log.WarnFormat("[DATA] didn't find regionHandle {0} from {1}", regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknown source"); } } else if (requestData.ContainsKey("region_name_search")) { string regionName = (string)requestData["region_name_search"]; simData = m_gridDBService.GetRegion(regionName); if (simData == null) { m_log.WarnFormat("[DATA] didn't find regionName {0} from {1}", regionName, request.Params.Count > 1 ? request.Params[1] : "unknown source"); } } else { m_log.Warn("[DATA] regionlookup without regionID, regionHandle or regionHame"); } if (simData == null) { //Sim does not exist responseData["error"] = "Sim does not exist"; } else { m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " + (string)requestData["region_handle"]); responseData["sim_ip"] = simData.serverHostName; responseData["sim_port"] = simData.serverPort.ToString(); responseData["remoting_port"] = simData.remotingPort.ToString(); responseData["http_port"] = simData.httpPort.ToString(); responseData["region_locx"] = simData.regionLocX.ToString(); responseData["region_locy"] = simData.regionLocY.ToString(); responseData["region_UUID"] = simData.UUID.Guid.ToString(); responseData["region_name"] = simData.regionName; responseData["regionHandle"] = simData.regionHandle.ToString(); responseData["product"] = Convert.ToInt32(simData.product).ToString(); if (simData.OutsideIP != null) { responseData["outside_ip"] = simData.OutsideIP; } } XmlRpcResponse response = new XmlRpcResponse(); response.Value = responseData; return(response); }
private XmlRpcResponse LoginHandler(XmlRpcRequest request, IHttpRequest httpRequest) { Hashtable requestData = (Hashtable)request.Params[0]; bool validLogin = requestData.ContainsKey("first") && requestData.ContainsKey("last") && (requestData.ContainsKey("passwd") || requestData.Contains("web_login_key")); if (validLogin) { string startLocation = (requestData.ContainsKey("start") ? (string)requestData["start"] : "last"); string version = (requestData.ContainsKey("version") ? (string)requestData["version"] : "Unknown"); string firstName = (string)requestData["first"]; string lastName = (string)requestData["last"]; string passHash = (string)requestData["passwd"]; m_log.InfoFormat("Received XML-RPC login request for {0} {1} with client \"{2}\" to destination \"{3}\"", firstName, lastName, version, startLocation); if (!String.IsNullOrEmpty(passHash)) { // Try to login string name = firstName + ' ' + lastName; // DEBUG: Anonymous logins are always enabled UserSession session = AnonymousLogin(name, 200, null, name, AUTH_METHOD, passHash); SceneInfo loginScene; Vector3 startPosition, lookAt; IPAddress address; int port; Uri seedCap; // Find a scene that this user is authorized to login to if (TryGetLoginScene(session, ref startLocation, out loginScene, out startPosition, out lookAt, out address, out port, out seedCap)) { m_log.Debug("Authenticated " + session.User.Name); #region Login Success Response // Session is created, construct the login response LindenLoginData response = new LindenLoginData(); uint regionX, regionY; GetRegionXY(loginScene.MinPosition, out regionX, out regionY); response.AgentID = session.User.ID; response.BuddyList = GetBuddyList(session.User.ID); response.CircuitCode = session.GetField("CircuitCode").AsInteger(); SetClassifiedCategories(ref response); response.FirstName = firstName; response.LastName = lastName; response.Login = true; response.LookAt = lookAt; response.Message = "Welcome to Simian"; response.RegionX = regionX; response.RegionY = regionY; response.SeedCapability = (seedCap != null) ? seedCap.AbsoluteUri : "http://localhost:0/"; response.SessionID = session.SessionID; response.SecureSessionID = session.SecureSessionID; response.StartLocation = startLocation; response.SimAddress = address.ToString(); response.SimPort = (uint)port; // Set the home scene information SceneInfo homeScene; if (m_gridClient.TryGetScene(session.User.HomeSceneID, out homeScene)) { uint homeRegionX, homeRegionY; GetRegionXY(homeScene.MinPosition, out homeRegionX, out homeRegionY); response.HomeLookAt = session.User.HomeLookAt; response.HomePosition = session.User.HomePosition; response.HomeRegionX = homeRegionX; response.HomeRegionY = homeRegionY; } else { response.HomeLookAt = lookAt; response.HomePosition = startPosition; response.HomeRegionX = regionX; response.HomeRegionY = regionY; } SetActiveGestures(session.User, ref response); GetInventory(session.User, ref response); m_log.Info("Login to " + loginScene.Name + " prepared for " + session.User.Name + ", returning response"); return(response.ToXmlRpcResponse()); #endregion Login Success Response } else { m_log.Error("Could not find a default local scene for " + name + ", cancelling login"); m_userClient.RemoveSession(session); return(CreateLoginNoRegionResponse()); } } } m_log.Warn("Received invalid login data, returning an error response"); return(CreateLoginGridErrorResponse()); }
public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request, IPEndPoint remoteClient) { int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020; Hashtable requestData = (Hashtable)request.Params[0]; if (requestData.ContainsKey("xmin")) { xmin = (Int32)requestData["xmin"]; } if (requestData.ContainsKey("ymin")) { ymin = (Int32)requestData["ymin"]; } if (requestData.ContainsKey("xmax")) { xmax = (Int32)requestData["xmax"]; } if (requestData.ContainsKey("ymax")) { ymax = (Int32)requestData["ymax"]; } //CFK: The second log is more meaningful and either standard or fast generally occurs. //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); response.Value = responseData; IList simProfileList = new ArrayList(); List <RegionProfileData> neighbours = m_gridDBService.GetRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax); foreach (RegionProfileData aSim in neighbours) { Hashtable simProfileBlock = new Hashtable(); simProfileBlock["x"] = aSim.regionLocX.ToString(); simProfileBlock["y"] = aSim.regionLocY.ToString(); //m_log.DebugFormat("[MAP]: Sending neighbour info for {0},{1}", aSim.regionLocX, aSim.regionLocY); simProfileBlock["name"] = aSim.regionName; simProfileBlock["access"] = aSim.AccessLevel; simProfileBlock["region-flags"] = 512; simProfileBlock["water-height"] = 0; simProfileBlock["agents"] = 1; simProfileBlock["map-image-id"] = aSim.regionMapTextureID.ToString(); // For Sugilite compatibility simProfileBlock["regionhandle"] = aSim.regionHandle.ToString(); simProfileBlock["sim_ip"] = aSim.serverHostName; simProfileBlock["sim_port"] = aSim.serverPort.ToString(); simProfileBlock["uuid"] = aSim.UUID.ToString(); simProfileBlock["remoting_port"] = aSim.remotingPort.ToString(); simProfileBlock["http_port"] = aSim.httpPort.ToString(); simProfileBlock["product"] = Convert.ToInt32(aSim.product).ToString(); if (aSim.OutsideIP != null) { simProfileBlock["outside_ip"] = aSim.OutsideIP; } simProfileList.Add(simProfileBlock); } m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); responseData["sim-profiles"] = simProfileList; return(response); }
private void applyMethod(TIPO_METODO_API method) => requestXmlRpc = new XmlRpcRequest(method.Humanize());
public XmlRpcResponse currencyNotify(XmlRpcRequest request, IPEndPoint ep) { XmlRpcResponse r = new XmlRpcResponse(); try { Hashtable requestData = (Hashtable)request.Params[0]; Hashtable communicationData = (Hashtable)request.Params[1]; #region // Debug #if DEBUG m_log.Debug("[OMECONOMY]: currencyNotify(...)"); foreach (DictionaryEntry requestDatum in requestData) { m_log.Debug("[OMECONOMY]: " + requestDatum.Key.ToString() + " " + (string)requestDatum.Value); } foreach (DictionaryEntry communicationDatum in communicationData) { m_log.Debug("[OMECONOMY]: " + communicationDatum.Key.ToString() + " " + (string)communicationDatum.Value); } #endif #endregion String method = (string)requestData["method"]; requestData.Remove("method"); if (CommunicationHelpers.ValidateRequest(communicationData, requestData, gatewayURL)) { switch (method) { case "notifyDeliverObject": r.Value = deliverObject(requestData); break; case "notifyOnObjectPaid": r.Value = onObjectPaid(requestData); break; case "notifyLandBuy": r.Value = landBuy(requestData); break; case "notifyChangePrimPermission": r.Value = changePrimPermissions(requestData); break; case "notifyBalanceUpdate": r.Value = balanceUpdate(requestData); break; case "notifyGetVersion": r.Value = GetVersion(requestData); break; default: m_log.ErrorFormat("[OMECONOMY]: Method {1} is not supported", Name, method); break; } } else { throw new Exception("Hash values do not match"); } } catch (Exception e) { m_log.ErrorFormat("[OMECONOMY]: genericNotify() Exception: {1} - {2}", Name, e.Message, e.StackTrace); r.SetFault(1, "Could not parse the requested method"); } return(r); }
public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request) { m_log.Info("[IRC-Bridge]: XML RPC Admin Entry"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); try { Hashtable requestData = (Hashtable)request.Params[0]; bool found = false; string region = String.Empty; if (password != String.Empty) { if (!requestData.ContainsKey("password")) { throw new Exception("Invalid request"); } if ((string)requestData["password"] != password) { throw new Exception("Invalid request"); } } if (!requestData.ContainsKey("region")) { throw new Exception("No region name specified"); } region = (string)requestData["region"]; foreach (RegionState rs in m_regions) { if (rs.Region == region) { responseData["server"] = rs.cs.Server; responseData["port"] = (int)rs.cs.Port; responseData["user"] = rs.cs.User; responseData["channel"] = rs.cs.IrcChannel; responseData["enabled"] = rs.cs.irc.Enabled; responseData["connected"] = rs.cs.irc.Connected; responseData["nickname"] = rs.cs.irc.Nick; found = true; break; } } if (!found) { throw new Exception(String.Format("Region <{0}> not found", region)); } responseData["success"] = true; } catch (Exception e) { m_log.InfoFormat("[IRC-Bridge] XML RPC Admin request failed : {0}", e.Message); responseData["success"] = "false"; responseData["error"] = e.Message; } finally { response.Value = responseData; } m_log.Debug("[IRC-Bridge]: XML RPC Admin Exit"); return(response); }
public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request, IPEndPoint remoteClient) { XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") && requestData.Contains("StringValue")); if (GoodXML) { UUID channel = new UUID((string)requestData["Channel"]); RPCChannelInfo rpcChanInfo; if (m_openChannels.TryGetValue(channel, out rpcChanInfo)) { string intVal = Convert.ToInt32(requestData["IntValue"]).ToString(); string strVal = (string)requestData["StringValue"]; RPCRequestInfo rpcInfo; lock (XMLRPCListLock) { rpcInfo = new RPCRequestInfo(rpcChanInfo.GetPrimID(), rpcChanInfo.GetItemID(), channel, strVal, intVal); m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo); } int timeoutCtr = 0; while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout)) { Thread.Sleep(RemoteReplyScriptWait); timeoutCtr += RemoteReplyScriptWait; } if (rpcInfo.IsProcessed()) { Hashtable param = new Hashtable(); param["StringValue"] = rpcInfo.GetStrRetval(); param["IntValue"] = rpcInfo.GetIntRetval(); ArrayList parameters = new ArrayList { param }; response.Value = parameters; rpcInfo = null; } else { response.SetFault(-1, "Script timeout"); rpcInfo = null; } } else { response.SetFault(-1, "Invalid channel"); } } //Make sure that the cmd handler thread is running m_scriptModule.PokeThreads(UUID.Zero); return(response); }
public virtual LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess) { LandData landData = null; IList paramList = new ArrayList(); regionAccess = 42; // Default to adult. Better safe... try { uint xpos = 0, ypos = 0; Util.RegionHandleToWorldLoc(regionHandle, out xpos, out ypos); GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos); if (info != null) // just to be sure { string targetHandlestr = info.RegionHandle.ToString(); if (ypos == 0) //HG proxy? { // this is real region handle on hg proxies hack targetHandlestr = info.RegionSecret; } Hashtable hash = new Hashtable(); hash["region_handle"] = targetHandlestr; hash["x"] = x.ToString(); hash["y"] = y.ToString(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("land_data", paramList); XmlRpcResponse response = request.Send(info.ServerURI, 10000); if (response.IsFault) { m_log.ErrorFormat("[LAND CONNECTOR]: remote call returned an error: {0}", response.FaultString); } else { hash = (Hashtable)response.Value; try { landData = new LandData(); landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]); landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]); landData.Area = Convert.ToInt32(hash["Area"]); landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]); landData.Description = (string)hash["Description"]; landData.Flags = Convert.ToUInt32(hash["Flags"]); landData.GlobalID = new UUID((string)hash["GlobalID"]); landData.Name = (string)hash["Name"]; landData.OwnerID = new UUID((string)hash["OwnerID"]); landData.SalePrice = Convert.ToInt32(hash["SalePrice"]); landData.SnapshotID = new UUID((string)hash["SnapshotID"]); landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]); if (hash["RegionAccess"] != null) { regionAccess = (byte)Convert.ToInt32((string)hash["RegionAccess"]); } if (hash["Dwell"] != null) { landData.Dwell = Convert.ToSingle((string)hash["Dwell"]); } //m_log.DebugFormat("[LAND CONNECTOR]: Got land data for parcel {0}", landData.Name); } catch (Exception e) { m_log.ErrorFormat( "[LAND CONNECTOR]: Got exception while parsing land-data: {0} {1}", e.Message, e.StackTrace); } } } else { m_log.WarnFormat("[LAND CONNECTOR]: Couldn't find region with handle {0}", regionHandle); } } catch (Exception e) { m_log.ErrorFormat( "[LAND CONNECTOR]: Couldn't contact region {0}: {1} {2}", regionHandle, e.Message, e.StackTrace); } return(landData); }
/// <summary> /// Process a XMLRPC Grid Instant Message /// </summary> /// <param name="request">XMLRPC parameters /// </param> /// <returns>Nothing much</returns> protected virtual XmlRpcResponse processXMLRPCGridInstantMessage(XmlRpcRequest request, IPEndPoint remoteClient) { bool successful = false; // TODO: For now, as IMs seem to be a bit unreliable on OSGrid, catch all exception that // happen here and aren't caught and log them. try { // various rational defaults UUID fromAgentID = UUID.Zero; UUID toAgentID = UUID.Zero; UUID imSessionID = UUID.Zero; uint timestamp = 0; string fromAgentName = ""; string message = ""; byte dialog = (byte)0; bool fromGroup = false; byte offline = (byte)0; uint ParentEstateID = 0; Vector3 Position = Vector3.Zero; UUID RegionID = UUID.Zero; byte[] binaryBucket = new byte[0]; float pos_x = 0; float pos_y = 0; float pos_z = 0; //m_log.Info("Processing IM"); Hashtable requestData = (Hashtable)request.Params[0]; // Check if it's got all the data if (requestData.ContainsKey("from_agent_id") && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id") && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name") && requestData.ContainsKey("message") && requestData.ContainsKey("dialog") && requestData.ContainsKey("from_group") && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id") && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y") && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") && requestData.ContainsKey("binary_bucket")) { // Do the easy way of validating the UUIDs UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); UUID.TryParse((string)requestData["im_session_id"], out imSessionID); UUID.TryParse((string)requestData["region_id"], out RegionID); try { timestamp = (uint)Convert.ToInt32((string)requestData["timestamp"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } fromAgentName = (string)requestData["from_agent_name"]; message = (string)requestData["message"]; if (message == null) { message = string.Empty; } // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them. string requestData1 = (string)requestData["dialog"]; if (string.IsNullOrEmpty(requestData1)) { dialog = 0; } else { byte[] dialogdata = Convert.FromBase64String(requestData1); dialog = dialogdata[0]; } if ((string)requestData["from_group"] == "TRUE") { fromGroup = true; } string requestData2 = (string)requestData["offline"]; if (String.IsNullOrEmpty(requestData2)) { offline = 0; } else { byte[] offlinedata = Convert.FromBase64String(requestData2); offline = offlinedata[0]; } try { ParentEstateID = (uint)Convert.ToInt32((string)requestData["parent_estate_id"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } try { pos_x = (uint)Convert.ToInt32((string)requestData["position_x"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } try { pos_y = (uint)Convert.ToInt32((string)requestData["position_y"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } try { pos_z = (uint)Convert.ToInt32((string)requestData["position_z"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } Position = new Vector3(pos_x, pos_y, pos_z); string requestData3 = (string)requestData["binary_bucket"]; if (string.IsNullOrEmpty(requestData3)) { binaryBucket = new byte[0]; } else { binaryBucket = Convert.FromBase64String(requestData3); } // Create a New GridInstantMessageObject the the data GridInstantMessage gim = new GridInstantMessage(); gim.fromAgentID = fromAgentID.Guid; gim.fromAgentName = fromAgentName; gim.fromGroup = fromGroup; gim.imSessionID = imSessionID.Guid; gim.RegionID = RegionID.Guid; gim.timestamp = timestamp; gim.toAgentID = toAgentID.Guid; gim.message = message; gim.dialog = dialog; gim.offline = offline; gim.ParentEstateID = ParentEstateID; gim.Position = Position; gim.binaryBucket = binaryBucket; // Trigger the Instant message in the scene. foreach (Scene scene in m_Scenes) { if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) { ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; if (!user.IsChildAgent) { scene.EventManager.TriggerIncomingInstantMessage(gim); successful = true; } } } if (!successful) { // If the message can't be delivered to an agent, it // is likely to be a group IM. On a group IM, the // imSessionID = toAgentID = group id. Raise the // unhandled IM event to give the groups module // a chance to pick it up. We raise that in a random // scene, since the groups module is shared. // m_Scenes[0].EventManager.TriggerUnhandledInstantMessage(gim); } } } catch (Exception e) { m_log.Error("[INSTANT MESSAGE]: Caught unexpected exception:", e); successful = false; } //Send response back to region calling if it was successful // calling region uses this to know when to look up a user's location again. XmlRpcResponse resp = new XmlRpcResponse(); Hashtable respdata = new Hashtable(); if (successful) { respdata["success"] = "TRUE"; } else { respdata["success"] = "FALSE"; } resp.Value = respdata; return(resp); }
public override void LogOffUser(UserProfileData theUser, string message) { RegionProfileData SimInfo; try { SimInfo = m_regionProfileService.RequestSimProfileData( theUser.CurrentAgent.Handle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); if (SimInfo == null) { m_log.Error("[GRID]: Region user was in isn't currently logged in"); return; } } catch (Exception) { m_log.Error("[GRID]: Unable to look up region to log user off"); return; } // Prepare notification Hashtable SimParams = new Hashtable(); SimParams["agent_id"] = theUser.ID.ToString(); SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); SimParams["region_secret2"] = SimInfo.regionSecret; //m_log.Info(SimInfo.regionSecret); SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); SimParams["message"] = message; ArrayList SendParams = new ArrayList(); SendParams.Add(SimParams); m_log.InfoFormat( "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, theUser.FirstName + " " + theUser.SurName); try { string methodName = "logoff_user"; XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(SimInfo.httpServerURI, methodName), 6000); if (GridResp.IsFault) { m_log.ErrorFormat( "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); } } catch (Exception) { m_log.Error("[LOGIN]: Error telling region to logout user!"); } // Prepare notification SimParams = new Hashtable(); SimParams["agent_id"] = theUser.ID.ToString(); SimParams["region_secret"] = SimInfo.regionSecret; //m_log.Info(SimInfo.regionSecret); SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); SimParams["message"] = message; SendParams = new ArrayList(); SendParams.Add(SimParams); m_log.InfoFormat( "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, theUser.FirstName + " " + theUser.SurName); try { string methodName = "logoff_user"; XmlRpcRequest GridReq = new XmlRpcRequest(methodName, SendParams); XmlRpcResponse GridResp = GridReq.Send(Util.XmlRpcRequestURI(SimInfo.httpServerURI, methodName), 6000); if (GridResp.IsFault) { m_log.ErrorFormat( "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); } } catch (Exception) { m_log.Error("[LOGIN]: Error telling region to logout user!"); } //base.LogOffUser(theUser); }
public void NullRequestStream() { var serializer = new XmlRpcSerializer(); Stream stm = null; XmlRpcRequest request = serializer.DeserializeRequest(stm, null); }