diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | 100 |
1 files changed, 42 insertions, 58 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 48ef247..d668e7c 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -50,42 +50,12 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
50 | LogManager.GetLogger( | 50 | LogManager.GetLogger( |
51 | MethodBase.GetCurrentMethod().DeclaringType); | 51 | MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | private string m_ServerURLHost; | ||
54 | private string m_ServerURL; | 53 | private string m_ServerURL; |
55 | private GridRegion m_Gatekeeper; | 54 | private GridRegion m_Gatekeeper; |
56 | 55 | ||
57 | public UserAgentServiceConnector(string url) : this(url, false) | 56 | public UserAgentServiceConnector(string url) |
58 | { | 57 | { |
59 | } | 58 | setServiceURL(url); |
60 | |||
61 | public UserAgentServiceConnector(string url, bool dnsLookup) | ||
62 | { | ||
63 | m_ServerURL = m_ServerURLHost = url; | ||
64 | |||
65 | if (dnsLookup) | ||
66 | { | ||
67 | // Doing this here, because XML-RPC or mono have some strong ideas about | ||
68 | // caching DNS translations. | ||
69 | try | ||
70 | { | ||
71 | Uri m_Uri = new Uri(m_ServerURL); | ||
72 | IPAddress ip = Util.GetHostFromDNS(m_Uri.Host); | ||
73 | if(ip != null) | ||
74 | { | ||
75 | m_ServerURL = m_ServerURL.Replace(m_Uri.Host, ip.ToString()); | ||
76 | if (!m_ServerURL.EndsWith("/")) | ||
77 | m_ServerURL += "/"; | ||
78 | } | ||
79 | else | ||
80 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Failed to resolv address of {0}", url); | ||
81 | } | ||
82 | catch (Exception e) | ||
83 | { | ||
84 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", url, e.Message); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0} ({1})", url, m_ServerURL); | ||
89 | } | 59 | } |
90 | 60 | ||
91 | public UserAgentServiceConnector(IConfigSource config) | 61 | public UserAgentServiceConnector(IConfigSource config) |
@@ -97,20 +67,38 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
97 | throw new Exception("UserAgent connector init error"); | 67 | throw new Exception("UserAgent connector init error"); |
98 | } | 68 | } |
99 | 69 | ||
100 | string serviceURI = serviceConfig.GetString("UserAgentServerURI", | 70 | string serviceURI = serviceConfig.GetString("UserAgentServerURI", String.Empty); |
101 | String.Empty); | ||
102 | 71 | ||
103 | if (serviceURI == String.Empty) | 72 | if (String.IsNullOrWhiteSpace(serviceURI)) |
104 | { | 73 | { |
105 | m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService"); | 74 | m_log.Error("[USER AGENT CONNECTOR]: No Server URI named in section UserAgentService"); |
106 | throw new Exception("UserAgent connector init error"); | 75 | throw new Exception("UserAgent connector init error"); |
107 | } | 76 | } |
108 | 77 | ||
109 | m_ServerURL = m_ServerURLHost = serviceURI; | 78 | if (!setServiceURL(serviceURI)) |
79 | { | ||
80 | throw new Exception("UserAgent connector init error"); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | private bool setServiceURL(string url) | ||
85 | { | ||
86 | // validate url getting some extended error messages | ||
87 | try | ||
88 | { | ||
89 | Uri tmpuri = new Uri(url); | ||
90 | } | ||
91 | catch (Exception e) | ||
92 | { | ||
93 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Malformed Uri {0}: {1}", url, e.Message); | ||
94 | return false; | ||
95 | } | ||
96 | |||
97 | m_ServerURL = url; | ||
110 | if (!m_ServerURL.EndsWith("/")) | 98 | if (!m_ServerURL.EndsWith("/")) |
111 | m_ServerURL += "/"; | 99 | m_ServerURL += "/"; |
112 | 100 | ||
113 | //m_log.DebugFormat("[USER AGENT CONNECTOR]: new connector to {0}", m_ServerURL); | 101 | return true; |
114 | } | 102 | } |
115 | 103 | ||
116 | protected override string AgentPath() | 104 | protected override string AgentPath() |
@@ -183,20 +171,20 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
183 | } | 171 | } |
184 | catch (Exception e) | 172 | catch (Exception e) |
185 | { | 173 | { |
186 | m_log.DebugFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURLHost, e.Message); | 174 | m_log.DebugFormat("[USER AGENT CONNECTOR]: {0} call to {1} failed: {2}", methodName, m_ServerURL, e.Message); |
187 | throw; | 175 | throw; |
188 | } | 176 | } |
189 | 177 | ||
190 | if (response.IsFault) | 178 | if (response.IsFault) |
191 | { | 179 | { |
192 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURLHost, response.FaultString)); | 180 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned an error: {2}", methodName, m_ServerURL, response.FaultString)); |
193 | } | 181 | } |
194 | 182 | ||
195 | hash = (Hashtable)response.Value; | 183 | hash = (Hashtable)response.Value; |
196 | 184 | ||
197 | if (hash == null) | 185 | if (hash == null) |
198 | { | 186 | { |
199 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURLHost)); | 187 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: {0} call to {1} returned null", methodName, m_ServerURL)); |
200 | } | 188 | } |
201 | 189 | ||
202 | return hash; | 190 | return hash; |
@@ -359,14 +347,14 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
359 | } | 347 | } |
360 | catch | 348 | catch |
361 | { | 349 | { |
362 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURLHost); | 350 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for StatusNotification", m_ServerURL); |
363 | // reason = "Exception: " + e.Message; | 351 | // reason = "Exception: " + e.Message; |
364 | return friendsOnline; | 352 | return friendsOnline; |
365 | } | 353 | } |
366 | 354 | ||
367 | if (response.IsFault) | 355 | if (response.IsFault) |
368 | { | 356 | { |
369 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURLHost, response.FaultString); | 357 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for StatusNotification returned an error: {1}", m_ServerURL, response.FaultString); |
370 | // reason = "XMLRPC Fault"; | 358 | // reason = "XMLRPC Fault"; |
371 | return friendsOnline; | 359 | return friendsOnline; |
372 | } | 360 | } |
@@ -378,7 +366,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
378 | { | 366 | { |
379 | if (hash == null) | 367 | if (hash == null) |
380 | { | 368 | { |
381 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost); | 369 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); |
382 | // reason = "Internal error 1"; | 370 | // reason = "Internal error 1"; |
383 | return friendsOnline; | 371 | return friendsOnline; |
384 | } | 372 | } |
@@ -431,14 +419,14 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
431 | } | 419 | } |
432 | catch | 420 | catch |
433 | { | 421 | { |
434 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURLHost); | 422 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetOnlineFriends", m_ServerURL); |
435 | // reason = "Exception: " + e.Message; | 423 | // reason = "Exception: " + e.Message; |
436 | return online; | 424 | return online; |
437 | } | 425 | } |
438 | 426 | ||
439 | if (response.IsFault) | 427 | if (response.IsFault) |
440 | { | 428 | { |
441 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURLHost, response.FaultString); | 429 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetOnlineFriends returned an error: {1}", m_ServerURL, response.FaultString); |
442 | // reason = "XMLRPC Fault"; | 430 | // reason = "XMLRPC Fault"; |
443 | return online; | 431 | return online; |
444 | } | 432 | } |
@@ -450,7 +438,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
450 | { | 438 | { |
451 | if (hash == null) | 439 | if (hash == null) |
452 | { | 440 | { |
453 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost); | 441 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetOnlineFriends Got null response from {0}! THIS IS BAAAAD", m_ServerURL); |
454 | // reason = "Internal error 1"; | 442 | // reason = "Internal error 1"; |
455 | return online; | 443 | return online; |
456 | } | 444 | } |
@@ -559,13 +547,13 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
559 | 547 | ||
560 | if (!hash.ContainsKey("UUID")) | 548 | if (!hash.ContainsKey("UUID")) |
561 | { | 549 | { |
562 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURLHost)); | 550 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} didn't return a UUID", m_ServerURL)); |
563 | } | 551 | } |
564 | 552 | ||
565 | UUID uuid; | 553 | UUID uuid; |
566 | if (!UUID.TryParse(hash["UUID"].ToString(), out uuid)) | 554 | if (!UUID.TryParse(hash["UUID"].ToString(), out uuid)) |
567 | { | 555 | { |
568 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURLHost, hash["UUID"].ToString())); | 556 | throw new Exception(string.Format("[USER AGENT CONNECTOR]: get_uuid call to {0} returned an invalid UUID: {1}", m_ServerURL, hash["UUID"].ToString())); |
569 | } | 557 | } |
570 | 558 | ||
571 | return uuid; | 559 | return uuid; |
@@ -573,26 +561,22 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
573 | 561 | ||
574 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) | 562 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) |
575 | { | 563 | { |
576 | //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURLHost); | 564 | //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); |
577 | XmlRpcResponse response = null; | 565 | XmlRpcResponse response = null; |
578 | try | 566 | try |
579 | { | 567 | { |
580 | // We can not use m_ServerURL here anymore because it causes | 568 | response = request.Send(m_ServerURL, 10000); |
581 | // the HTTP request to be built without a host name. This messes | ||
582 | // with OSGrid's NGINX and can make OSGrid avatars unable to TP | ||
583 | // to other grids running recent mono. | ||
584 | response = request.Send(m_ServerURLHost, 10000); | ||
585 | } | 569 | } |
586 | catch (Exception e) | 570 | catch (Exception e) |
587 | { | 571 | { |
588 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURLHost); | 572 | m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetBoolResponse", m_ServerURL); |
589 | reason = "Exception: " + e.Message; | 573 | reason = "Exception: " + e.Message; |
590 | return false; | 574 | return false; |
591 | } | 575 | } |
592 | 576 | ||
593 | if (response.IsFault) | 577 | if (response.IsFault) |
594 | { | 578 | { |
595 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURLHost, response.FaultString); | 579 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetBoolResponse returned an error: {1}", m_ServerURL, response.FaultString); |
596 | reason = "XMLRPC Fault"; | 580 | reason = "XMLRPC Fault"; |
597 | return false; | 581 | return false; |
598 | } | 582 | } |
@@ -604,7 +588,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
604 | { | 588 | { |
605 | if (hash == null) | 589 | if (hash == null) |
606 | { | 590 | { |
607 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURLHost); | 591 | m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got null response from {0}! THIS IS BAAAAD", m_ServerURL); |
608 | reason = "Internal error 1"; | 592 | reason = "Internal error 1"; |
609 | return false; | 593 | return false; |
610 | } | 594 | } |
@@ -615,7 +599,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
615 | else | 599 | else |
616 | { | 600 | { |
617 | reason = "Internal error 2"; | 601 | reason = "Internal error 2"; |
618 | m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURLHost); | 602 | m_log.WarnFormat("[USER AGENT CONNECTOR]: response from {0} does not have expected key 'result'", m_ServerURL); |
619 | } | 603 | } |
620 | 604 | ||
621 | return success; | 605 | return success; |