public string ResolveConfigurationServer(string OverlayName) {
if (ReloadGlobals.ForceLocalConfig)
return null;
/* Need to know about DNS servers available */
try {
m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_INFO, "Resolving Configuration server...");
#if WINDOWS_PHONE
// HACK: Windows Phone doesn't support DNS lookups, so fake it
string enrollment_url = String.Format("enroll.{0}.org", OverlayName);
m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_TOPO, String.Format("DNS SRV lookup faked: http://{0}", enrollment_url));
// Be sure to use HTTP instead of HTTPS
#if IETF83_ENROLL
return String.Format("http://{0}/.well-known/p2psip-enroll", enrollment_url);
#else
return String.Format("http://{0}/p2psip/enroll/", enrollment_url);
#endif
#else
List<string> s_dnsServerAddrList = new List<string>();
if (ReloadGlobals.DNS_Address != null && ReloadGlobals.DNS_Address.Length != 0)
if (!s_dnsServerAddrList.Contains(ReloadGlobals.DNS_Address))
s_dnsServerAddrList.Add(ReloadGlobals.DNS_Address);
foreach (string s_dnsServerAddr in s_dnsServerAddrList) {
DnsQueryRequest dnsQuery = new DnsQueryRequest();
DnsQueryResponse dnsResponse = dnsQuery.Resolve(s_dnsServerAddr, String.Format("_reload-config._tcp.{0}", OverlayName), DnDns.Enums.NsType.SRV, DnDns.Enums.NsClass.INET, ProtocolType.Udp); //--joscha
if (dnsResponse != null)
foreach (IDnsRecord record in dnsResponse.Answers) {
string[] lines = System.Text.RegularExpressions.Regex.Split(record.Answer, "\r\n");
//m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_INFO, String.Format("DNS SRV lookup returned {0}", record.Answer));
foreach (string line in lines) {
if (line.StartsWith("HostName")) {
string[] lines2 = System.Text.RegularExpressions.Regex.Split(line, " ");
string enrollment_url = lines2[1].TrimEnd('.');
m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_TOPO, String.Format("DNS SRV lookup returned: https://{0}", enrollment_url));
return String.Format("https://{0}/.well-known/reload-config", enrollment_url);
}
}
}
}
#endif
}
catch (Exception ex) {
m_ReloadConfig.Logger(ReloadGlobals.TRACEFLAGS.T_ERROR, String.Format("DNS SRV for p2psip_enroll failed: {0}", ex.Message));
}
return null;
}