Files
INSServer/src/main/java/org/openautonomousconnection/dns/Server.java
2025-12-11 11:09:04 +01:00

57 lines
1.8 KiB
Java

/*
* 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 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.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class Server extends ProtocolServer {
@Override
public List<Domain> getDomains() throws SQLException {
return DomainManager.getDomains();
}
@Override
public List<String> getTopLevelDomains() throws SQLException {
return DomainManager.getTopLevelDomains();
}
@Override
public void handleMessage(ConnectionHandler connectionHandler, String message) {
System.out.println("[MESSAGE] " + connectionHandler.getClientID() + ": " + message);
}
@Override
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 getInterfaceSite() {
return Config.getInterfaceSite();
}
@Override
public String getDNSServerInfoSite() {
return Config.getInfoSite();
}
}