65 lines
2.7 KiB
Java
65 lines
2.7 KiB
Java
|
|
package org.openautonomousconnection.dns;
|
||
|
|
|
||
|
|
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||
|
|
import org.openautonomousconnection.protocol.side.dns.ConnectedProtocolClient;
|
||
|
|
import org.openautonomousconnection.protocol.side.dns.ProtocolDNSServer;
|
||
|
|
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.DNSResponseCode;
|
||
|
|
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.Domain;
|
||
|
|
|
||
|
|
import java.io.File;
|
||
|
|
import java.io.IOException;
|
||
|
|
import java.security.cert.CertificateException;
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
public class Server extends ProtocolDNSServer {
|
||
|
|
/**
|
||
|
|
* Constructs a ProtocolDNSServer with the specified configuration file.
|
||
|
|
*
|
||
|
|
* @throws IOException If an I/O error occurs.
|
||
|
|
* @throws CertificateException If a certificate error occurs.
|
||
|
|
*/
|
||
|
|
public Server() throws IOException, CertificateException {
|
||
|
|
super(new File("config.properties"));
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public List<Domain> getDomains() {
|
||
|
|
return List.of();
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String getDomainDestination(Domain domain) {
|
||
|
|
return "";
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String getSubnameDestination(Domain domain, String subname) {
|
||
|
|
return "";
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public String getTLNInfoSite(String topLevelName) {
|
||
|
|
return "";
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public DNSResponseCode validateDomain(Domain requestedDomain) {
|
||
|
|
if (!requestedDomain.getProtocol().equalsIgnoreCase("oac")) return DNSResponseCode.RESPONSE_INVALID_REQUEST;
|
||
|
|
return DNSResponseCode.RESPONSE_DOMAIN_FULLY_NOT_EXIST;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void validationPacketSendFailed(Domain domain, ConnectedProtocolClient client, Exception exception) {
|
||
|
|
ProtocolBridge.getInstance().getLogger().exception("Failed to send ValidationPacket. (" +
|
||
|
|
"Domain: " + domain.getProtocol() + "." + (domain.hasSubname() ? domain.getSubname() : "") + "." + domain.getTopLevelName() + "/" + domain.getPath() + "?" + domain.getQuery() + "#" + domain.getFragment() + ";" +
|
||
|
|
";Client: " + client.getConnectionHandler().getClientID() + ")", exception);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void domainDestinationPacketFailedSend(ConnectedProtocolClient client, Domain domain, DNSResponseCode validationResponse, Exception exception) {
|
||
|
|
ProtocolBridge.getInstance().getLogger().exception("Failed to send DomainDestinationPacket. (" +
|
||
|
|
"Domain: " + domain.getProtocol() + "." + (domain.hasSubname() ? domain.getSubname() : "") + "." + domain.getTopLevelName() + "/" + domain.getPath() + "?" + domain.getQuery() + "#" + domain.getFragment() + ";" +
|
||
|
|
"Validation response: " + validationResponse + ";Client: " + client.getConnectionHandler().getClientID() + ")", exception);
|
||
|
|
}
|
||
|
|
}
|