Easter cleaning
This commit is contained in:
commit
9e36078b2e
1862 changed files with 270281 additions and 0 deletions
31
nx01-zerofungus-server/conf/logback-server-console.xml
Normal file
31
nx01-zerofungus-server/conf/logback-server-console.xml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="90 seconds" debug="false">
|
||||
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
|
||||
<resetJUL>true</resetJUL>
|
||||
</contextListener>
|
||||
<jmxConfigurator/>
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>logs/no2all-demo.log</file>
|
||||
<encoder>
|
||||
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
<!-- Package opens. -->
|
||||
<logger level="DEBUG" name="love.distributedrebirth.nx01.warp.core"/>
|
||||
<logger level="DEBUG" name="love.distributedrebirth.nx01.zerofungus"/>
|
||||
|
||||
<!-- Package limits. -->
|
||||
<logger level="INFO" name="org.eclipse.jetty"/>
|
||||
<logger level="INFO" name="jakarta.json.spi"/>
|
||||
|
||||
</configuration>
|
||||
23
nx01-zerofungus-server/conf/logback-server.xml
Normal file
23
nx01-zerofungus-server/conf/logback-server.xml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="90 seconds">
|
||||
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
|
||||
<resetJUL>true</resetJUL>
|
||||
</contextListener>
|
||||
<jmxConfigurator/>
|
||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||
<file>logs/no2all-demo.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>logs/no2all-demo-%d{yyyy-MM-dd}.log.zip</fileNamePattern>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
|
||||
<!-- Package limits. -->
|
||||
<logger level="INFO" name="org.eclipse.jetty"/>
|
||||
|
||||
</configuration>
|
||||
63
nx01-zerofungus-server/pom.xml
Normal file
63
nx01-zerofungus-server/pom.xml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>love.distributedrebirth.nx01</groupId>
|
||||
<artifactId>nx01</artifactId>
|
||||
<version>〇一。壬寅。一〄-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>nx01-zerofungus-server</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>nx01-no2all-react-nostr</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>nx01-no2all-wire-jetty</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.parsson</groupId>
|
||||
<artifactId>parsson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery</artifactId>
|
||||
<version>3.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>jquery-validation</artifactId>
|
||||
<version>1.19.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import jakarta.json.Json;
|
||||
import jakarta.json.JsonWriter;
|
||||
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEvent;
|
||||
import love.distributedrebirth.nx01.no2all.react.nostr.server.relay.NoStrArtServerRelayStoreEvent;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReact;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaPulse;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactTypeScriptPlasmaAdapter;
|
||||
import love.distributedrebirth.nx01.warp.core.space.WarpSpaceAntimatterInducer;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class ZFunRtsServer extends WarpReactTypeScriptPlasmaAdapter {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ZFunRtsServer.class.getName());
|
||||
|
||||
public ZFunRtsServer(WarpReactPlasma antimatterVortexSlot) {
|
||||
super(antimatterVortexSlot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
|
||||
WarpReact react = signal.getReact();
|
||||
WarpReactPlasma slot = getAntimatterVortexSlot();
|
||||
DataSource ds = react.service(DataSource.class);
|
||||
react.registrate(slot, NoStrArtServerRelayStoreEvent.class, storeEvent -> {
|
||||
logger.info("Store event: " + storeEvent.getData().getEvent().getId().getHexDipavali());
|
||||
NoStrEvent event = storeEvent.getData().getEvent();
|
||||
StringWriter jsonStr = new StringWriter();
|
||||
try (JsonWriter writer = Json.createWriter(jsonStr)) {
|
||||
writer.write(event.toBible());
|
||||
}
|
||||
try (Connection conn = ds.getConnection()) {
|
||||
String sql = "INSERT INTO \"ᔆʸᔆᐪᓫᔿ\".\"ᔆᐪᣔᒼᒽᑉ\" (\"ᑊᑊᐣ\",\"ᣖᓑᒃᒽᑉᓫᔾ\",\"ᒼᣗᓫᣔᐪᓫᐝᒄᐪ\",\"ᑊᑉᑊᣕᒄ\",\"ᒄᓫᒻᐪᣔᕐ\",\"ᓫᕁᣖᑊᣗᓫᐝᒄᐪ\",\"ᣗᣔᒡᒢ\") VALUES (?,?,?,?,?,?,?)";
|
||||
PreparedStatement prep = conn.prepareStatement(sql);
|
||||
prep.setString(1, event.getId().getHex());
|
||||
prep.setString(2, event.getPayload().getPublicKey().getHex());
|
||||
prep.setDate(3, new java.sql.Date(event.getPayload().getCreatedAt().toEpochMilli()));
|
||||
prep.setInt(4, event.getPayload().getKind().getNumber());
|
||||
prep.setString(5, null); // del tag
|
||||
prep.setString(6, null); // exp date
|
||||
prep.setString(7, jsonStr.toString());
|
||||
prep.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaPulse;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactTypeScript;
|
||||
import love.distributedrebirth.nx01.warp.core.space.WarpSpaceAntimatterInducer;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class ZFunRtsServerBooted implements WarpReactTypeScript {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ZFunRtsServerBooted.class.getName());
|
||||
|
||||
@Override
|
||||
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
|
||||
logger.info("╔═╗┌─┐┬─┐┌─┐ .╔═╗┬ ┬┌┐┌╔═╗┬ ┬┌─┐");
|
||||
logger.info("╔═╝├┤ ├┬┘│ │ . ╠╣ │ ││││║ ╦│ │└─┐");
|
||||
logger.info("╚═╝└─┘┴└─└─┘. ╚ └─┘┘└┘╚═╝└─┘└─┘");
|
||||
logger.info("Boot done.");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
||||
|
||||
import ch.qos.logback.core.status.NopStatusListener;
|
||||
import love.distributedrebirth.nx01.no2all.react.nostr.client.NoStrRtsClient;
|
||||
import love.distributedrebirth.nx01.no2all.react.nostr.server.NoStrRtsServer;
|
||||
import love.distributedrebirth.nx01.no2all.react.nostr.server.relay.NoStrRtsServerRelay;
|
||||
import love.distributedrebirth.nx01.no2all.react.nostr.server.relay.NoStrRtsServerRelaySubs;
|
||||
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllRtsClient;
|
||||
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServer;
|
||||
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServerLog;
|
||||
import love.distributedrebirth.nx01.warp.core.WarpCoreReactor;
|
||||
import love.distributedrebirth.nx01.warp.core.WarpCoreSpeedMonitor;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
|
||||
import love.distributedrebirth.nx01.zerofungus.server.service.ZFunRtsConfigJetty;
|
||||
import love.distributedrebirth.nx01.zerofungus.server.service.ZFunRtsInitJdbc;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public enum ZeroFungus /* implements BãßBȍőnAbacusInstanceMBeanʸᴰ<ZeroFungus> */ {
|
||||
INSTANCE;
|
||||
|
||||
private WarpCoreReactor foei = new WarpCoreReactor();
|
||||
private List<ZFunRtsConfigJetty> jetties = new ArrayList<>();
|
||||
private static final Logger logger = Logger.getLogger(ZeroFungus.class.getName());
|
||||
|
||||
public static void main(String[] args) {
|
||||
Iterator<String> arguments = Arrays.asList(args).iterator();
|
||||
boolean hasPort = arguments.hasNext() && arguments.next().equals("-p") && arguments.hasNext();
|
||||
|
||||
// todo move
|
||||
new File("logs").mkdir();
|
||||
setupLogging();
|
||||
|
||||
// config jetty
|
||||
INSTANCE.jetties.clear();
|
||||
if (hasPort) {
|
||||
// note: multiple currently does not work...
|
||||
INSTANCE.jetties.add(Arrays.asList(arguments.next().split(",")).stream().map(v -> Integer.parseInt(v)).findFirst().map(v -> new ZFunRtsConfigJetty(v)).get());
|
||||
} else {
|
||||
INSTANCE.jetties.add(new ZFunRtsConfigJetty(8080));
|
||||
}
|
||||
INSTANCE.start();
|
||||
}
|
||||
|
||||
public WarpCoreReactor getWarpCore() {
|
||||
return foei;
|
||||
}
|
||||
|
||||
private static void setupLogging() {
|
||||
if (System.getProperty("logback.configurationFile") == null) {
|
||||
String logConfig = null;
|
||||
if (System.getProperty("java.class.path").contains("classes")) {
|
||||
logConfig = "conf/logback-server-console.xml";
|
||||
} else {
|
||||
logConfig = "conf/logback-server.xml";
|
||||
}
|
||||
System.setProperty("logback.configurationFile", logConfig);
|
||||
}
|
||||
if (System.getProperty("logback.statusListenerClass") == null) {
|
||||
System.setProperty("logback.statusListenerClass",NopStatusListener.class.getName());
|
||||
}
|
||||
org.slf4j.Logger logger2 = LoggerFactory.getLogger(ZeroFungus.class);
|
||||
logger2.info("Logging configured.");
|
||||
|
||||
SLF4JBridgeHandler.removeHandlersForRootLogger();
|
||||
SLF4JBridgeHandler.install();
|
||||
logger.info(" ╦┬ ┬╦ ╦═╗┌─┐╦ ╦┬╦═╗┌─┐╔╦╗");
|
||||
logger.info(" ║│ │║ ╠╦╝├┤ ║║║│╠╦╝├┤ ║║");
|
||||
logger.info("╚╝└─┘╩═╝ ╩╚═└─┘╚╩╝┴╩╚═└─┘═╩╝");
|
||||
//https://patorjk.com/software/taag
|
||||
// Calvin S
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
jetties.forEach(v -> v.stop());
|
||||
// foei.fire(No2AllReactWarpCore.DILITHIUM, new EjectWrapCoreShutdown());
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
||||
foei.claim(MUSHROOM_WARP_CORE);
|
||||
foei.claim(MUSHROOM_CLIENT_NOSTR);
|
||||
foei.claim(MUSHROOM_SERVER_NOSTR);
|
||||
foei.claim(MUSHROOM_SERVER_HYPER);
|
||||
foei.claim(MUSHROOM_SERVER_NETHER);
|
||||
|
||||
// debug warp monitor
|
||||
foei.load(new WarpCoreSpeedMonitor());
|
||||
|
||||
foei.load(new No2AllRtsServer(MUSHROOM_SERVER_HYPER));
|
||||
foei.load(new No2AllRtsServerLog(MUSHROOM_SERVER_HYPER));
|
||||
|
||||
foei.load(new No2AllRtsServer(MUSHROOM_SERVER_NETHER));
|
||||
foei.load(new No2AllRtsServerLog(MUSHROOM_SERVER_NETHER));
|
||||
|
||||
foei.load(new No2AllRtsServer(MUSHROOM_SERVER_NOSTR));
|
||||
foei.load(new No2AllRtsServerLog(MUSHROOM_SERVER_NOSTR));
|
||||
foei.load(new NoStrRtsServer(MUSHROOM_SERVER_NOSTR));
|
||||
foei.load(new NoStrRtsServerRelay(MUSHROOM_SERVER_NOSTR));
|
||||
foei.load(new NoStrRtsServerRelaySubs(MUSHROOM_SERVER_NOSTR));
|
||||
|
||||
foei.load(new No2AllRtsClient(MUSHROOM_CLIENT_NOSTR));
|
||||
foei.load(new NoStrRtsClient(MUSHROOM_CLIENT_NOSTR));
|
||||
|
||||
// config zero fungus servers and clients
|
||||
foei.load(new ZFunRtsInitJdbc(foei));
|
||||
foei.load(new ZFunRtsServer(MUSHROOM_SERVER_NOSTR));
|
||||
// foei.load(new ZFunRtsClientReplay());
|
||||
|
||||
// load jetties and join
|
||||
jetties.forEach(v -> foei.load(v));
|
||||
foei.load(new ZFunRtsServerBooted());
|
||||
jetties.stream().findFirst().ifPresent(v -> v.join());
|
||||
}
|
||||
|
||||
// TODO: redo plasma name types and loading
|
||||
public final static WarpReactPlasma MUSHROOM_WARP_CORE = WarpReactPlasma.ofClassQualified(ZeroFungus.class, "warp-core");
|
||||
public final static WarpReactPlasma MUSHROOM_CLIENT_NOSTR = WarpReactPlasma.ofClassQualified(ZeroFungus.class, "client-nostr");
|
||||
public final static WarpReactPlasma MUSHROOM_SERVER_NOSTR = WarpReactPlasma.ofClassQualified(ZeroFungus.class, "server-nostr");
|
||||
public final static WarpReactPlasma MUSHROOM_SERVER_HYPER = WarpReactPlasma.ofClassQualified(ZeroFungus.class, "server-hyper");
|
||||
public final static WarpReactPlasma MUSHROOM_SERVER_NETHER = WarpReactPlasma.ofClassQualified(ZeroFungus.class, "server-nether");
|
||||
}
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.eclipse.jetty.server.CustomRequestLog;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.servlet.DefaultServlet;
|
||||
import org.eclipse.jetty.servlet.ServletHolder;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.component.LifeCycle.Listener;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.resource.ResourceCollection;
|
||||
import org.eclipse.jetty.webapp.Configuration;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.webapp.WebInfConfiguration;
|
||||
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
|
||||
import org.h2.server.web.JakartaWebServlet;
|
||||
|
||||
import jakarta.servlet.DispatcherType;
|
||||
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllActServer;
|
||||
import love.distributedrebirth.nx01.no2all.wire.jetty.JettyWireServerEndpoint;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReact;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaPulse;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactTypeScript;
|
||||
import love.distributedrebirth.nx01.warp.core.space.WarpSpaceAntimatterInducer;
|
||||
import love.distributedrebirth.nx01.zerofungus.server.ZeroFungus;
|
||||
import love.distributedrebirth.nx01.zerofungus.server.web.RedirectServlet;
|
||||
import love.distributedrebirth.nx01.zerofungus.server.web.WarpCorePlasmaInspectorServlet;
|
||||
import love.distributedrebirth.nx01.zerofungus.server.web.ZilLaLaFaultFilter;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public final class ZFunRtsConfigJetty implements WarpReactTypeScript {
|
||||
|
||||
public static final WarpReactPlasma API = WarpReactPlasma.ofClass(ZFunRtsConfigJetty.class);
|
||||
private static final Logger logger = Logger.getLogger(ZFunRtsConfigJetty.class.getName());
|
||||
private final Server server;
|
||||
private final ServerConnector connector;
|
||||
private JettyWireServerEndpoint wsNostr;
|
||||
private JettyWireServerEndpoint wsHyper;
|
||||
private JettyWireServerEndpoint wsNether;
|
||||
|
||||
public ZFunRtsConfigJetty(int port) {
|
||||
server = new Server();
|
||||
connector = new ServerConnector(server);
|
||||
connector.setPort(port);
|
||||
server.addConnector(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
|
||||
logger.info(" ╦┌─┐╔╦╗╔╦╗┬ ┬ ╔═╗┌─┐╦ ╦╔═╗┬─┐┌┬┐");
|
||||
logger.info(" ║├┤ ║ ║ └┬┘ ╠═╝│ │║║║║╣ ├┬┘ ││");
|
||||
logger.info("╚╝└─┘ ╩ ╩ ┴ ╩ └─┘╚╩╝╚═╝┴└──┴┘");
|
||||
WebAppContext context = new WebAppContext();
|
||||
context.setContextPath("/");
|
||||
context.setBaseResource(buildBaseResource(getClass().getClassLoader()));
|
||||
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/target/classes/|.*\\.jar");
|
||||
context.setConfigurations(new Configuration[]{
|
||||
//new AnnotationConfiguration(),
|
||||
new WebInfConfiguration(),
|
||||
});
|
||||
server.setHandler(context);
|
||||
|
||||
JettyWebSocketServletContainerInitializer.configure(context, (servletContext, wsContainer) -> {
|
||||
wsContainer.setMaxTextMessageSize(65535);
|
||||
wsNostr = new JettyWireServerEndpoint(wsContainer, "/ws/nostr");
|
||||
wsHyper = new JettyWireServerEndpoint(wsContainer, "/ws/hyper");
|
||||
wsNether = new JettyWireServerEndpoint(wsContainer, "/ws/nether");
|
||||
});
|
||||
|
||||
context.addFilter(ZilLaLaFaultFilter.class, "/debug/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
|
||||
logger.info("Add H2 console on: /debug/jdbc/console");
|
||||
context.addServlet(JakartaWebServlet.class, "/debug/jdbc/console/*");
|
||||
|
||||
logger.info("Add plasma inspector on: /debug/warpcore/inspector");
|
||||
context.addServlet(WarpCorePlasmaInspectorServlet.class, "/debug/warpcore/inspector");
|
||||
|
||||
|
||||
context.addServlet(RedirectServlet.class, "/test");
|
||||
|
||||
// for static
|
||||
ServletHolder staticHome = new ServletHolder("staticHome", DefaultServlet.class);
|
||||
staticHome.setInitParameter("dirAllowed","false");
|
||||
context.addServlet(staticHome, "/");
|
||||
|
||||
logger.info("Add request logger console");
|
||||
CustomRequestLog log = new CustomRequestLog("logs/http.log", CustomRequestLog.EXTENDED_NCSA_FORMAT);
|
||||
server.setRequestLog(log);
|
||||
|
||||
WarpReact react = signal.getReact();
|
||||
server.addEventListener(new Listener() {
|
||||
@Override
|
||||
public void lifeCycleStarted(LifeCycle event) {
|
||||
react.fire(ZeroFungus.MUSHROOM_SERVER_NOSTR, new No2AllActServer(wsNostr)); // text
|
||||
react.fire(ZeroFungus.MUSHROOM_SERVER_HYPER, new No2AllActServer(wsHyper)); // text + bin
|
||||
react.fire(ZeroFungus.MUSHROOM_SERVER_NETHER, new No2AllActServer(wsNether)); // bin
|
||||
}
|
||||
});
|
||||
try {
|
||||
logger.info("start jetty");
|
||||
server.start();
|
||||
logger.info("jetty started");
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Resource buildBaseResource(ClassLoader cl) {
|
||||
try {
|
||||
List<URL> paths = Collections.list(cl.getResources("META-INF/resources"));
|
||||
Resource[] resources = new Resource[paths.size() + 1];
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
resources[i] = Resource.newResource(paths.get(i));
|
||||
}
|
||||
resources[paths.size()] = Resource.newResource("target/classes/static");
|
||||
return new ResourceCollection(resources);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void join() {
|
||||
try {
|
||||
server.join();
|
||||
} catch (InterruptedException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
try {
|
||||
server.stop();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server.service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.h2.jdbcx.JdbcConnectionPool;
|
||||
|
||||
import love.distributedrebirth.nx01.warp.core.WarpCoreReactor;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaPulse;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactTypeScript;
|
||||
import love.distributedrebirth.nx01.warp.core.space.WarpSpaceAntimatterInducer;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class ZFunRtsInitJdbc implements WarpReactTypeScript {
|
||||
|
||||
public static final WarpReactPlasma API = WarpReactPlasma.ofClass(ZFunRtsInitJdbc.class);
|
||||
private static final Logger logger = Logger.getLogger(ZFunRtsInitJdbc.class.getName());
|
||||
private final WarpCoreReactor foei;
|
||||
|
||||
public ZFunRtsInitJdbc(WarpCoreReactor foei) {
|
||||
this.foei = foei;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
|
||||
signal.getReact().claim(API);
|
||||
|
||||
JdbcConnectionPool cp = JdbcConnectionPool.create("jdbc:h2:file:./target/h2db/zfun", "sa", "sa");
|
||||
foei.addService(JdbcConnectionPool.class, cp);
|
||||
foei.addService(DataSource.class, cp);
|
||||
|
||||
Flyway flyway = Flyway.configure().schemas("ᔆʸᔆᐪᓫᔿ", "other", "ssd").table("ᣔᒃᣔᒼᓑᔆ").dataSource(cp).load();
|
||||
flyway.migrate();
|
||||
logger.info("╔╦╗┌─┐╔╦╗┌─┐╔╗ ┌─┐╔═╗┌─┐ ╔═╗┌─┐╔╦╗┬ ┬┌─┐");
|
||||
logger.info(" ║║├─┤ ║ ├─┤╠╩╗├─┤╚═╗├┤ ╚═╗├┤ ║ │ │├─┘");
|
||||
logger.info("═╩╝┴ ┴ ╩ ┴ ┴╚═╝┴ ┴╚═╝└─┘ ╚═╝└─┘ ╩ └─┘┴ ");
|
||||
try {
|
||||
startDone();
|
||||
} catch (SQLException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void startDone() throws SQLException {
|
||||
JdbcConnectionPool cp = foei.service(JdbcConnectionPool.class);
|
||||
try (Connection conn = cp.getConnection()) {
|
||||
String sql = "SELECT COUNT(\"ᑊᑊᐣ\") FROM \"ᔆʸᔆᐪᓫᔿ\".\"ᔆᐪᣔᒼᒽᑉ\"";
|
||||
PreparedStatement prep = conn.prepareStatement(sql);
|
||||
ResultSet rs = prep.executeQuery();
|
||||
if (rs.first()) {
|
||||
Long records = rs.getLong(1);
|
||||
logger.info("DB Records: " + records + " from: " + sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server.web;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class RedirectServlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
response.sendRedirect("/powp/error/errmsg.html?title=NotHere&msg=TheEnd");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server.web;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.sax3.SAX3WriterEnum;
|
||||
import org.x4o.sax3.SAX3WriterXml;
|
||||
import org.x4o.sax3.io.xdbx.XDBXWriterXml;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import love.distributedrebirth.nx01.warp.core.WarpCorePlasmaIntermixChamber;
|
||||
import love.distributedrebirth.nx01.warp.core.WarpCoreReactor;
|
||||
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
|
||||
import love.distributedrebirth.nx01.zerofungus.server.ZeroFungus;
|
||||
|
||||
/// Prints the plasma slot contracts of the warp core.
|
||||
///
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class WarpCorePlasmaInspectorServlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
if ("true".equalsIgnoreCase(request.getParameter("___xdbx"))) {
|
||||
response.setContentType("application/octet-stream");
|
||||
try (SAX3WriterEnum<Tag,?> writer = new SAX3WriterEnum<Tag,XDBXWriterXml>(new XDBXWriterXml(response.getOutputStream()))) {
|
||||
printReport(writer, request);
|
||||
}
|
||||
return;
|
||||
}
|
||||
response.setContentType("text/xml");
|
||||
response.setCharacterEncoding("utf-8");
|
||||
BufferedWriter out = new BufferedWriter(response.getWriter());
|
||||
try (SAX3WriterEnum<Tag,?> writer = new SAX3WriterEnum<Tag,SAX3WriterXml>(new SAX3WriterXml(out, response.getCharacterEncoding()))) {
|
||||
printReport(writer, request);
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
|
||||
private void printReport(SAX3WriterEnum<Tag,?> writer, HttpServletRequest request) {
|
||||
WarpCoreReactor reactor = ZeroFungus.INSTANCE.getWarpCore();
|
||||
List<WarpReactPlasma> slots = reactor.listChilds(null);
|
||||
try {
|
||||
writer.startDocument();
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute("", "仙上主天", "", "", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕");
|
||||
if ("true".equalsIgnoreCase(request.getParameter("___willem"))) {
|
||||
atts.addAttribute("", "ᒡᒢᑊᒻᒻᓫᔿ", "", "", "𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕");
|
||||
}
|
||||
if ("true".equalsIgnoreCase(request.getParameter("___error"))) {
|
||||
throw new IOException("Oops triggered a ___error");
|
||||
}
|
||||
writer.printTagStart(Tag.reactor, atts);
|
||||
for (WarpReactPlasma slot : slots) {
|
||||
printSlotContract(writer, reactor.getSlotContract(slot));
|
||||
}
|
||||
writer.printTagEnd(Tag.reactor);
|
||||
writer.endDocument();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void printSlotContract(SAX3WriterEnum<Tag,?> writer, WarpCorePlasmaIntermixChamber contract) throws IOException {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute("", "path", "", "", contract.getSlot().getSlotPath());
|
||||
writer.printTagStart(Tag.slot, atts);
|
||||
printClaims(writer, Tag.claimIn, contract.getSlotTypesIn());
|
||||
printClaims(writer, Tag.claimOut, contract.getSlotTypesOut());
|
||||
printRequireServices(writer, contract.getRequireServices());
|
||||
printRequireSlots(writer, contract.getRequireSlots());
|
||||
writer.printTagEnd(Tag.slot);
|
||||
}
|
||||
|
||||
private void printClaims(SAX3WriterEnum<Tag,?> writer, Tag tag, List<Class<?>> clazzes) throws IOException {
|
||||
if (clazzes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
writer.printTagStart(tag);
|
||||
for (Class<?> cls : clazzes) {
|
||||
AttributesImpl atts = new AttributesImpl();
|
||||
atts.addAttribute("", "className", "", "", cls.getName());
|
||||
atts.addAttribute("", "classType", "", "", cls.toString().split(" ")[0]);
|
||||
writer.printTagStartEnd(Tag.claimType, atts);
|
||||
}
|
||||
writer.printTagEnd(tag);
|
||||
}
|
||||
|
||||
private void printRequireServices(SAX3WriterEnum<Tag,?> writer, List<Class<?>> clazzes) throws IOException {
|
||||
if (clazzes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
writer.printTagStart(Tag.requireServices);
|
||||
for (Class<?> cls : clazzes) {
|
||||
writer.printTagCharacters(Tag.requireService, cls.toString());
|
||||
}
|
||||
writer.printTagEnd(Tag.requireServices);
|
||||
}
|
||||
|
||||
private void printRequireSlots(SAX3WriterEnum<Tag,?> writer, List<WarpReactPlasma> slots) throws IOException {
|
||||
if (slots.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
writer.printTagStart(Tag.requireSlots);
|
||||
for (WarpReactPlasma slot : slots) {
|
||||
writer.printTagCharacters(Tag.requireSlot, slot.getSlotPath());
|
||||
}
|
||||
writer.printTagEnd(Tag.requireSlots);
|
||||
}
|
||||
|
||||
// public class ContentWriterInspector extends ContentWriterTagWrapper<Tag, ContentWriter> {
|
||||
//
|
||||
// public ContentWriterInspector(ContentWriter writer) {
|
||||
// super(writer);
|
||||
// }
|
||||
// }
|
||||
|
||||
public enum Tag {
|
||||
reactor, slot, requireSlots, requireSlot, requireServices, requireService, claimIn, claimOut, claimType;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* Copyright ©Δ∞ 仙上主天
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
|
||||
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
|
||||
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
|
||||
* even on air gaped systems, all information in the universe is owned by the pi creator.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package love.distributedrebirth.nx01.zerofungus.server.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpFilter;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import love.distributedrebirth.nx01.warp.fault.BassFaultAnchor;
|
||||
import love.distributedrebirth.nx01.warp.fault.FaultStreamDelegate;
|
||||
import love.distributedrebirth.nx01.warp.manifestor.WarpManifestorDriver;
|
||||
import love.distributedrebirth.nx01.warp.manifestor.manifest.WarpManifestX8;
|
||||
|
||||
/// Generic fault handler for human interaction.
|
||||
///
|
||||
/// @author للَّٰهِilLצسُو
|
||||
/// @version ©Δ∞ 仙上主天
|
||||
public class ZilLaLaFaultFilter extends HttpFilter {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger logger = Logger.getLogger(ZilLaLaFaultFilter.class.getName());
|
||||
|
||||
public void init() throws ServletException {
|
||||
logger.fine("ZilLaLa fault filter activacted.");
|
||||
}
|
||||
|
||||
protected void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain) throws IOException, ServletException {
|
||||
try {
|
||||
chain.doFilter(req, res);
|
||||
} catch (Exception error) {
|
||||
if (res.isCommitted()) {
|
||||
throw error;
|
||||
}
|
||||
BassFaultAnchor fault = wrap(error);
|
||||
WarpManifestX8 report = fault.toZilLaLaManyfesto();
|
||||
|
||||
// TODO: repack and forward to UI form to inspect AND connect+send into a NOSTR
|
||||
// relay
|
||||
|
||||
res.reset();
|
||||
res.setCharacterEncoding("utf-8");
|
||||
res.setStatus(500);
|
||||
res.setContentType("text/plain");
|
||||
PrintWriter out = res.getWriter();
|
||||
WarpManifestorDriver.writeV2StreamChar(report, out);
|
||||
out.flush();
|
||||
|
||||
// logger.warning(fault.toStringZilLaLa());
|
||||
// response.sendRedirect("/powp/error/errmsg.html?title=NotHere&msg=TheEnd");
|
||||
}
|
||||
}
|
||||
|
||||
private BassFaultAnchor wrap(Exception fault) {
|
||||
if (BassFaultAnchor.class.isAssignableFrom(fault.getClass())) {
|
||||
return BassFaultAnchor.class.cast(fault);
|
||||
}
|
||||
return new FaultStreamDelegate(fault, FaultStreamDelegate.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraFaultStackTraceJava3
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraFaultWarpVersion
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraRuntimeChapter
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraRuntimeThreads
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraSystemChapter
|
||||
love.distributedrebirth.nx01.warp.fault.report.ReportSitraSystemLocale
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
DROP TABLE IF EXISTS "ᒄᒃᓑᔆᓫᣗ";
|
||||
CREATE TABLE IF NOT EXISTS "ᒄᒃᓑᔆᓫᣗ" (
|
||||
"ᑊᑊᐣ" BIGINT NOT NULL AUTO_INCREMENT,
|
||||
"ᣕᣔᔿᓫ" VARCHAR(100) NOT NULL,
|
||||
"ᓑᔆᓫᣗᣕᣔᔿᓫ" VARCHAR(45) NOT NULL,
|
||||
"ᣖᣔᔆᔆᒡᒢᐤᣗᒄ" VARCHAR(256) NOT NULL,
|
||||
"ᓫᔿᣔᑊᒻ" VARCHAR(200) NOT NULL,
|
||||
"ᔆᐪᣔᐪᓑᔆ" VARCHAR(45) NOT NULL,
|
||||
delete_reason VARCHAR(500) NULL,
|
||||
create_dt DATETIME NOT NULL DEFAULT now(),
|
||||
create_uid BIGINT NOT NULL DEFAULT 1,
|
||||
modify_dt DATE NULL,
|
||||
modify_uid BIGINT NULL,
|
||||
PRIMARY KEY ("ᑊᑊᐣ"))
|
||||
;
|
||||
|
||||
CREATE UNIQUE INDEX "ᒄᒃᓑᔆᓫᣗᐨᓑᑊᐣᕁᐨᓑᔆᓫᣗᣕᣔᔿᓫ" ON "ᒄᒃᓑᔆᓫᣗ" ("ᓑᔆᓫᣗᣕᣔᔿᓫ" ASC);
|
||||
CREATE INDEX "ᒄᒃᓑᔆᓫᣗᐨᑊᑊᐣᕁᐨᔆᐪᣔᐪᓑᔆ" ON "ᒄᒃᓑᔆᓫᣗ" ("ᔆᐪᣔᐪᓑᔆ" ASC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "ᔆᐪᣔᒼᒽᑉ" (
|
||||
"ᑊᑊᐣ" text NOT NULL,
|
||||
"ᣖᓑᒃᒽᑉᓫᔾ" TEXT NOT NULL,
|
||||
"ᒼᣗᓫᣔᐪᓫᐝᒄᐪ" DATETIME NOT NULL DEFAULT now(),
|
||||
"ᑊᑉᑊᣕᒄ" INTEGER NOT NULL,
|
||||
"ᒄᓫᒻᐪᣔᕐ" TEXT NULL,
|
||||
"ᓫᕁᣖᑊᣗᓫᐝᒄᐪ" DATETIME NULL,
|
||||
"ᣗᣔᒡᒢ" JSON NOT NULL,
|
||||
PRIMARY KEY ("ᑊᑊᐣ"))
|
||||
;
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "ᔆᐪᣔᒼᒽᑉᐨᓑᑊᐣᕁᐨᑊᑊᐣ" ON "ᔆᐪᣔᒼᒽᑉ" USING btree ("ᑊᑊᐣ");
|
||||
CREATE INDEX IF NOT EXISTS "ᔆᐪᣔᒼᒽᑉᐨᑊᑊᐣᕁᐨᣖᓑᒃᒽᑉᓫᔾ" ON "ᔆᐪᣔᒼᒽᑉ" USING btree ("ᣖᓑᒃᒽᑉᓫᔾ");
|
||||
CREATE INDEX IF NOT EXISTS "ᔆᐪᣔᒼᒽᑉᐨᑊᑊᐣᕁᐨᒼᣗᓫᣔᐪᓫᐝᒄᐪ" ON "ᔆᐪᣔᒼᒽᑉ" ("ᒼᣗᓫᣔᐪᓫᐝᒄᐪ" DESC);
|
||||
CREATE INDEX IF NOT EXISTS "ᔆᐪᣔᒼᒽᑉᐨᑊᑊᐣᕁᐨᑊᑉᑊᣕᒄ" ON "ᔆᐪᣔᒼᒽᑉ" ("ᑊᑉᑊᣕᒄ");
|
||||
CREATE INDEX IF NOT EXISTS "ᔆᐪᣔᒼᒽᑉᐨᑊᑊᐣᕁᐨᓫᕁᣖᑊᣗᓫᐝᒄᐪ" ON "ᔆᐪᣔᒼᒽᑉ" ("ᓫᕁᣖᑊᣗᓫᐝᒄᐪ" DESC);
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
INSERT INTO "ᒄᒃᓑᔆᓫᣗ" ("ᑊᑊᐣ", "ᣕᣔᔿᓫ", "ᓑᔆᓫᣗᣕᣔᔿᓫ", "ᣖᣔᔆᔆᒡᒢᐤᣗᒄ", "ᓫᔿᣔᑊᒻ", "ᔆᐪᣔᐪᓑᔆ") VALUES (1, 'Technical User', 'tech', '00000000', 'technical@', 'TECHNICAL');
|
||||
INSERT INTO "ᒄᒃᓑᔆᓫᣗ" ("ᑊᑊᐣ", "ᣕᣔᔿᓫ", "ᓑᔆᓫᣗᣕᣔᔿᓫ", "ᣖᣔᔆᔆᒡᒢᐤᣗᒄ", "ᓫᔿᣔᑊᒻ", "ᔆᐪᣔᐪᓑᔆ") VALUES (2, 'Admin', 'admin', '000000000', 'admin@', 'ACTIVE');
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
-- Test case for H2 webconsole unicode autocomplete escaping and quoting.
|
||||
-- http://localhost:8080/debug/jdbc/console
|
||||
|
||||
CREATE SCHEMA "Господь мой пастырь";
|
||||
CREATE TABLE "Господь мой пастырь"."Я не захочу." (
|
||||
"Он заставляет меня лечь" BIGINT NOT NULL AUTO_INCREMENT,
|
||||
"на зеленых пастбищах" VARCHAR(500) NULL,
|
||||
"Он ведет меня" DATETIME NOT NULL DEFAULT now(),
|
||||
"возле стоячей воды" BIGINT NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY ("Он заставляет меня лечь"))
|
||||
;
|
||||
CREATE TABLE "Господь мой пастырь"."Он восстанавливает мою душу." (
|
||||
"Он ведет меня путями" BIGINT NOT NULL AUTO_INCREMENT,
|
||||
"праведности" VARCHAR(500) NULL,
|
||||
"ради его имени" DATETIME NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY ("Он ведет меня путями"))
|
||||
;
|
||||
CREATE SCHEMA "Хотя я иду по долине";
|
||||
CREATE TABLE "Хотя я иду по долине"."тени смерти" (
|
||||
"Я не буду бояться зла" BIGINT NOT NULL AUTO_INCREMENT,
|
||||
"ибо ты со мной;" VARCHAR(500) NULL,
|
||||
"твой жезл и твой посох," DATETIME NOT NULL DEFAULT now(),
|
||||
"они меня утешают." BIGINT NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY ("Я не буду бояться зла"))
|
||||
;
|
||||
CREATE INDEX "Ты готовишь стол раньше меня" ON "Хотя я иду по долине"."тени смерти" ("ибо ты со мной;" ASC);
|
||||
CREATE INDEX "в присутствии моих врагов;" ON "Хотя я иду по долине"."тени смерти" ("твой жезл и твой посох," ASC);
|
||||
CREATE TABLE "Хотя я иду по долине"."Ты помажешь мне голову маслом;" (
|
||||
"мой запас переполнен." BIGINT NOT NULL AUTO_INCREMENT,
|
||||
"Воистину, добро и милосердие последуют за мной." VARCHAR(100) NULL,
|
||||
"все дни моей жизни," VARCHAR(200) NULL,
|
||||
"и буду жить в доме Господнем" VARCHAR(300) NULL,
|
||||
"навсегда." VARCHAR(400) NULL,
|
||||
PRIMARY KEY ("мой запас переполнен."))
|
||||
;
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Helvetica Neue", "Helvetica", "Arial";
|
||||
font-size: 14px;
|
||||
background-color: rgba(45, 67, 49, 0.32);
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 500px;
|
||||
margin: 25px auto;
|
||||
padding-top: 25px;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
padding: 20px;
|
||||
background-color: #233927;
|
||||
color: #fff;
|
||||
-moz-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
form .dialog, #errorTitle {
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Error</title>
|
||||
<meta name="keywords" content="error">
|
||||
<meta name="description" content="Error">
|
||||
<script src="../../webjars/jquery/3.5.1/jquery.slim.min.js"></script>
|
||||
<link rel="stylesheet" href="errmsg.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="dialog">
|
||||
<h2 id="errorTitle">Error</h2>
|
||||
<p><br></p>
|
||||
<p>We could not process your request because;</p>
|
||||
<p id="errorMessage">...</p>
|
||||
<a href="/">Home</a>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
"use strict";
|
||||
(function($) {
|
||||
var searchParams = new URLSearchParams(window.location.search);
|
||||
if (searchParams.has('msg')) {
|
||||
$('#errorMessage').html(searchParams.get('msg').replace(/_/g, ' '));
|
||||
}
|
||||
if (searchParams.has('title')) {
|
||||
var title = searchParams.get('title').replace(/_/g, ' ');
|
||||
$('#errorTitle').html('Error || ' + title);
|
||||
window.document.title = 'Error || ' + title;
|
||||
}
|
||||
})(jQuery);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue