Updated to latest Protocol Version
This commit is contained in:
@@ -4,7 +4,6 @@ import dev.unlegitdqrk.unlegitlibrary.file.ConfigurationManager;
|
||||
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSRecord;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.INSRecordType;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.classic.helper.TargetName;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -24,48 +23,18 @@ public final class DatabaseINSServer extends ProtocolINSServer {
|
||||
private final String jdbcUser;
|
||||
private final String jdbcPassword;
|
||||
|
||||
private final ConfigurationManager config;
|
||||
|
||||
/**
|
||||
* Creates a new database-backed INS server.
|
||||
*
|
||||
* @throws IOException If the base server initialization fails.
|
||||
* @throws CertificateException If required certificate files are missing or invalid.
|
||||
*/
|
||||
public DatabaseINSServer() throws Exception {
|
||||
super(new File("config.properties"));
|
||||
public DatabaseINSServer(String insInfoSite, String insFrontendSite, int tcpPort, int udpPort, String jdbcUrl, String jdbcUser, String jdbcPassword) throws Exception {
|
||||
super(insInfoSite, insFrontendSite, tcpPort, udpPort);
|
||||
|
||||
config = new ConfigurationManager(new File("config.properties"));
|
||||
config.loadProperties();
|
||||
|
||||
if (!config.isSet("db.url")) {
|
||||
config.set(
|
||||
"db.url",
|
||||
"jdbc:mysql://localhost:3306/ins?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC"
|
||||
);
|
||||
config.saveProperties();
|
||||
}
|
||||
|
||||
if (!config.isSet("db.user")) {
|
||||
config.set("db.user", "username");
|
||||
config.saveProperties();
|
||||
}
|
||||
|
||||
if (!config.isSet("db.password")) {
|
||||
config.set("db.password", "password");
|
||||
config.saveProperties();
|
||||
}
|
||||
|
||||
if (!config.isSet("port")) {
|
||||
config.set("port", 1023);
|
||||
config.saveProperties();
|
||||
}
|
||||
|
||||
jdbcUrl = config.getString("db.url");
|
||||
jdbcUser = config.getString("db.user");
|
||||
jdbcPassword = config.getString("db.password");
|
||||
|
||||
Main.getSettings().port = config.getInt("port");
|
||||
this.jdbcUrl = jdbcUrl;
|
||||
this.jdbcUser = jdbcUser;
|
||||
this.jdbcPassword = jdbcPassword;
|
||||
}
|
||||
|
||||
private Connection openConnection() throws SQLException {
|
||||
@@ -200,9 +169,9 @@ public final class DatabaseINSServer extends ProtocolINSServer {
|
||||
|
||||
// recurse on the target name to fetch the original requested type
|
||||
List<INSRecord> resolvedTarget = resolveInternal(
|
||||
target.tln(),
|
||||
target.name(),
|
||||
target.sub(),
|
||||
target.tln,
|
||||
target.name,
|
||||
target.sub,
|
||||
requestedType,
|
||||
depth + 1,
|
||||
visited
|
||||
@@ -363,4 +332,17 @@ public final class DatabaseINSServer extends ProtocolINSServer {
|
||||
|
||||
return new TargetName(tln, name, sub);
|
||||
}
|
||||
|
||||
private static final class TargetName {
|
||||
final String tln;
|
||||
final String name;
|
||||
final String sub;
|
||||
|
||||
TargetName(String tln, String name, String sub) {
|
||||
this.tln = tln;
|
||||
this.name = name;
|
||||
this.sub = sub;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user