Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from hoytech:master #17

Merged
merged 11 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
run: |
sudo apt update && sudo apt install -y --no-install-recommends \
git g++ make pkg-config libtool ca-certificates \
libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev \
liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
git submodule update --init
make setup-golpe
make -j4
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ RUN \
pkgconfig \
libtool \
ca-certificates \
perl-yaml \
perl-template-toolkit \
perl-app-cpanminus \
libressl-dev \
zlib-dev \
lmdb-dev \
flatbuffers-dev \
libsecp256k1-dev \
zstd-dev \
&& rm -rf /var/cache/apk/* \
&& cpanm Regexp::Grammars \
&& git submodule update --init \
&& make setup-golpe \
&& make -j4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ LDLIBS += -lsecp256k1 -lzstd
INCS += -Iexternal/negentropy/cpp

build/StrfryTemplates.h: $(shell find src/tmpls/ -type f -name '*.tmpl')
perl golpe/external/templar/templar.pl src/tmpls/ strfrytmpl $@
PERL5LIB=golpe/vendor/ perl golpe/external/templar/templar.pl src/tmpls/ strfrytmpl $@

src/apps/relay/RelayWebsocket.o: build/StrfryTemplates.h
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ A C++20 compiler is required, along with a few other common dependencies. On Deb

#### Linux

sudo apt install -y git build-essential libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
sudo apt install -y git g++ make libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
git clone https://github.com/hoytech/strfry && cd strfry/
git submodule update --init
make setup-golpe
make -j4

#### FreeBSD

pkg install -y gcc gmake cmake git perl5 openssl lmdb flatbuffers libuv libinotify zstr secp256k1 zlib-ng p5-Regexp-Grammars p5-Module-Install-Template p5-YAML
pkg install -y gcc gmake cmake git perl5 openssl lmdb flatbuffers libuv libinotify zstr secp256k1 zlib-ng
git clone https://github.com/hoytech/strfry && cd strfry/
git submodule update --init
gmake setup-golpe
Expand Down
5 changes: 0 additions & 5 deletions arch.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,9 @@ RUN pacman -Syu --noconfirm
RUN pacman -S --noconfirm \
# build essentials
base-devel git \
# perl stuff
cpanminus perl-template-toolkit perl-yaml \
# flatbuffers, lmdb, libsecp256k1
flatbuffers lmdb libsecp256k1

# necessary perl pod
RUN /usr/bin/vendor_perl/cpanm Regexp::Grammars

# update submodules
RUN git submodule update --init

Expand Down
2 changes: 1 addition & 1 deletion golpe
Submodule golpe updated 58 files
+2 −0 LoadGolpe.pm
+1 −1 external/hoytech-cpp
+3 −3 gen-config.pl
+0 −0 gen-fbs.pl
+4 −4 gen-golpe.h.pl
+3 −3 gen-main.cpp.pl
+19 −4 golpe.h.tt
+24 −0 if-feature.pl
+18 −11 main.cpp.tt
+0 −0 pre-build.pl
+21 −14 rules.mk
+6,926 −0 vendor/Regexp/Grammars.pm
+935 −0 vendor/Template.pm
+283 −0 vendor/Template/Base.pm
+429 −0 vendor/Template/Config.pm
+265 −0 vendor/Template/Constants.pm
+1,550 −0 vendor/Template/Context.pm
+1,069 −0 vendor/Template/Directive.pm
+537 −0 vendor/Template/Document.pm
+229 −0 vendor/Template/Exception.pm
+849 −0 vendor/Template/Filters.pm
+6,237 −0 vendor/Template/Grammar.pm
+493 −0 vendor/Template/Iterator.pm
+176 −0 vendor/Template/Namespace/Constants.pm
+1,221 −0 vendor/Template/Parser.pm
+369 −0 vendor/Template/Plugin.pm
+465 −0 vendor/Template/Plugins.pm
+1,399 −0 vendor/Template/Provider.pm
+573 −0 vendor/Template/Service.pm
+890 −0 vendor/Template/Stash.pm
+773 −0 vendor/Template/Stash/Context.pm
+137 −0 vendor/Template/Stash/XS.pm
+720 −0 vendor/Template/Test.pm
+146 −0 vendor/Template/Toolkit.pm
+694 −0 vendor/Template/VMethods.pm
+747 −0 vendor/Template/View.pm
+117 −0 vendor/YAML.pm
+123 −0 vendor/YAML/Any.pm
+165 −0 vendor/YAML/Any.pod
+578 −0 vendor/YAML/Dumper.pm
+38 −0 vendor/YAML/Dumper.pod
+111 −0 vendor/YAML/Dumper/Base.pm
+35 −0 vendor/YAML/Dumper/Base.pod
+191 −0 vendor/YAML/Error.pm
+35 −0 vendor/YAML/Error.pod
+839 −0 vendor/YAML/Loader.pm
+39 −0 vendor/YAML/Loader.pod
+38 −0 vendor/YAML/Loader/Base.pm
+35 −0 vendor/YAML/Loader/Base.pod
+47 −0 vendor/YAML/Marshall.pm
+36 −0 vendor/YAML/Marshall.pod
+80 −0 vendor/YAML/Mo.pm
+218 −0 vendor/YAML/Node.pm
+91 −0 vendor/YAML/Node.pod
+19 −0 vendor/YAML/Tag.pm
+34 −0 vendor/YAML/Tag.pod
+240 −0 vendor/YAML/Types.pm
+38 −0 vendor/YAML/Types.pod
12 changes: 9 additions & 3 deletions golpe.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
appName: strfry
onAppStartup: true
useGlobalH: true
customLMDBSetup: true
features:
ssl: true
config: true
onAppStartup: true
db: true
customLMDBSetup: true
flatbuffers: true
websockets: true
templar: true

flatBuffers: |
include "../fbs/nostr-index.fbs";
Expand Down
3 changes: 1 addition & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
with pkgs;
mkShell {
buildInputs = [
perl perlPackages.YAML perlPackages.TemplateToolkit perlPackages.RegexpGrammars
lmdb zstd secp256k1 flatbuffers zlib openssl libuv
perl lmdb zstd secp256k1 flatbuffers zlib openssl libuv
];
}
11 changes: 11 additions & 0 deletions src/apps/relay/RelayIngester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ void RelayServer::ingesterProcessEvent(lmdb::txn &txn, uint64_t connId, std::str

auto *flat = flatbuffers::GetRoot<NostrIndex::Event>(flatStr.data());

{
for (const auto &tagArr : origJson.at("tags").get_array()) {
auto tag = tagArr.get_array();
if (tag.size() == 1 && tag.at(0).get_string() == "-") {
LI << "Protected event, skipping";
sendOKResponse(connId, to_hex(sv(flat->id())), false, "blocked: event marked as protected");
return;
}
}
}

{
auto existing = lookupEventById(txn, sv(flat->id()));
if (existing) {
Expand Down
8 changes: 7 additions & 1 deletion src/apps/relay/RelayWebsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,26 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
tempBuf.reserve(cfg().events__maxEventSize + MAX_SUBID_SIZE + 100);


tao::json::value supportedNips = tao::json::value::array({ 1, 2, 4, 9, 11, 12, 16, 20, 22, 28, 33, 40 });
tao::json::value supportedNips = tao::json::value::array({ 1, 2, 4, 9, 11, 20, 22, 28, 40, 70 });

auto getServerInfoHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable {
if (ver != cfg().version()) {
tao::json::value nip11 = tao::json::value({
{ "supported_nips", supportedNips },
{ "software", "git+https://github.com/hoytech/strfry.git" },
{ "version", APP_GIT_VERSION },
{ "limitation", tao::json::value({
{ "max_message_length", cfg().relay__maxWebsocketPayloadSize },
{ "max_subscriptions", cfg().relay__maxSubsPerConnection },
{ "max_limit", cfg().relay__maxFilterLimit },
}) },
});

if (cfg().relay__info__name.size()) nip11["name"] = cfg().relay__info__name;
if (cfg().relay__info__description.size()) nip11["description"] = cfg().relay__info__description;
if (cfg().relay__info__contact.size()) nip11["contact"] = cfg().relay__info__contact;
if (cfg().relay__info__pubkey.size()) nip11["pubkey"] = cfg().relay__info__pubkey;
if (cfg().relay__info__icon.size()) nip11["icon"] = cfg().relay__info__icon;

rendered = preGenerateHttpResponse("application/json", tao::json::to_string(nip11));
ver = cfg().version();
Expand Down
3 changes: 3 additions & 0 deletions src/apps/relay/golpe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ config:
- name: relay__info__contact
desc: "NIP-11: Alternative administrative contact (email, website, etc)"
default: ""
- name: relay__info__icon
desc: "NIP-11: URL pointing to an image to be used as an icon for the relay"
default: ""

- name: relay__maxWebsocketPayloadSize
desc: "Maximum accepted incoming websocket frame size (should be larger than max event)"
Expand Down
14 changes: 0 additions & 14 deletions src/onAppStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ static void dbCheck(lmdb::txn &txn, const std::string &cmd) {
auto s = env.lookup_Meta(txn, 1);

if (!s) {
{
// The first version of the DB didn't use a Meta entry -- we consider this version 0

bool eventFound = false;

env.foreach_Event(txn, [&](auto &ev){
eventFound = true;
return false;
});

if (cmd == "export" || cmd == "info") return;
if (eventFound) dbTooOld(0);
}

env.insert_Meta(txn, CURR_DB_VERSION, 1);
return;
}
Expand Down
3 changes: 3 additions & 0 deletions strfry.conf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ relay {

# NIP-11: Alternative administrative contact (email, website, etc)
contact = ""

# NIP-11: URL pointing to an image to be used as an icon for the relay
icon = ""
}

# Maximum accepted incoming websocket frame size (should be larger than max event) (restart required)
Expand Down
5 changes: 2 additions & 3 deletions ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ ENV TZ=Europe/London
WORKDIR /build
RUN apt update && apt install -y --no-install-recommends \
git g++ make pkg-config libtool ca-certificates \
libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev \
liblmdb-dev libflatbuffers-dev libsecp256k1-dev \
libzstd-dev
libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev \
libsecp256k1-dev libzstd-dev

COPY . .
RUN git submodule update --init
Expand Down