9 Commits

Author SHA1 Message Date
UnlegitDqrk
aeadf55ec9 Updated frontend 2026-03-02 18:41:19 +01:00
UnlegitDqrk
740e85fa3f Updated to latest Protocol build 2026-02-28 15:51:18 +01:00
UnlegitDqrk
357b30b037 Updated to latest Protocol build 2026-02-28 15:50:38 +01:00
UnlegitDqrk
f81cb0ee15 Updated frontend to new Protocol 2026-02-27 20:40:59 +01:00
UnlegitDqrk
09dd207bb1 Updated frontend to new Protocol 2026-02-22 17:21:23 +01:00
UnlegitDqrk
2d829fe341 Updated to lates Protocol 2026-02-22 16:15:22 +01:00
UnlegitDqrk
de22a8ab67 Updated to lates Protocol 2026-02-22 16:08:16 +01:00
UnlegitDqrk
a365b57638 Removed unused licenses 2026-02-14 19:22:18 +01:00
UnlegitDqrk
eda1b24a26 Small bug fix 2026-02-14 17:25:22 +01:00
13 changed files with 412 additions and 341 deletions

2
.idea/misc.xml generated
View File

@@ -8,7 +8,7 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="23" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@@ -1 +1,2 @@
Please read the license here: https://open-autonomous-connection.org/license.html Please read the license here: https://open-autonomous-connection.org/license.html
Download all third parties licenses here: https://open-autonomous-connection.org/assets/licenses.zip

View File

