Moved classic code to classic branch
This commit is contained in:
@@ -1,64 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Open Autonomous Connection - All Rights Reserved
|
||||
*
|
||||
* You are unauthorized to remove this copyright.
|
||||
* You have to give Credits to the Author in your project and link this GitHub site: https://github.com/Open-Autonomous-Connection
|
||||
* See LICENSE-File if exists
|
||||
*/
|
||||
|
||||
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 dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||
import org.openautonomousconnection.dns.utils.Config;
|
||||
import org.openautonomousconnection.dns.utils.Database;
|
||||
import org.openautonomousconnection.protocol.domain.Domain;
|
||||
import org.openautonomousconnection.protocol.side.ProtocolServer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
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"));
|
||||
public class Server extends ProtocolServer {
|
||||
@Override
|
||||
public List<Domain> getDomains() throws SQLException {
|
||||
return DomainManager.getDomains();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Domain> getDomains() {
|
||||
return List.of();
|
||||
public List<String> getTopLevelDomains() throws SQLException {
|
||||
return DomainManager.getTopLevelDomains();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDomainDestination(Domain domain) {
|
||||
return "";
|
||||
public void handleMessage(ConnectionHandler connectionHandler, String message) {
|
||||
System.out.println("[MESSAGE] " + connectionHandler.getClientID() + ": " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubnameDestination(Domain domain, String subname) {
|
||||
return "";
|
||||
public String getInfoSite(String topLevelDomain) throws SQLException {
|
||||
if (!topLevelDomainExists(topLevelDomain)) return null;
|
||||
|
||||
ResultSet resultSet = Database.getConnection().prepareStatement("SELECT name, info FROM topleveldomains").executeQuery();
|
||||
while (resultSet.next()) if (resultSet.getString("name").equals(topLevelDomain)) return resultSet.getString("info");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTLNInfoSite(String topLevelName) {
|
||||
return "";
|
||||
public String getInterfaceSite() {
|
||||
return Config.getInterfaceSite();
|
||||
}
|
||||
|
||||
@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);
|
||||
public String getDNSServerInfoSite() {
|
||||
return Config.getInfoSite();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user