Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Ignore parsing exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
stackia committed Mar 7, 2015
1 parent 7ab37ff commit 7b0d8ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion DNSAgent/DnsAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ public async void ReceiveMessage(Semaphore connectionPool)
try
{
var query = await UdpListener.ReceiveAsync();
var message = DnsMessage.Parse(query.Buffer);
DnsMessage message;
try
{
message = DnsMessage.Parse(query.Buffer);
}
catch (Exception)
{
throw new ParsingException();
}
var targetNameServer = Options.DefaultNameServer;
if (Options.QueryTimeout == null)
throw new NullReferenceException();
Expand Down Expand Up @@ -113,6 +121,9 @@ public async void ReceiveMessage(Semaphore connectionPool)
if (e.SocketErrorCode != SocketError.ConnectionReset)
Logger.Error("Unexpected socket error:\n{0}", e);
}
catch (ParsingException)
{
}
catch (Exception e)
{
Logger.Error("Unexpected exception:\n{0}", e);
Expand Down
2 changes: 2 additions & 0 deletions DNSAgent/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public InfiniteForwardingException(DnsQuestion question)

public DnsQuestion Question { get; set; }
}

internal class ParsingException : Exception {}
}

0 comments on commit 7b0d8ed

Please sign in to comment.