|
@@ -30,9 +30,9 @@ namespace DnsForwarder
|
|
|
}
|
|
|
|
|
|
Console.WriteLine("Starting...");
|
|
|
- Console.WriteLine($"Default Server:{_defaultDns = args[0]}");
|
|
|
- Console.WriteLine($"China DNS Server:{_cnDns = args[1]}");
|
|
|
- Console.WriteLine($"dnsmasq-china-list file:{args[2]}");
|
|
|
+ Console.WriteLine($"Default Server: {_defaultDns = args[0]}");
|
|
|
+ Console.WriteLine($".CN DNS Server: {_cnDns = args[1]}");
|
|
|
+ Console.WriteLine($"dnsmasq-china-list: {args[2]}");
|
|
|
|
|
|
Console.WriteLine("Loading list file...");
|
|
|
LoadListFile(args[2]);
|
|
@@ -70,10 +70,16 @@ namespace DnsForwarder
|
|
|
|
|
|
var target = MatchServer(domain);
|
|
|
|
|
|
- _consoleOutout.Add($"{DateTime.Now:yyyyMMdd HH:mm:ss} {from} [{target}]\t{domain}");
|
|
|
-
|
|
|
- var dnsResponse = GetDnsResponse(buf, count, target);
|
|
|
- if (dnsResponse != null) _listener.SendTo(dnsResponse, from);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var dnsResponse = GetDnsResponse(buf, count, target);
|
|
|
+ if (dnsResponse != null) _listener.SendTo(dnsResponse, from);
|
|
|
+ _consoleOutout.Add($"{DateTime.Now:yyyyMMdd HH:mm:ss} {from} [{target}]\t{domain}");
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ _consoleOutout.Add($"{DateTime.Now:yyyyMMdd HH:mm:ss} {from} [{target}]\t{domain} ERR:{e.Message}");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
protected static string ExtractDomainName(byte[] buf, int count)
|