Updated to new WebServer-Version

This commit is contained in:
Finn
2026-01-19 17:02:46 +01:00
parent 42b1d69a5f
commit 348476cf0a
19 changed files with 1163 additions and 122 deletions

View File

@@ -1,32 +1,21 @@
package org.openautonomousconnection.oac2web;
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.web.WebResponsePacket;
import org.openautonomousconnection.webserver.api.Route;
import org.openautonomousconnection.webserver.api.WebPage;
import org.openautonomousconnection.webserver.api.WebPageContext;
import org.openautonomousconnection.webserver.utils.HttpsProxy;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Scanner;
/**
* Proxies the HTTPS INS page through OAC.
*/
@Route(path = "ins.php")
public class ins implements WebPage {
@Override
public WebResponsePacket handle(WebPageContext webPageContext) throws Exception {
String content = null;
URLConnection connection = null;
try {
connection = new URL("https://open-autonomous-connection.org/ins.php").openConnection();
Scanner scanner = new Scanner(connection.getInputStream());
scanner.useDelimiter("\\Z");
content = scanner.next();
scanner.close();
}catch ( Exception ex ) {
content = ex.getMessage();
ex.printStackTrace();
}
return new WebResponsePacket(308, "text/html", new HashMap<>(), content.getBytes(StandardCharsets.UTF_8));
@Override
public WebResponsePacket handle(WebPageContext webPageContext) {
if (webPageContext.request.getPath().equalsIgnoreCase("ins.php"))
return HttpsProxy.proxyGet(webPageContext, "https://open-autonomous-connection.org/ins.php");
return null;
}
}