Skip to content

Commit

Permalink
Show message and continue on unknown host in password
Browse files Browse the repository at this point in the history
  • Loading branch information
arbruijn committed Mar 18, 2019
1 parent 2cd75ec commit ad30f74
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions olproxy/Program.cs
Expand Up @@ -172,7 +172,7 @@ class ParsedMessage
"\\\\\"password\\\\\":\\{\\\\\"attributeType\\\\\":\\\\\"STRING_LIST\\\\\",\\\\\"valueAttribute\\\\\":\\[\\\\\"([^\"]+)\\\\\"\\]}"
);

private static IPAddress FindPasswordAddress(string password, out string name)
private IPAddress FindPasswordAddress(string password, out string name)
{
var i = password.IndexOf('_'); // allow password suffix with '_'
name = i == -1 ? password : password.Substring(0, i);
Expand All @@ -181,8 +181,14 @@ private static IPAddress FindPasswordAddress(string password, out string name)
if (new Regex(@"\d{1,3}([.]\d{1,3}){3}").IsMatch(name) &&
IPAddress.TryParse(name, out IPAddress adr))
return adr;
var adrs = Dns.GetHostAddresses(name);
return adrs == null || adrs.Length == 0 ? null : adrs[0];
try {
var adrs = Dns.GetHostAddresses(name);
return adrs == null || adrs.Length == 0 ? null : adrs[0];
} catch (SocketException ex) {
AddMessage("Cannot find " + name + ": " + ex.Message);
} catch (Exception) {
}
return null;
}

private static ParsedMessage ParseMessage(string message)
Expand Down

0 comments on commit ad30f74

Please sign in to comment.