@@ -10,7 +10,8 @@ This project (OAC) is licensed under
the [Open Autonomous Public License (OAPL)](https://open-autonomous-connection.org/license.html). the [Open Autonomous Public License (OAPL)](https://open-autonomous-connection.org/license.html).
**Third-party components:** **Third-party components:**
<br />
Download all license here: https://open-autonomous-connection.org/assets/licenses.zip
- *UnlegitLibrary* is authored by the same copyright holder and is used here under a special agreement: - *UnlegitLibrary* is authored by the same copyright holder and is used here under a special agreement:
While [UnlegitLibrary](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/) is generally distributed under While [UnlegitLibrary](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/) is generally distributed under
the [GNU GPLv3](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/src/branch/master/LICENSE), the [GNU GPLv3](https://repo.unlegitdqrk.dev/UnlegitDqrk/unlegitlibrary/src/branch/master/LICENSE),

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.openautonomousconnection</groupId> <groupId>org.openautonomousconnection</groupId>
<artifactId>INSServer</artifactId> <artifactId>INSServer</artifactId>
<version>1.0.0-BETA.1.0</version> <version>1.0.1-BETA.0.3</version>
<description>The default INS-Server</description> <description>The default INS-Server</description>
<url>https://open-autonomous-connection.org/</url> <url>https://open-autonomous-connection.org/</url>
<issueManagement> <issueManagement>
@@ -37,44 +37,6 @@
<name>Open Autonomous Public License (OAPL)</name> <name>Open Autonomous Public License (OAPL)</name>
<url>https://open-autonomous-connection.org/license.html</url> <url>https://open-autonomous-connection.org/license.html</url>
</license> </license>
<license>
<name>GNU General Public License v3.0</name>
<url>https://www.gnu.org/licenses/gpl-3.0.html</url>
<comments>Default license: Applies to all users and projects unless an explicit alternative license has been
granted.</comments>
</license>
<license>
<name>LPGL 3</name>
<url>https://www.gnu.org/licenses/lgpl-3.0.html#license-text</url>
</license>
<license>
<name>LPGL 2.1</name>
<url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.en#SEC1</url>
</license>
<license>
<name>WTPL License</name>
<url>https://github.com/ronmamo/reflections/tree/master?tab=WTFPL-1-ov-file</url>
</license>
<license>
<name>Apache License 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
<license>
<name>MIT License</name>
<url>https://opensource.org/license/mit</url>
</license>
<license>
<name>javassist</name>
<url>https://github.com/jboss-javassist/javassist/blob/master/License.html</url>
</license>
<license>
<name>projectlombok</name>
<url>https://github.com/projectlombok/lombok?tab=License-1-ov-file</url>
</license>
<license>
<name>mariadb</name>
<url>https://mariadb.com/docs/general-resources/community/community/faq/licensing-questions/licensing-faq</url>
</license>
</licenses> </licenses>
<organization> <organization>
<name>Open Autonomous Connection</name> <name>Open Autonomous Connection</name>
@@ -105,6 +67,13 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version> <version>3.13.0</version>
<configuration> <configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
</path>
</annotationProcessorPaths>
<compilerArgs> <compilerArgs>
<arg>--add-exports</arg> <arg>--add-exports</arg>
<arg>java.base/sun.security.x509=ALL-UNNAMED</arg> <arg>java.base/sun.security.x509=ALL-UNNAMED</arg>
@@ -143,17 +112,9 @@
<url>https://repo.open-autonomous-connection.org/api/packages/open-autonomous-connection/maven</url> <url>https://repo.open-autonomous-connection.org/api/packages/open-autonomous-connection/maven</url>
</repository> </repository>
</repositories> </repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>23</maven.compiler.target> <maven.compiler.target>25</maven.compiler.target>
<maven.compiler.source>23</maven.compiler.source> <maven.compiler.source>25</maven.compiler.source>
</properties> </properties>
</project> </project>

View File

@@ -2,22 +2,24 @@ package ins.frontend;
import ins.frontend.utils.RegistrarDao; import ins.frontend.utils.RegistrarDao;
import ins.frontend.utils.WebApp; import ins.frontend.utils.WebApp;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket; import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer; import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketFlags;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketHeader;
import org.openautonomousconnection.webserver.api.Route; import org.openautonomousconnection.webserver.api.Route;
import org.openautonomousconnection.webserver.api.SessionContext;
import org.openautonomousconnection.webserver.api.WebPage; import org.openautonomousconnection.webserver.api.WebPage;
import org.openautonomousconnection.webserver.api.WebPageContext; import org.openautonomousconnection.webserver.api.WebPageContext;
import org.openautonomousconnection.webserver.utils.HeaderMaps;
import org.openautonomousconnection.webserver.utils.Html; import org.openautonomousconnection.webserver.utils.Html;
import org.openautonomousconnection.webserver.utils.MergedRequestParams; import org.openautonomousconnection.webserver.utils.MergedRequestParams;
import org.openautonomousconnection.webserver.utils.QuerySupport; import org.openautonomousconnection.webserver.utils.WebUrlUtil;
import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
/** /**
* INS registrar ins.frontend (TLN / InfoName / Records) with proper POST parameter parsing. * INS registrar dashboard (TLN / InfoName / Records) for protocol v1.0.1 resource packets.
* *
* <p>Supported actions (POST recommended for mutations):</p> * <p>Supported actions (POST recommended for mutations):</p>
* <ul> * <ul>
@@ -28,12 +30,9 @@ import java.util.Map;
* <li>delete_infoname</li> * <li>delete_infoname</li>
* <li>add_record</li> * <li>add_record</li>
* </ul> * </ul>
*
* <p>Important: Listing/editing/deleting records requires DAO methods that are not part of the provided snippet.
* This page currently supports adding records only.</p>
*/ */
@Route(path = "dashboard.html") @Route(path = "/dashboard.html")
public final class dashboard implements WebPage { public final class dashboard extends WebPage {
private static Integer normalizeNullableInt(String s) { private static Integer normalizeNullableInt(String s) {
if (s == null) return null; if (s == null) return null;
@@ -47,30 +46,26 @@ public final class dashboard implements WebPage {
} }
@Override @Override
public WebResponsePacket handle(WebPageContext ctx) throws Exception { public WebResourceResponsePacket handle(WebPageContext ctx) throws Exception {
WebApp.init(); WebApp.init();
SessionContext session = SessionContext.from( if (ctx.session == null || !ctx.session.isValid() || ctx.session.getUser() == null) {
ctx.client, return plain(ctx, 401, "Authentication required (session).");
(ProtocolWebServer) ctx.client.getServer(),
ctx.request.getHeaders()
);
if (!session.isValid() || session.getUser() == null) {
return plain(401, "Authentication required (session).");
} }
int userId; int userId;
try { try {
userId = Integer.parseInt(session.getUser()); userId = Integer.parseInt(ctx.session.getUser());
} catch (Exception e) { } catch (Exception e) {
return plain(401, "Invalid session user."); return plain(ctx, 401, "Invalid session user.");
} }
RegistrarDao dao = WebApp.get().dao(); RegistrarDao dao = WebApp.get().dao();
// Raw target and merged params (GET + POST). // Build target for param merging: "/path?query"
String rawTarget = org.openautonomousconnection.webserver.utils.QuerySupport.extractRawTarget(ctx.request); String rawTarget = WebUrlUtil.extractPathAndQuery(ctx.request.getUrl());
if (rawTarget == null) rawTarget = "/dashboard.html";
Map<String, String> headers = ctx.request.getHeaders(); Map<String, String> headers = ctx.request.getHeaders();
byte[] body = ctx.request.getBody(); byte[] body = ctx.request.getBody();
@@ -90,7 +85,7 @@ public final class dashboard implements WebPage {
} }
} }
return render(userId, msg, err, dao); return render(ctx, userId, msg, err, dao);
} }
private ActionResult executeAction(String action, MergedRequestParams p, int userId, RegistrarDao dao) throws Exception { private ActionResult executeAction(String action, MergedRequestParams p, int userId, RegistrarDao dao) throws Exception {
@@ -171,7 +166,6 @@ public final class dashboard implements WebPage {
if (!dao.isOwnerOfInfoName(infonameId, userId)) return ActionResult.err("Not owner of this infoname."); if (!dao.isOwnerOfInfoName(infonameId, userId)) return ActionResult.err("Not owner of this infoname.");
if (type.isBlank() || value == null || value.isBlank()) return ActionResult.err("Missing type/value."); if (type.isBlank() || value == null || value.isBlank()) return ActionResult.err("Missing type/value.");
// Validate allow_subdomains against TLN of this infoname (owned list contains TLN metadata).
RegistrarDao.InfoNameRow[] owned = dao.listOwnedInfoNames(userId); RegistrarDao.InfoNameRow[] owned = dao.listOwnedInfoNames(userId);
RegistrarDao.InfoNameRow row = null; RegistrarDao.InfoNameRow row = null;
for (RegistrarDao.InfoNameRow r : owned) { for (RegistrarDao.InfoNameRow r : owned) {
@@ -194,7 +188,7 @@ public final class dashboard implements WebPage {
return ActionResult.err("Unknown action: " + action); return ActionResult.err("Unknown action: " + action);
} }
private WebResponsePacket render(int userId, String msg, String err, RegistrarDao dao) throws Exception { private WebResourceResponsePacket render(WebPageContext ctx, int userId, String msg, String err, RegistrarDao dao) throws Exception {
RegistrarDao.TlnRow[] tlns = dao.listVisibleTlns(userId); RegistrarDao.TlnRow[] tlns = dao.listVisibleTlns(userId);
RegistrarDao.InfoNameRow[] owned = dao.listOwnedInfoNames(userId); RegistrarDao.InfoNameRow[] owned = dao.listOwnedInfoNames(userId);
@@ -259,7 +253,7 @@ public final class dashboard implements WebPage {
); );
String html = Html.page("INS Registrar", body); String html = Html.page("INS Registrar", body);
return new WebResponsePacket(200, "text/html", new HashMap<>(), Html.utf8(html)); return html(ctx, 200, html);
} }
private String renderTlnSection(RegistrarDao.TlnRow[] tlns, int userId) { private String renderTlnSection(RegistrarDao.TlnRow[] tlns, int userId) {
@@ -348,8 +342,33 @@ public final class dashboard implements WebPage {
return sb.toString(); return sb.toString();
} }
private WebResponsePacket plain(int code, String text) { private WebResourceResponsePacket plain(WebPageContext ctx, int code, String text) {
return new WebResponsePacket(code, "text/plain", new HashMap<>(), Html.utf8(text)); byte[] body = (text == null ? "" : text).getBytes(StandardCharsets.UTF_8);
Map<String, String> headers = HeaderMaps.mutable();
headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), code, "text/plain; charset=utf-8", headers, body, null);
}
private WebResourceResponsePacket html(WebPageContext ctx, int code, String html) {
byte[] body = Html.utf8(html);
Map<String, String> headers = HeaderMaps.mutable();
headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), code, "text/html; charset=utf-8", headers, body, null);
}
private WebPacketHeader outHeader(WebPageContext ctx) {
WebPacketHeader in = (ctx != null && ctx.request != null) ? ctx.request.getHeader() : null;
if (in == null) {
return new WebPacketHeader(0, 0, 0, 0, WebPacketFlags.RESOURCE, System.currentTimeMillis());
}
return new WebPacketHeader(
in.getRequestId(),
in.getTabId(),
in.getPageId(),
in.getFrameId(),
in.getFlags() | WebPacketFlags.RESOURCE,
System.currentTimeMillis()
);
} }
private String safeMsg(Exception e) { private String safeMsg(Exception e) {

View File

@@ -1,36 +1,59 @@
package ins.frontend; package ins.frontend;
import ins.frontend.utils.WebApp; import ins.frontend.utils.WebApp;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket; import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketFlags;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketHeader;
import org.openautonomousconnection.webserver.api.Route; import org.openautonomousconnection.webserver.api.Route;
import org.openautonomousconnection.webserver.api.WebPage; import org.openautonomousconnection.webserver.api.WebPage;
import org.openautonomousconnection.webserver.api.WebPageContext; import org.openautonomousconnection.webserver.api.WebPageContext;
import org.openautonomousconnection.webserver.utils.HeaderMaps;
import org.openautonomousconnection.webserver.utils.Html; import org.openautonomousconnection.webserver.utils.Html;
import java.util.HashMap; import java.util.Map;
/** /**
* Landing page for the registrar ins.frontend. * Landing page for INS registrar frontend (v1.0.1).
*/ */
@Route(path = "index.html") @Route(path = "/index.html")
public final class index implements WebPage { public final class index extends WebPage {
@Override @Override
public WebResponsePacket handle(WebPageContext ctx) { public WebResourceResponsePacket handle(WebPageContext ctx) {
WebApp.init(); WebApp.init();
String html = Html.page("OAC INS Registrar", """ String html = Html.page("OAC INS Registrar", """
<div class="card"> <div class="card">
<h2>OAC INS Registrar</h2> <h2>OAC INS Registrar</h2>
<p class="muted">What you want to do?</p> <p class="muted">What you want to do? You can checkout the source of this site here: https://repo.open-autonomous-connection.org/open-autonomous-connection/INSServer/</p>
<div class="col"><a href="info.html">Info</a></div><br /> <div class="col"><a href="info.html">Info</a></div><br />
<div class="row"> <div class="row">
<div class="col"><a href="login.html">Login</a></div> <div class="col"><a href="login.html">Login</a></div>
<div class="col"><a href="register.html">Register</a></div> <div class="col"><a href="register.html">Register</a></div>
<div class="col"><a href="dashboard.html">Dashboard</a></div> <div class="col"><a href="dashboard.html">Dashboard</a></div>
</div> </div>
</div> </div>
"""); """);
return new WebResponsePacket(200, "text/html", new HashMap<>(), Html.utf8(html)); byte[] body = Html.utf8(html);
Map<String, String> headers = HeaderMaps.mutable();
headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), 200, "text/html; charset=utf-8", headers, body, null);
}
private WebPacketHeader outHeader(WebPageContext ctx) {
WebPacketHeader in = (ctx != null && ctx.request != null) ? ctx.request.getHeader() : null;
if (in == null) {
return new WebPacketHeader(0, 0, 0, 0, WebPacketFlags.RESOURCE, System.currentTimeMillis());
}
return new WebPacketHeader(
in.getRequestId(),
in.getTabId(),
in.getPageId(),
in.getFrameId(),
in.getFlags() | WebPacketFlags.RESOURCE,
System.currentTimeMillis()
);
} }
} }

View File

@@ -1,25 +1,29 @@
package ins.frontend; package ins.frontend;
import ins.frontend.utils.WebApp; import ins.frontend.utils.WebApp;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket; import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketFlags;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketHeader;
import org.openautonomousconnection.webserver.api.Route; import org.openautonomousconnection.webserver.api.Route;
import org.openautonomousconnection.webserver.api.WebPage; import org.openautonomousconnection.webserver.api.WebPage;
import org.openautonomousconnection.webserver.api.WebPageContext; import org.openautonomousconnection.webserver.api.WebPageContext;
import org.openautonomousconnection.webserver.utils.HeaderMaps;
import org.openautonomousconnection.webserver.utils.Html; import org.openautonomousconnection.webserver.utils.Html;
import java.util.HashMap; import java.util.Map;
/** /**
* Landing page for the registrar ins.frontend. * Info page for INS registrar frontend (v1.0.1).
*/ */
@Route(path = "info.html") @Route(path = "/info.html")
public final class info implements WebPage { public final class info extends WebPage {
@Override @Override
public WebResponsePacket handle(WebPageContext ctx) { public WebResourceResponsePacket handle(WebPageContext ctx) {
WebApp.init(); WebApp.init();
String html = Html.page("INS Info", """ String html = Html.page("INS Info", """
<section class="card"> <section class="card">
<h2>OAC Default INS Server</h2> <h2>OAC Default INS Server</h2>
<p> <p>
@@ -30,7 +34,7 @@ public final class info implements WebPage {
<p> <p>
It provides a trusted reference point for resolving InfoNames It provides a trusted reference point for resolving InfoNames
and enables initial client connections and enables initial client connections
to the OAC ecosystem. to the OAC.
</p> </p>
<p> <p>
@@ -42,8 +46,30 @@ public final class info implements WebPage {
Note: Alternative or private INS servers may exist, but the default INS Note: Alternative or private INS servers may exist, but the default INS
server represents the official and stable reference instance. server represents the official and stable reference instance.
</p> </p>
</section> """);
return new WebResponsePacket(200, "text/html", new HashMap<>(), Html.utf8(html)); <p>Checkout the Source here: https://repo.open-autonomous-connection.org/open-autonomous-connection/INSServer/</p>
</section>
""");
byte[] body = Html.utf8(html);
Map<String, String> headers = HeaderMaps.mutable();
headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), 200, "text/html; charset=utf-8", headers, body, null);
}
private WebPacketHeader outHeader(WebPageContext ctx) {
WebPacketHeader in = (ctx != null && ctx.request != null) ? ctx.request.getHeader() : null;
if (in == null) {
return new WebPacketHeader(0, 0, 0, 0, WebPacketFlags.RESOURCE, System.currentTimeMillis());
}
return new WebPacketHeader(
in.getRequestId(),
in.getTabId(),
in.getPageId(),
in.getFrameId(),
in.getFlags() | WebPacketFlags.RESOURCE,
System.currentTimeMillis()
);
} }
} }

View File

@@ -2,46 +2,132 @@ package ins.frontend;
import ins.frontend.utils.UserDao; import ins.frontend.utils.UserDao;
import ins.frontend.utils.WebApp; import ins.frontend.utils.WebApp;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket; import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer; import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
import org.openautonomousconnection.protocol.side.web.managers.SessionManager; import org.openautonomousconnection.protocol.side.web.managers.SessionManager;
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.WebRequestMethod; import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketFlags;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketHeader;
import org.openautonomousconnection.webserver.api.Route; import org.openautonomousconnection.webserver.api.Route;
import org.openautonomousconnection.webserver.api.SessionContext;
import org.openautonomousconnection.webserver.api.WebPage; import org.openautonomousconnection.webserver.api.WebPage;
import org.openautonomousconnection.webserver.api.WebPageContext; import org.openautonomousconnection.webserver.api.WebPageContext;
import org.openautonomousconnection.webserver.utils.HeaderMaps; import org.openautonomousconnection.webserver.utils.HeaderMaps;
import org.openautonomousconnection.webserver.utils.Html; import org.openautonomousconnection.webserver.utils.Html;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
/** /**
* Login page with existing-session short-circuit. * Login page (v1.0.1).
*
* <p>Username stored in DB as plain text.</p>
*/ */
@Route(path = "/login.html") @Route(path = "/login.html")
public final class login implements WebPage { public final class login extends WebPage {
private static WebResponsePacket ok(String html) { private enum ReqMethod { GET, POST, OTHER }
return new WebResponsePacket(200, "text/html; charset=utf-8", HeaderMaps.mutable(), Html.utf8(html));
}
private static WebResponsePacket text(int code, String msg) { @Override
return new WebResponsePacket(code, "text/plain; charset=utf-8", HeaderMaps.mutable(), msg.getBytes(StandardCharsets.UTF_8)); public WebResourceResponsePacket handle(WebPageContext ctx) throws Exception {
} WebApp.init();
private static WebResponsePacket redirect302(String location, String session) { // If a valid session already exists -> go dashboard (keep session)
Map<String, String> headers = HeaderMaps.mutable(); if (ctx.session != null && ctx.session.isValid() && ctx.session.getUser() != null) {
headers.put("location", location); return redirect302(ctx, "dashboard.html", ctx.session.getSessionId());
if (session != null && !session.isBlank()) {
headers.put("Location", "dashboard.html");
headers.put("Set-Cookie", "session=" + session + "; Path=/; HttpOnly; SameSite=Lax");
headers.put("session", session);
headers.put("cookie", session);
} }
return new WebResponsePacket(302, "text/plain; charset=utf-8", headers, new byte[0]);
ReqMethod method = detectMethod(ctx);
if (method == ReqMethod.GET) {
return ok(ctx, renderForm(null));
}
if (method != ReqMethod.POST) {
return text(ctx, 405, "Method Not Allowed");
}
String contentType = headerIgnoreCase(ctx.request.getHeaders(), "content-type");
String ctLower = (contentType == null) ? "" : contentType.toLowerCase(Locale.ROOT);
if (!ctLower.startsWith("application/x-www-form-urlencoded")) {
return ok(ctx, renderForm("Unsupported content-type: " + Html.esc(contentType)));
}
Map<String, List<String>> form = parseFormUrlEncoded(ctx.request.getBody());
String username = first(form, "username");
String password = first(form, "password");
if (username == null || password == null) {
return ok(ctx, renderForm("Missing username/password."));
}
String lookupUsername = username.trim();
UserDao.UserRow user = WebApp.get().users().findByUsername(lookupUsername).orElse(null);
if (user == null) {
return ok(ctx, renderForm("Invalid credentials."));
}
boolean okPw = WebApp.get().passwordHasher().verify(password, user.passwordEncoded());
if (!okPw) {
return ok(ctx, renderForm("Invalid credentials."));
}
String ip = resolveIp(ctx);
String ua = headerIgnoreCase(ctx.request.getHeaders(), "user-agent");
if (ua == null) ua = "";
String session = SessionManager.create(
String.valueOf(user.id()),
ip,
ua,
(ProtocolWebServer) ctx.client.getServer()
);
return redirect302(ctx, "dashboard.html", session);
}
private ReqMethod detectMethod(WebPageContext ctx) {
// Preferred: request.getMethod() via reflection (avoids depending on specific enum package).
try {
Method m = ctx.request.getClass().getMethod("getMethod");
Object v = m.invoke(ctx.request);
if (v != null) {
String s = String.valueOf(v).trim().toUpperCase(Locale.ROOT);
if ("GET".equals(s)) return ReqMethod.GET;
if ("POST".equals(s)) return ReqMethod.POST;
return ReqMethod.OTHER;
}
} catch (Exception ignored) {
// Fall back below.
}
// Fallback: treat presence of body as POST-like.
byte[] body = ctx.request.getBody();
if (body != null && body.length > 0) return ReqMethod.POST;
return ReqMethod.GET;
}
private static WebResourceResponsePacket ok(WebPageContext ctx, String html) {
byte[] body = Html.utf8(html);
Map<String, String> headers = HeaderMaps.mutable();
headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), 200, "text/html; charset=utf-8", headers, body, null);
}
private static WebResourceResponsePacket text(WebPageContext ctx, int code, String msg) {
byte[] body = (msg == null ? "" : msg).getBytes(StandardCharsets.UTF_8);
Map<String, String> headers = HeaderMaps.mutable();
headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), code, "text/plain; charset=utf-8", headers, body, null);
}
private static WebResourceResponsePacket redirect302(WebPageContext ctx, String location, String session) {
Map<String, String> headers = HeaderMaps.mutable();
headers.put("Location", location);
if (session != null && !session.isBlank()) {
headers.put("Set-Cookie", "session=" + session + "; Path=/; HttpOnly; SameSite=Lax");
// optional fallback for stacks that read a direct header:
headers.put("session", session);
}
return new WebResourceResponsePacket(outHeader(ctx), 302, "text/plain; charset=utf-8", headers, new byte[0], null);
} }
private static String renderForm(String errOrOk) { private static String renderForm(String errOrOk) {
@@ -140,7 +226,7 @@ public final class login implements WebPage {
continue; continue;
} }
if (c == '%' && i + 2 < s.length()) { if (c == '%' && i + 2 < s.length()) {
int hi = hex(s.charAt(i + 1)); int hi = hex(c = s.charAt(i + 1));
int lo = hex(s.charAt(i + 2)); int lo = hex(s.charAt(i + 2));
if (hi >= 0 && lo >= 0) { if (hi >= 0 && lo >= 0) {
tmp[n++] = (byte) ((hi << 4) | lo); tmp[n++] = (byte) ((hi << 4) | lo);
@@ -149,7 +235,7 @@ public final class login implements WebPage {
} }
} }
byte[] b = String.valueOf(c).getBytes(StandardCharsets.UTF_8); byte[] b = String.valueOf(s.charAt(i)).getBytes(StandardCharsets.UTF_8);
for (byte bb : b) tmp[n++] = bb; for (byte bb : b) tmp[n++] = bb;
} }
@@ -163,69 +249,18 @@ public final class login implements WebPage {
return -1; return -1;
} }
@Override private static WebPacketHeader outHeader(WebPageContext ctx) {
public WebResponsePacket handle(WebPageContext ctx) throws Exception { WebPacketHeader in = (ctx != null && ctx.request != null) ? ctx.request.getHeader() : null;
WebApp.init(); if (in == null) {
return new WebPacketHeader(0, 0, 0, 0, WebPacketFlags.RESOURCE, System.currentTimeMillis());
// 1) If a valid session already exists -> go dashboard (keep session) }
SessionContext existing = SessionContext.from( return new WebPacketHeader(
ctx.client, in.getRequestId(),
(ProtocolWebServer) ctx.client.getServer(), in.getTabId(),
ctx.request.getHeaders() in.getPageId(),
in.getFrameId(),
in.getFlags() | WebPacketFlags.RESOURCE,
System.currentTimeMillis()
); );
if (existing.isValid() && existing.getUser() != null) {
return redirect302("dashboard.html", existing.getSessionId());
}
WebRequestMethod method = ctx.request.getMethod();
if (method == null) method = WebRequestMethod.GET;
if (method == WebRequestMethod.GET) {
return ok(renderForm(null));
}
if (method != WebRequestMethod.POST) {
return text(405, "Method Not Allowed");
}
String contentType = headerIgnoreCase(ctx.request.getHeaders(), "content-type");
String ctLower = (contentType == null) ? "" : contentType.toLowerCase(Locale.ROOT);
if (!ctLower.startsWith("application/x-www-form-urlencoded")) {
return ok(renderForm("Unsupported content-type: " + Html.esc(contentType)));
}
Map<String, List<String>> form = parseFormUrlEncoded(ctx.request.getBody());
String username = first(form, "username");
String password = first(form, "password");
if (username == null || password == null) {
return ok(renderForm("Missing username/password."));
}
String lookupUsername = username.trim();
UserDao.UserRow user = WebApp.get().users().findByUsername(lookupUsername).orElse(null);
if (user == null) {
return ok(renderForm("Invalid credentials."));
}
boolean okPw = WebApp.get().passwordHasher().verify(password, user.passwordEncoded());
if (!okPw) {
return ok(renderForm("Invalid credentials."));
}
String ip = resolveIp(ctx);
String ua = headerIgnoreCase(ctx.request.getHeaders(), "user-agent");
if (ua == null) ua = "";
String session = SessionManager.create(
String.valueOf(user.id()),
ip,
ua,
(ProtocolWebServer) ctx.client.getServer()
);
return redirect302("dashboard.html", session);
} }
} }

