Files
INSServer/frontend/info.java
2026-02-22 17:21:23 +01:00

73 lines
2.8 KiB
Java

package ins.frontend;
import ins.frontend.utils.WebApp;
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.WebPage;
import org.openautonomousconnection.webserver.api.WebPageContext;
import org.openautonomousconnection.webserver.utils.HeaderMaps;
import org.openautonomousconnection.webserver.utils.Html;
import java.util.Map;
/**
* Info page for INS registrar frontend (v1.0.1).
*/
@Route(path = "/info.html")
public final class info implements WebPage {
@Override
public WebResourceResponsePacket handle(WebPageContext ctx) {
WebApp.init();
String html = Html.page("INS Info", """
<section class="card">
<h2>OAC Default INS Server</h2>
<p>
The <strong>Default INS Server</strong> is the official, project-operated
name service of the Open Autonomous Connection (OAC) network.
</p>
<p>
It provides a trusted reference point for resolving InfoNames
and enables initial client connections
to the OAC ecosystem.
</p>
<p>
This server is maintained by the OAC project and is intended
as the recommended entry point for public services and new clients.
</p>
<p class="muted">
Note: Alternative or private INS servers may exist, but the default INS
server represents the official and stable reference instance.
</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()
);
}
}