2025-12-11 11:09:04 +01:00
|
|
|
/*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
|
2025-11-03 18:33:59 +01:00
|
|
|
package org.openautonomousconnection.dns;
|
|
|
|
|
|
2025-12-11 11:09:04 +01:00
|
|
|
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;
|
2025-11-03 18:33:59 +01:00
|
|
|
|
2025-12-11 11:09:04 +01:00
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
import java.sql.SQLException;
|
2025-11-03 18:33:59 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2025-12-11 11:09:04 +01:00
|
|
|
public class Server extends ProtocolServer {
|
2025-11-03 18:33:59 +01:00
|
|
|
@Override
|
2025-12-11 11:09:04 +01:00
|
|
|
public List<Domain> getDomains() throws SQLException {
|
|
|
|
|
return DomainManager.getDomains();
|
2025-11-03 18:33:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-12-11 11:09:04 +01:00
|
|
|
public List<String> getTopLevelDomains() throws SQLException {
|
|
|
|
|
return DomainManager.getTopLevelDomains();
|
2025-11-03 18:33:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-12-11 11:09:04 +01:00
|
|
|
public void handleMessage(ConnectionHandler connectionHandler, String message) {
|
|
|
|
|
System.out.println("[MESSAGE] " + connectionHandler.getClientID() + ": " + message);
|
2025-11-03 18:33:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-12-11 11:09:04 +01:00
|
|
|
public String getInfoSite(String topLevelDomain) throws SQLException {
|
|
|
|
|
if (!topLevelDomainExists(topLevelDomain)) return null;
|
2025-11-03 18:33:59 +01:00
|
|
|
|
2025-12-11 11:09:04 +01:00
|
|
|
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;
|
2025-11-03 18:33:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-12-11 11:09:04 +01:00
|
|
|
public String getInterfaceSite() {
|
|
|
|
|
return Config.getInterfaceSite();
|
2025-11-03 18:33:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2025-12-11 11:09:04 +01:00
|
|
|
public String getDNSServerInfoSite() {
|
|
|
|
|
return Config.getInfoSite();
|
2025-11-03 18:33:59 +01:00
|
|
|
}
|
|
|
|
|
}
|