View File

@@ -2,44 +2,120 @@ package ins.frontend;
import ins.frontend.utils.RegistrationService; import ins.frontend.utils.RegistrationService;
import ins.frontend.utils.WebApp; import ins.frontend.utils.WebApp;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket; import org.openautonomousconnection.protocol.packets.v1_0_1.beta.web.impl.resource.WebResourceResponsePacket;
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer; import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
import org.openautonomousconnection.protocol.side.web.managers.SessionManager; import org.openautonomousconnection.protocol.side.web.managers.SessionManager;
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.WebRequestMethod; import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketFlags;
import org.openautonomousconnection.protocol.versions.v1_0_1.beta.WebPacketHeader;
import org.openautonomousconnection.webserver.api.Route; import org.openautonomousconnection.webserver.api.Route;
import org.openautonomousconnection.webserver.api.SessionContext;
import org.openautonomousconnection.webserver.api.WebPage; import org.openautonomousconnection.webserver.api.WebPage;
import org.openautonomousconnection.webserver.api.WebPageContext; import org.openautonomousconnection.webserver.api.WebPageContext;
import org.openautonomousconnection.webserver.utils.HeaderMaps; import org.openautonomousconnection.webserver.utils.HeaderMaps;
import org.openautonomousconnection.webserver.utils.Html; import org.openautonomousconnection.webserver.utils.Html;
import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
/** /**
* Register page with existing-session short-circuit. * Register page (v1.0.1).
*/ */
@Route(path = "/register.html") @Route(path = "/register.html")
public final class register implements WebPage { public final class register extends WebPage {
private static WebResponsePacket ok(String html) { private enum ReqMethod { GET, POST, OTHER }
return new WebResponsePacket(200, "text/html; charset=utf-8", HeaderMaps.mutable(), Html.utf8(html));
@Override
public WebResourceResponsePacket handle(WebPageContext ctx) throws Exception {
WebApp.init();
// If a valid session already exists -> go dashboard (keep session)
if (ctx.session != null && ctx.session.isValid() && ctx.session.getUser() != null) {
return redirect302(ctx, "dashboard.html", ctx.session.getSessionId());
}
ReqMethod method = detectMethod(ctx);
if (method == ReqMethod.GET) {
return ok(ctx, renderForm(null));
}
if (method != ReqMethod.POST) {
return text(ctx, 405, "Method Not Allowed");
}
String contentType = headerIgnoreCase(ctx.request.getHeaders(), "content-type");
String ctLower = (contentType == null) ? "" : contentType.toLowerCase(Locale.ROOT);
if (!ctLower.startsWith("application/x-www-form-urlencoded")) {
return ok(ctx, renderForm("Unsupported content-type: " + Html.esc(contentType)));
}
Map<String, List<String>> form = parseFormUrlEncoded(ctx.request.getBody());
String username = first(form, "username");
String password = first(form, "password");
RegistrationService service = new RegistrationService(WebApp.get().users(), WebApp.get().passwordHasher());
RegistrationService.Result r = service.register(username, password);
if (!r.ok()) {
return ok(ctx, renderForm(r.error()));
}
// Create new session (user just registered)
String ip = resolveIp(ctx);
String ua = headerIgnoreCase(ctx.request.getHeaders(), "user-agent");
if (ua == null) ua = "";
String session = SessionManager.create(
String.valueOf(r.userId()),
ip,
ua,
(ProtocolWebServer) ctx.client.getServer()
);
return redirect302(ctx, "dashboard.html", session);
} }
private static WebResponsePacket text(int code, String msg) { private ReqMethod detectMethod(WebPageContext ctx) {
return new WebResponsePacket(code, "text/plain; charset=utf-8", HeaderMaps.mutable(), msg.getBytes(StandardCharsets.UTF_8)); try {
Method m = ctx.request.getClass().getMethod("getMethod");
Object v = m.invoke(ctx.request);
if (v != null) {
String s = String.valueOf(v).trim().toUpperCase(Locale.ROOT);
if ("GET".equals(s)) return ReqMethod.GET;
if ("POST".equals(s)) return ReqMethod.POST;
return ReqMethod.OTHER;
}
} catch (Exception ignored) {
}
byte[] body = ctx.request.getBody();
if (body != null && body.length > 0) return ReqMethod.POST;
return ReqMethod.GET;
} }
private static WebResponsePacket redirect302(String location, String session) { private static WebResourceResponsePacket ok(WebPageContext ctx, String html) {
byte[] body = Html.utf8(html);
Map<String, String> headers = HeaderMaps.mutable(); Map<String, String> headers = HeaderMaps.mutable();
headers.put("location", location); headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), 200, "text/html; charset=utf-8", headers, body, null);
}
private static WebResourceResponsePacket text(WebPageContext ctx, int code, String msg) {
byte[] body = (msg == null ? "" : msg).getBytes(StandardCharsets.UTF_8);
Map<String, String> headers = HeaderMaps.mutable();
headers.put("content-length", String.valueOf(body.length));
return new WebResourceResponsePacket(outHeader(ctx), code, "text/plain; charset=utf-8", headers, body, null);
}
private static WebResourceResponsePacket redirect302(WebPageContext ctx, String location, String session) {
Map<String, String> headers = HeaderMaps.mutable();
headers.put("Location", location);
if (session != null && !session.isBlank()) { if (session != null && !session.isBlank()) {
headers.put("Location", "dashboard.html");
headers.put("Set-Cookie", "session=" + session + "; Path=/; HttpOnly; SameSite=Lax"); headers.put("Set-Cookie", "session=" + session + "; Path=/; HttpOnly; SameSite=Lax");
headers.put("session", session); headers.put("session", session);
headers.put("cookie", session);
} }
return new WebResponsePacket(302, "text/plain; charset=utf-8", headers, new byte[0]); return new WebResourceResponsePacket(outHeader(ctx), 302, "text/plain; charset=utf-8", headers, new byte[0], null);
} }
private static String renderForm(String errOrOk) { private static String renderForm(String errOrOk) {
@@ -138,7 +214,7 @@ public final class register implements WebPage {
continue; continue;
} }
if (c == '%' && i + 2 < s.length()) { if (c == '%' && i + 2 < s.length()) {
int hi = hex(s.charAt(i + 1)); int hi = hex(c = s.charAt(i + 1));
int lo = hex(s.charAt(i + 2)); int lo = hex(s.charAt(i + 2));
if (hi >= 0 && lo >= 0) { if (hi >= 0 && lo >= 0) {
tmp[n++] = (byte) ((hi << 4) | lo); tmp[n++] = (byte) ((hi << 4) | lo);
@@ -147,7 +223,7 @@ public final class register implements WebPage {
} }
} }
byte[] b = String.valueOf(c).getBytes(StandardCharsets.UTF_8); byte[] b = String.valueOf(s.charAt(i)).getBytes(StandardCharsets.UTF_8);
for (byte bb : b) tmp[n++] = bb; for (byte bb : b) tmp[n++] = bb;
} }
@@ -161,61 +237,18 @@ public final class register implements WebPage {
return -1; return -1;
} }
@Override private static WebPacketHeader outHeader(WebPageContext ctx) {
public WebResponsePacket handle(WebPageContext ctx) throws Exception { WebPacketHeader in = (ctx != null && ctx.request != null) ? ctx.request.getHeader() : null;
WebApp.init(); if (in == null) {
return new WebPacketHeader(0, 0, 0, 0, WebPacketFlags.RESOURCE, System.currentTimeMillis());
// 1) If a valid session already exists -> go dashboard (keep session) }
SessionContext existing = SessionContext.from( return new WebPacketHeader(
ctx.client, in.getRequestId(),
(ProtocolWebServer) ctx.client.getServer(), in.getTabId(),
ctx.request.getHeaders() in.getPageId(),
in.getFrameId(),
in.getFlags() | WebPacketFlags.RESOURCE,
System.currentTimeMillis()
); );
if (existing.isValid() && existing.getUser() != null) {
return redirect302("dashboard.html", existing.getSessionId());
}
WebRequestMethod method = ctx.request.getMethod();
if (method == null) method = WebRequestMethod.GET;
if (method == WebRequestMethod.GET) {
return ok(renderForm(null));
}
if (method != WebRequestMethod.POST) {
return text(405, "Method Not Allowed");
}
String contentType = headerIgnoreCase(ctx.request.getHeaders(), "content-type");
String ctLower = (contentType == null) ? "" : contentType.toLowerCase(Locale.ROOT);
if (!ctLower.startsWith("application/x-www-form-urlencoded")) {
return ok(renderForm("Unsupported content-type: " + Html.esc(contentType)));
}
Map<String, List<String>> form = parseFormUrlEncoded(ctx.request.getBody());
String username = first(form, "username");
String password = first(form, "password");
RegistrationService service = new RegistrationService(WebApp.get().users(), WebApp.get().passwordHasher());
RegistrationService.Result r = service.register(username, password);
if (!r.ok()) {
return ok(renderForm(r.error()));
}
// 2) Create new session (user just registered)
String ip = resolveIp(ctx);
String ua = headerIgnoreCase(ctx.request.getHeaders(), "user-agent");
if (ua == null) ua = "";
String session = SessionManager.create(
String.valueOf(r.userId()),
ip,
ua,
(ProtocolWebServer) ctx.client.getServer()
);
return redirect302("dashboard.html", session);
} }
} }

