Commit 09822702 authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Refined the logging a bit

parent 7c818da6
...@@ -65,7 +65,7 @@ import de.measite.minidns.record.Data; ...@@ -65,7 +65,7 @@ import de.measite.minidns.record.Data;
*/ */
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class DNSTCPProxy extends DNSProxy{ public class DNSTCPProxy extends DNSProxy{
private static final String LOG_TAG = "[DNSUDPProxy]"; private static final String LOG_TAG = "[DNSTCPProxy]";
private FileDescriptor interruptedDescriptor = null; private FileDescriptor interruptedDescriptor = null;
private FileDescriptor blockingDescriptor = null; private FileDescriptor blockingDescriptor = null;
private ParcelFileDescriptor parcelFileDescriptor; private ParcelFileDescriptor parcelFileDescriptor;
...@@ -256,10 +256,12 @@ public class DNSTCPProxy extends DNSProxy{ ...@@ -256,10 +256,12 @@ public class DNSTCPProxy extends DNSProxy{
} }
private void sendPacketToUpstreamDNSServer(DatagramPacket outgoingPacket, IpPacket ipPacket){ private void sendPacketToUpstreamDNSServer(DatagramPacket outgoingPacket, IpPacket ipPacket){
LogFactory.writeMessage(vpnService, LOG_TAG,"Writing packet to upstream: " + outgoingPacket);
try{ try{
Socket socket = SocketChannel.open().socket(); Socket socket = SocketChannel.open().socket();
vpnService.protect(socket); //The sent packets shouldn't be handled by this class vpnService.protect(socket); //The sent packets shouldn't be handled by this class
outgoingPacket.setPort(upstreamServers.get(outgoingPacket.getAddress().getHostAddress())); outgoingPacket.setPort(upstreamServers.get(outgoingPacket.getAddress().getHostAddress()));
LogFactory.writeMessage(vpnService, LOG_TAG, "Connecting to " + outgoingPacket + "(PORT: " + outgoingPacket.getPort() + ")");
socket.connect(outgoingPacket.getSocketAddress(),timeout); socket.connect(outgoingPacket.getSocketAddress(),timeout);
byte[] data = ipPacket == null ? new byte[0] : outgoingPacket.getData(); byte[] data = ipPacket == null ? new byte[0] : outgoingPacket.getData();
DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream()); DataOutputStream outputStream = new DataOutputStream(socket.getOutputStream());
...@@ -271,8 +273,10 @@ public class DNSTCPProxy extends DNSProxy{ ...@@ -271,8 +273,10 @@ public class DNSTCPProxy extends DNSProxy{
outputStream.close(); //Closes the associated socket outputStream.close(); //Closes the associated socket
} }
}catch(IOException exception){ }catch(IOException exception){
if(!(exception instanceof SocketTimeoutException))handleUpstreamDNSResponse(ipPacket, outgoingPacket.getData()); if(!(exception instanceof SocketTimeoutException)){
LogFactory.writeStackTrace(vpnService, LOG_TAG, exception); LogFactory.writeStackTrace(vpnService, LOG_TAG, exception);
handleUpstreamDNSResponse(ipPacket, outgoingPacket.getData());
}
} }
} }
......
...@@ -323,6 +323,7 @@ public class DNSUDPProxy extends DNSProxy{ ...@@ -323,6 +323,7 @@ public class DNSUDPProxy extends DNSProxy{
} }
upstreamServers.clear(); upstreamServers.clear();
writeToDevice.clear(); writeToDevice.clear();
if(resolver != null) resolver.destroy(); if(resolver != null) resolver.destroy();
if(queryLogger != null) queryLogger.destroy(); if(queryLogger != null) queryLogger.destroy();
LogFactory.writeMessage(vpnService, LOG_TAG, "Everything was destructed."); LogFactory.writeMessage(vpnService, LOG_TAG, "Everything was destructed.");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment