DNS over TLS is functional
This commit is contained in:
parent
b794722a5b
commit
27b50054c1
@ -1,8 +1,6 @@
|
|||||||
package org.itxtech.daedalus.provider;
|
package org.itxtech.daedalus.provider;
|
||||||
|
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.system.ErrnoException;
|
|
||||||
import android.system.OsConstants;
|
|
||||||
import org.itxtech.daedalus.service.DaedalusVpnService;
|
import org.itxtech.daedalus.service.DaedalusVpnService;
|
||||||
import org.itxtech.daedalus.util.Logger;
|
import org.itxtech.daedalus.util.Logger;
|
||||||
import org.itxtech.daedalus.util.server.DNSServerHelper;
|
import org.itxtech.daedalus.util.server.DNSServerHelper;
|
||||||
@ -10,10 +8,8 @@ import org.pcap4j.packet.IpPacket;
|
|||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Daedalus Project
|
* Daedalus Project
|
||||||
@ -32,12 +28,13 @@ public class TlsProvider extends TcpProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket) throws DaedalusVpnService.VpnNetworkException {
|
protected void forwardPacket(DatagramPacket outPacket, IpPacket parsedPacket) {
|
||||||
Socket dnsSocket;
|
Socket dnsSocket;
|
||||||
try {
|
try {
|
||||||
dnsSocket = SSLContext.getInstance("TLSv1.2").getSocketFactory()
|
SSLContext context = SSLContext.getInstance("TLSv1.2");
|
||||||
.createSocket(outPacket.getAddress(),
|
context.init(null, null, null);
|
||||||
DNSServerHelper.getPortOrDefault(outPacket.getAddress(), outPacket.getPort()));
|
dnsSocket = context.getSocketFactory().createSocket(outPacket.getAddress(),
|
||||||
|
DNSServerHelper.getPortOrDefault(outPacket.getAddress(), outPacket.getPort()));
|
||||||
//Create TLS v1.2 socket
|
//Create TLS v1.2 socket
|
||||||
|
|
||||||
service.protect(dnsSocket);
|
service.protect(dnsSocket);
|
||||||
@ -53,15 +50,8 @@ public class TlsProvider extends TcpProvider{
|
|||||||
} else {
|
} else {
|
||||||
dnsSocket.close();
|
dnsSocket.close();
|
||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException e){
|
} catch (Exception e) {
|
||||||
Logger.logException(e);
|
Logger.logException(e);
|
||||||
} catch (IOException e) {
|
|
||||||
if (e.getCause() instanceof ErrnoException) {
|
|
||||||
ErrnoException errnoExc = (ErrnoException) e.getCause();
|
|
||||||
if ((errnoExc.errno == OsConstants.ENETUNREACH) || (errnoExc.errno == OsConstants.EPERM)) {
|
|
||||||
throw new DaedalusVpnService.VpnNetworkException("Cannot send message:", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user