67
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>org.openautonomousconnection</groupId> <groupId>org.openautonomousconnection</groupId>
<artifactId>INSServer</artifactId> <artifactId>INSServer</artifactId>
<version>1.0.0-BETA.1.0</version> <version>1.0.1-BETA.0.3</version>
<organization> <organization>
<name>Open Autonomous Connection</name> <name>Open Autonomous Connection</name>
<url>https://open-autonomous-connection.org/</url> <url>https://open-autonomous-connection.org/</url>
@@ -15,8 +15,8 @@
<description>The default INS-Server</description> <description>The default INS-Server</description>
<properties> <properties>
<maven.compiler.source>23</maven.compiler.source> <maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target> <maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@@ -53,47 +53,6 @@
<name>Open Autonomous Public License (OAPL)</name> <name>Open Autonomous Public License (OAPL)</name>
<url>https://open-autonomous-connection.org/license.html</url> <url>https://open-autonomous-connection.org/license.html</url>
</license> </license>
<license>
<name>GNU General Public License v3.0</name>
<url>https://www.gnu.org/licenses/gpl-3.0.html</url>
<comments>
Default license: Applies to all users and projects unless an explicit alternative license has been
granted.
</comments>
</license>
<license>
<name>LPGL 3</name>
<url>https://www.gnu.org/licenses/lgpl-3.0.html#license-text</url>
</license>
<license>
<name>LPGL 2.1</name>
<url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.en#SEC1</url>
</license>
<license>
<name>WTPL License</name>
<url>https://github.com/ronmamo/reflections/tree/master?tab=WTFPL-1-ov-file</url>
</license>
<license>
<name>Apache License 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
<license>
<name>MIT License</name>
<url>https://opensource.org/license/mit</url>
</license>
<license>
<name>javassist</name>
<url>https://github.com/jboss-javassist/javassist/blob/master/License.html</url>
</license>
<license>
<name>projectlombok</name>
<url>https://github.com/projectlombok/lombok?tab=License-1-ov-file</url>
</license>
<license>
<name>mariadb</name>
<url>https://mariadb.com/docs/general-resources/community/community/faq/licensing-questions/licensing-faq
</url>
</license>
</licenses> </licenses>
<repositories> <repositories>
@@ -110,19 +69,18 @@
<dependency> <dependency>
<groupId>org.openautonomousconnection</groupId> <groupId>org.openautonomousconnection</groupId>
<artifactId>Protocol</artifactId> <artifactId>Protocol</artifactId>
<version>1.0.0-BETA.1.0</version> <version>1.0.1-BETA.0.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.38</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
<version>3.5.7</version> <version>3.5.7</version>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@@ -153,6 +111,13 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version> <version>3.13.0</version>
<configuration> <configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.42</version>
</path>
</annotationProcessorPaths>
<compilerArgs> <compilerArgs>
<arg>--add-exports</arg> <arg>--add-exports</arg>
<arg>java.base/sun.security.x509=ALL-UNNAMED</arg> <arg>java.base/sun.security.x509=ALL-UNNAMED</arg>

View File

@@ -71,7 +71,7 @@ public final class DatabaseINSServer extends ProtocolINSServer {
out.sort(recordComparator(type)); out.sort(recordComparator(type));
return out; return out;
} catch (SQLException ex) { } catch (SQLException ex) {
getProtocolBridge().getLogger().exception( getProtocolBridge().getProtocolValues().logger.exception(
"INS resolve failed for " + formatName(tln, name, sub) + " type=" + type, "INS resolve failed for " + formatName(tln, name, sub) + " type=" + type,
ex ex
); );
@@ -100,7 +100,7 @@ public final class DatabaseINSServer extends ProtocolINSServer {
if (rs.next()) return rs.getString("info"); if (rs.next()) return rs.getString("info");
} }
} catch (SQLException ex) { } catch (SQLException ex) {
getProtocolBridge().getLogger().exception("Failed to resolve TLN info site for tln=" + tln, ex); getProtocolBridge().getProtocolValues().logger.exception("Failed to resolve TLN info site for tln=" + tln, ex);
} }
return null; return null;
@@ -131,12 +131,12 @@ public final class DatabaseINSServer extends ProtocolINSServer {
String canonical = formatName(tln, name, sub).toLowerCase(Locale.ROOT); String canonical = formatName(tln, name, sub).toLowerCase(Locale.ROOT);
if (!visited.add(canonical)) { if (!visited.add(canonical)) {
// loop detected // loop detected
getProtocolBridge().getLogger().warn("CNAME loop detected for " + canonical + " type=" + requestedType); getProtocolBridge().getProtocolValues().logger.warn("CNAME loop detected for " + canonical + " type=" + requestedType);
return new ArrayList<>(); return new ArrayList<>();
} }
if (depth > MAX_CNAME_DEPTH) { if (depth > MAX_CNAME_DEPTH) {
getProtocolBridge().getLogger().warn("CNAME recursion limit exceeded for " + canonical + " type=" + requestedType); getProtocolBridge().getProtocolValues().logger.warn("CNAME recursion limit exceeded for " + canonical + " type=" + requestedType);
return new ArrayList<>(); return new ArrayList<>();
} }
@@ -169,7 +169,7 @@ public final class DatabaseINSServer extends ProtocolINSServer {
for (INSRecord cname : cnames) { for (INSRecord cname : cnames) {
TargetName target = parseCnameTarget(cname.value); TargetName target = parseCnameTarget(cname.value);
if (target == null) { if (target == null) {
getProtocolBridge().getLogger().warn("Invalid CNAME target '" + cname.value + "' on " + canonical); getProtocolBridge().getProtocolValues().logger.warn("Invalid CNAME target '" + cname.value + "' on " + canonical);
continue; continue;
} }

View File

@@ -10,11 +10,11 @@ public class Listener extends EventListener {
public void onCommandNotFound(CommandNotFoundEvent event) { public void onCommandNotFound(CommandNotFoundEvent event) {
StringBuilder argsBuilder = new StringBuilder(); StringBuilder argsBuilder = new StringBuilder();
for (String arg : event.getArgs()) argsBuilder.append(arg).append(" "); for (String arg : event.getArgs()) argsBuilder.append(arg).append(" ");
Main.getProtocolBridge().getLogger().error("Command '" + event.getName() + argsBuilder.toString() + "' not found!"); Main.getProtocolBridge().getProtocolValues().logger.error("Command '" + event.getName() + argsBuilder.toString() + "' not found!");
} }
@dev.unlegitdqrk.unlegitlibrary.event.Listener @dev.unlegitdqrk.unlegitlibrary.event.Listener
public void onMissingCommandPermission(CommandExecutorMissingPermissionEvent event) { public void onMissingCommandPermission(CommandExecutorMissingPermissionEvent event) {
Main.getProtocolBridge().getLogger().error("You do not have enough permissions to execute this command!"); Main.getProtocolBridge().getProtocolValues().logger.error("You do not have enough permissions to execute this command!");
} }
} }

View File

@@ -1,11 +1,13 @@
package org.openautonomousconnection.insserver; package org.openautonomousconnection.insserver;
import dev.unlegitdqrk.unlegitlibrary.addon.AddonLoader;
import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor; import dev.unlegitdqrk.unlegitlibrary.command.CommandExecutor;
import dev.unlegitdqrk.unlegitlibrary.command.CommandManager; import dev.unlegitdqrk.unlegitlibrary.command.CommandManager;
import dev.unlegitdqrk.unlegitlibrary.command.CommandPermission; import dev.unlegitdqrk.unlegitlibrary.command.CommandPermission;
import dev.unlegitdqrk.unlegitlibrary.event.EventManager; import dev.unlegitdqrk.unlegitlibrary.event.EventManager;
import dev.unlegitdqrk.unlegitlibrary.file.ConfigurationManager; import dev.unlegitdqrk.unlegitlibrary.file.ConfigurationManager;
import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler; import dev.unlegitdqrk.unlegitlibrary.network.system.packets.PacketHandler;
import dev.unlegitdqrk.unlegitlibrary.utils.Logger;
import lombok.Getter; import lombok.Getter;
import org.openautonomousconnection.insserver.commands.StopCommand; import org.openautonomousconnection.insserver.commands.StopCommand;
import org.openautonomousconnection.protocol.ProtocolBridge; import org.openautonomousconnection.protocol.ProtocolBridge;
@@ -29,10 +31,15 @@ public class Main {
private static ProtocolValues values; private static ProtocolValues values;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (!new File("logs").exists()) new File("logs").mkdir();
Logger logger = new Logger(new File("logs"), false, true);
values = new ProtocolValues(); values = new ProtocolValues();
values.packetHandler = new PacketHandler(); values.packetHandler = new PacketHandler();
values.eventManager = new EventManager(); values.eventManager = new EventManager();
values.protocolVersion = ProtocolVersion.PV_1_0_1_BETA;
values.eventManager.registerListener(new Listener()); values.eventManager.registerListener(new Listener());
values.logger = logger;
if (!new File("config.properties").exists()) { if (!new File("config.properties").exists()) {
new File("config.properties").createNewFile(); new File("config.properties").createNewFile();
@@ -69,8 +76,8 @@ public class Main {
config.saveProperties(); config.saveProperties();
} }
if (!config.isSet("ins.ins.frontend")) { if (!config.isSet("ins.frontend")) {
config.set("ins.ins.frontend", "INS FRONTEND SITE (HOST)"); config.set("ins.frontend", "INS FRONTEND SITE (HOST)");
config.saveProperties(); config.saveProperties();
} }
@@ -81,10 +88,10 @@ public class Main {
int tcpPort = config.getInt("port"); int tcpPort = config.getInt("port");
String info = config.getString("ins.info"); String info = config.getString("ins.info");
String frontend = config.getString("ins.ins.frontend"); String frontend = config.getString("ins.frontend");
DatabaseINSServer server = new DatabaseINSServer(info, frontend, url, user, password); DatabaseINSServer server = new DatabaseINSServer(info, frontend, url, user, password);
protocolBridge = new ProtocolBridge(server, values, ProtocolVersion.PV_1_0_0_BETA, new File("logs")); protocolBridge = new ProtocolBridge(server, values);
server.start(tcpPort); server.start(tcpPort);
commandManager = new CommandManager(values.eventManager); commandManager = new CommandManager(values.eventManager);