Easter cleaning

This commit is contained in:
Willem Cazander 2025-05-07 21:46:32 +02:00
commit 9e36078b2e
1862 changed files with 270281 additions and 0 deletions

View file

@ -0,0 +1,40 @@
<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-no2all-react-nostr</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nx01-no2all-nostr</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nx01-no2all-react-wire</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nx01-no2all-wire-ojw</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.parsson</groupId>
<artifactId>parsson</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,58 @@
/*
* 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.no2all.react.nostr.client;
import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import jakarta.json.Json;
import jakarta.json.JsonReader;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrRelayInfo;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrRelayFetchInfo {
public NoStrRelayInfo fetchRelayInfo(URI uri) throws IOException, InterruptedException {
HttpRequest request = HttpRequest.newBuilder(uri).header("Accept", "application/nostr+json").build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, BodyHandlers.ofString());
if (response.statusCode() != 200) {
return null;
}
String contentJson = response.body();
try (JsonReader read = Json.createReader(new StringReader(contentJson))) {
NoStrRelayInfo result = new NoStrRelayInfo(read.readObject());
return result;
}
}
}

View file

@ -0,0 +1,38 @@
/*
* 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.no2all.react.nostr.client;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public enum NoStrRelayReadType {
NONE,
ALL,
;
}

View file

@ -0,0 +1,101 @@
/*
* 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.no2all.react.nostr.client;
import love.distributedrebirth.nx01.no2all.nostr.NoStr;
import love.distributedrebirth.nx01.no2all.nostr.fire.NoStrFirePipe;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientAuth;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientCount;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientEose;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientNotice;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientOk;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelay;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayAuth;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayClose;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayCount;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayReq;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllActClientClose;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllActClientSendMessage;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClient;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClientOnMessage;
import love.distributedrebirth.nx01.warp.core.react.WarpReact;
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaCoil;
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 NoStrRtsClient extends WarpReactTypeScriptPlasmaAdapter {
public NoStrRtsClient(WarpReactPlasma antimatterVortexSlot) {
super(antimatterVortexSlot);
}
@Override
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
WarpReact react = signal.getReact();
WarpReactPlasma slot = getAntimatterVortexSlot();
react.registrate(slot, No2AllArtClient.class, artClient -> {
WarpReactPlasma clientSlot = artClient.getData().getSlot();
react.claimIn(clientSlot, NoStrMsgToRelayAuth.class);
react.claimIn(clientSlot, NoStrMsgToRelayClose.class);
react.claimIn(clientSlot, NoStrMsgToRelayCount.class);
react.claimIn(clientSlot, NoStrMsgToRelayEvent.class);
react.claimIn(clientSlot, NoStrMsgToRelayReq.class);
react.claimOut(clientSlot, NoStrMsgToClientAuth.class);
react.claimOut(clientSlot, NoStrMsgToClientCount.class);
react.claimOut(clientSlot, NoStrMsgToClientEose.class);
react.claimOut(clientSlot, NoStrMsgToClientEvent.class);
react.claimOut(clientSlot, NoStrMsgToClientNotice.class);
react.claimOut(clientSlot, NoStrMsgToClientOk.class);
NoStrFirePipe pipeReader = NoStr.FACTORY.pipeReaderClient(reason -> {
react.fire(clientSlot, No2AllActClientClose.ofRefuse(reason));
}, message -> {
react.fire(clientSlot, message);
});
react.registrate(clientSlot, No2AllArtClientOnMessage.class, v -> {
pipeReader.onFire(v.getData().getMessage());
});
react.registrate(clientSlot, NoStrMsgToRelayAuth.class, pipeWriter(react, clientSlot));
react.registrate(clientSlot, NoStrMsgToRelayClose.class, pipeWriter(react, clientSlot));
react.registrate(clientSlot, NoStrMsgToRelayCount.class, pipeWriter(react, clientSlot));
react.registrate(clientSlot, NoStrMsgToRelayEvent.class, pipeWriter(react, clientSlot));
react.registrate(clientSlot, NoStrMsgToRelayReq.class, pipeWriter(react, clientSlot));
});
}
private <T extends NoStrMsgToRelay> WarpReactPlasmaCoil<T> pipeWriter(WarpReact react, WarpReactPlasma clientSlot) {
return v -> {
react.fire(clientSlot, new No2AllActClientSendMessage(v.getData().toBible().toString()));
};
}
}

View file

@ -0,0 +1,115 @@
/*
* 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.no2all.react.nostr.server;
import love.distributedrebirth.nx01.no2all.nostr.NoStr;
import love.distributedrebirth.nx01.no2all.nostr.fire.NoStrFirePipe;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClient;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientAuth;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientCount;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientEose;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientNotice;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientOk;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayAuth;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayClose;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayCount;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayReq;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllActServerBroadcastMessage;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllActServerSocketClose;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllActServerSocketSendMessage;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocket;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocketOnMessage;
import love.distributedrebirth.nx01.warp.core.react.WarpReact;
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaCoil;
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 NoStrRtsServer extends WarpReactTypeScriptPlasmaAdapter {
public NoStrRtsServer(WarpReactPlasma antimatterVortexSlot) {
super(antimatterVortexSlot);
}
@Override
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
WarpReact react = signal.getReact();
WarpReactPlasma slot = getAntimatterVortexSlot();
react.claimIn(slot, NoStrMsgToClientNotice.class);
react.registrate(slot, NoStrMsgToClientNotice.class, v -> {
react.fireForEach(slot, new No2AllActServerBroadcastMessage(v.getData().toBible().toString()));
});
react.registrate(slot, No2AllArtServer.class, artServer -> {
WarpReactPlasma serverSlot = artServer.getData().getSlot();
react.claimIn(serverSlot, NoStrMsgToClientNotice.class);
react.registrate(serverSlot, No2AllArtServerSocket.class, artSocket -> {
WarpReactPlasma socketSlot = artSocket.getData().getSlot();
react.claimIn(socketSlot, NoStrMsgToClientAuth.class);
react.claimIn(socketSlot, NoStrMsgToClientCount.class);
react.claimIn(socketSlot, NoStrMsgToClientEose.class);
react.claimIn(socketSlot, NoStrMsgToClientEvent.class);
react.claimIn(socketSlot, NoStrMsgToClientNotice.class);
react.claimIn(socketSlot, NoStrMsgToClientOk.class);
react.claimOut(socketSlot, NoStrMsgToRelayAuth.class);
react.claimOut(socketSlot, NoStrMsgToRelayClose.class);
react.claimOut(socketSlot, NoStrMsgToRelayCount.class);
react.claimOut(socketSlot, NoStrMsgToRelayEvent.class);
react.claimOut(socketSlot, NoStrMsgToRelayReq.class);
NoStrFirePipe pipeReader = NoStr.FACTORY.pipeReaderRelay(reason -> {
react.fire(socketSlot, No2AllActServerSocketClose.ofRefuse(reason));
}, message -> {
react.fire(socketSlot, message);
});
react.registrate(socketSlot, No2AllArtServerSocketOnMessage.class, v -> {
pipeReader.onFire(v.getData().getMessage());
});
react.registrate(socketSlot, NoStrMsgToClientAuth.class, pipeWriter(react, socketSlot));
react.registrate(socketSlot, NoStrMsgToClientCount.class, pipeWriter(react, socketSlot));
react.registrate(socketSlot, NoStrMsgToClientEose.class, pipeWriter(react, socketSlot));
react.registrate(socketSlot, NoStrMsgToClientEvent.class, pipeWriter(react, socketSlot));
react.registrate(socketSlot, NoStrMsgToClientNotice.class, pipeWriter(react, socketSlot));
react.registrate(socketSlot, NoStrMsgToClientOk.class, pipeWriter(react, socketSlot));
});
react.registrate(serverSlot, NoStrMsgToClientNotice.class, v -> {
react.fire(serverSlot, new No2AllActServerBroadcastMessage(v.getData().toBible().toString()));
});
});
}
private <T extends NoStrMsgToClient> WarpReactPlasmaCoil<T> pipeWriter(WarpReact react, WarpReactPlasma clientSlot) {
return v -> {
react.fire(clientSlot, new No2AllActServerSocketSendMessage(v.getData().toBible().toString()));
};
}
}

View file

@ -0,0 +1,51 @@
/*
* 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.no2all.react.nostr.server.relay;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEvent;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public final class NoStrArtServerRelayStoreEvent {
private final NoStrEvent event;
private final String remoteAddr;
protected NoStrArtServerRelayStoreEvent(NoStrEvent event, String remoteAddr) {
this.event = event;
this.remoteAddr = remoteAddr;
}
public NoStrEvent getEvent() {
return event;
}
public String getRemoteAddr() {
return remoteAddr;
}
}

View file

@ -0,0 +1,95 @@
/*
* 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.no2all.react.nostr.server.relay;
import java.util.logging.Logger;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventSignature;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToClientOk;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayEvent;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplMessageOkReason;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocket;
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 NoStrRtsServerRelay extends WarpReactTypeScriptPlasmaAdapter {
private static final Logger logger = Logger.getLogger(NoStrRtsServerRelay.class.getName());
public NoStrRtsServerRelay(WarpReactPlasma antimatterVortexSlot) {
super(antimatterVortexSlot);
}
@Override
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
WarpReact react = signal.getReact();
WarpReactPlasma slot = getAntimatterVortexSlot();
react.claimOut(slot, NoStrArtServerRelayStoreEvent.class);
react.registrate(slot, No2AllArtServer.class, artServer -> {
WarpReactPlasma serverSlot = artServer.getData().getSlot();
react.registrate(serverSlot, No2AllArtServerSocket.class, artSocket -> {
WarpReactPlasma socketSlot = artSocket.getData().getSlot();
react.registrate(socketSlot, NoStrMsgToRelayEvent.class, v -> {
handleRelayEvent(react, v.getData().getEvent(), artSocket.getData().getRemoteAddr(), socketSlot, slot);
});
});
});
}
private void handleRelayEvent(WarpReact react, NoStrEvent event, String remoteAddr, WarpReactPlasma socketSlot, WarpReactPlasma serverSlot) {
boolean eventSaved = false;
String eventResponse = "";
NoStrImplMessageOkReason eventReason = NoStrImplMessageOkReason.DEFAULT;
// filter on
event.getPayload().getKind();
event.getPayload().getPublicKey();
event.getPayload().getTags();
eventSaved = NoStrEventSignature.verify(event);
if (!eventSaved) {
eventReason = NoStrImplMessageOkReason.INVALID;
}
logger.fine("Validate event: " + eventSaved + " eventId: " + event.getId());
if (eventSaved) {
react.fire(serverSlot, new NoStrArtServerRelayStoreEvent(event, remoteAddr));
}
react.fire(socketSlot, new NoStrMsgToClientOk(event.getId(), eventSaved, eventReason, eventResponse));
}
}

View file

@ -0,0 +1,68 @@
/*
* 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.no2all.react.nostr.server.relay;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayClose;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayReq;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocket;
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 NoStrRtsServerRelaySubs extends WarpReactTypeScriptPlasmaAdapter {
public NoStrRtsServerRelaySubs(WarpReactPlasma antimatterVortexSlot) {
super(antimatterVortexSlot);
}
@Override
public void onEvent(WarpReactPlasmaPulse<WarpSpaceAntimatterInducer> signal) {
WarpReact react = signal.getReact();
WarpReactPlasma slot = getAntimatterVortexSlot();
react.registrate(slot, No2AllArtServer.class, v -> {
WarpReactPlasma serverSlot = v.getData().getSlot();
react.registrate(serverSlot, No2AllArtServerSocket.class, x -> {
WarpReactPlasma socketSlot = x.getData().getSlot();
react.registrate(socketSlot, NoStrMsgToRelayReq.class, y -> {
String subId = y.getData().getSubscriptionId();
y.getData().getFilters();
System.out.println("sub new: " + subId);
});
react.registrate(socketSlot, NoStrMsgToRelayClose.class, y -> {
String subId = y.getData().getSubscriptionId();
System.out.println("sub clone: " + subId);
});
});
});
}
}

View file

@ -0,0 +1,135 @@
/*
* 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.no2all.react.nostr.client;
import java.net.URI;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import love.distributedrebirth.nx01.no2all.nostr.NoStr;
import love.distributedrebirth.nx01.no2all.nostr.fire.NoStrFireWaterBoiler;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentity;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentityPrivateKey;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.message.NoStrMsgToRelayEvent;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplEventKind;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllActClient;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllActClientClose;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllActClientConnect;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClient;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClientOnClose;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClientOnError;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClientOnMessage;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClientOnOpen;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllArtClientOnStart;
import love.distributedrebirth.nx01.no2all.react.wire.client.No2AllRtsClient;
import love.distributedrebirth.nx01.no2all.wire.ojw.OjwWireClientEndpoint;
import love.distributedrebirth.nx01.warp.core.WarpCoreReactor;
import love.distributedrebirth.nx01.warp.core.WarpCoreSpeedMonitor;
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrClientTest {
public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newFixedThreadPool(10);
NoStrIdentity nid = new NoStrIdentity(NoStrIdentityPrivateKey.ofRandom());
WarpCoreReactor react = new WarpCoreReactor();
WarpReactPlasma mushroomClient = WarpReactPlasma.ofClass(NoStrClientTest.class);
react.claim(mushroomClient);
react.load(new WarpCoreSpeedMonitor());
react.load(new No2AllRtsClient(mushroomClient));
react.load(new NoStrRtsClient(mushroomClient));
react.registrate(mushroomClient, No2AllArtClient.class, v -> {
WarpReactPlasma clientSlot = v.getData().getSlot();
System.out.println("NoStrClient created: " + clientSlot.getSlotPath());
react.registrate(clientSlot, No2AllArtClientOnError.class, x -> {
System.out.println("NoStrClient socket error: " + x.getData().getError().getMessage());
});
react.registrate(clientSlot, No2AllArtClientOnClose.class, x -> {
System.out.println("NoStrClient socket close: " + x.getData().getCode() + " " + x.getData().getReason());
});
react.registrate(clientSlot, No2AllArtClientOnOpen.class, x -> {
System.out.println("NoStrClient socket open");
executor.submit(() -> {
try {
for (int i = 0; i < 10; i++) {
NoStrFireWaterBoiler userBoiler = NoStr.FACTORY.boiler(nid);
NoStrEvent event = userBoiler.smoker()
.tagSubject("Reply to all")
.tagR("")
.burn()
.water(NoStrImplEventKind.TEXT_NOTE, "Hello world:"+i);
System.out.println("send msg");
NoStrMsgToRelayEvent msg = new NoStrMsgToRelayEvent(event);
react.fire(clientSlot, msg);
Thread.sleep(1000);
}
} catch (Exception ex) {
ex.printStackTrace();
}
});
});
react.registrate(clientSlot, No2AllArtClientOnMessage.class, y -> {
System.out.println("NoStrClient got msg1: " + y.getData().getMessage());
});
// Todo "OnStart" is not working...
react.registrate(clientSlot, No2AllArtClientOnStart.class, x -> {
System.out.println("NoStrClient socket start");
});
react.fire(clientSlot, new No2AllActClientConnect());
});
OjwWireClientEndpoint clientEndpoint = new OjwWireClientEndpoint(new URI("ws://localhost:8080/ws/nostr"));
System.out.println("NoStrClient start");
react.fire(mushroomClient, new No2AllActClient(clientEndpoint));
Thread.sleep(30000);
executor.shutdown();
executor.awaitTermination(60, TimeUnit.SECONDS);
Thread exitTimer = new Thread(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
System.out.println("NoStrClient stopping");
react.fireForEach(mushroomClient, No2AllActClientClose.ofNormal("exit"));
System.out.println("NoStrClient stopped");
});
exitTimer.start();
}
}

View file

@ -0,0 +1,96 @@
/*
* 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.no2all.react.nostr.server;
import java.net.InetSocketAddress;
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.server.No2AllActServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerOnStart;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocket;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocketOnClose;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServerLog;
import love.distributedrebirth.nx01.no2all.wire.ojw.OjwWireServer;
import love.distributedrebirth.nx01.no2all.wire.ojw.OjwWireServerEndpoint;
import love.distributedrebirth.nx01.warp.core.WarpCoreReactor;
import love.distributedrebirth.nx01.warp.core.WarpCoreSpeedMonitor;
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrServerTest {
static OjwWireServer server = null;
public static void main(String[] args) throws Exception {
WarpReactPlasma mushroomServer = WarpReactPlasma.ofClass(NoStrServerTest.class);
WarpCoreReactor react = new WarpCoreReactor();
react.claim(mushroomServer);
react.load(new WarpCoreSpeedMonitor());
react.load(new No2AllRtsServer(mushroomServer));
react.load(new No2AllRtsServerLog(mushroomServer));
react.load(new NoStrRtsServer(mushroomServer));
react.load(new NoStrRtsServerRelay(mushroomServer));
react.load(new NoStrRtsServerRelaySubs(mushroomServer));
react.registrate(mushroomServer, No2AllArtServer.class, artServer -> {
WarpReactPlasma serverSlot = artServer.getData().getSlot();
react.registrate(serverSlot, No2AllArtServerOnStart.class, v -> {
System.out.println("RelayServer started: " + v.getTarget().getSlotSlug());
});
react.registrate(serverSlot, No2AllArtServerSocket.class, v -> {
System.out.println("RelayServer client-open: " + v.getData().getSlot().getSlotPath());
react.registrate(v.getData().getSlot(), No2AllArtServerSocketOnClose.class, y -> {
System.out.println("RelayServer client-close: " + y.getData().getCode() + " of: " + y.getTarget().getSlotPath());
});
});
react.registrate(serverSlot, OjwWireServer.class, x -> { // TODO: add interface matching ...
server = x.getData();
});
});
System.out.println("RelayServer fire configs");
OjwWireServerEndpoint serverEndpoint = new OjwWireServerEndpoint(new InetSocketAddress(8080), 120);
react.fire(mushroomServer, new No2AllActServer(serverEndpoint));
for (int i=0;i<1000;i++) {
//react.fire(No2AllServerRTS.API, react);
Thread.sleep(100);
}
Thread.sleep(40000);
if (server != null) {
System.out.println("RelayServers stopping");
server.getHandler().stop();
}
//react.fireForEach(No2AllServerRTS.API, new No2AllActServerStop());
System.out.println("RelayServers stopped");
}
}