realy.lol

module
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2024 License: Unlicense

README

realy.lol

nostr relay built from a heavily modified fork of nbd-wtf/go-nostr and fiatjaf/relayer aimed at maximum performance, simplicity and memory efficiency.

includes:

  • a lot of other bits and pieces accumulated from nearly 8 years of working with Go, logging and run control, user data directories (windows, mac, linux, android)
  • a cleaned up and unified fork of the btcd/dcred BIP-340 signatures, including the use of bitcoin core's BIP-340 implementation (more than 4x faster than btcd)
  • AVX/AVX2 optimized SHA256 and SIMD hex encoder
  • a bespoke, mutable byte slice based hash/pubkey/signature encoding in memory and the fastest nostr binary codec that exists
  • custom badger based event store with a garbage collector that prunes off data with least recent access
  • vanity npub generator that can mine a 5 letter prefix in around 15 minutes on a 6 core Ryzen 5 processor
  • reverse proxy tool with support for Go vanity imports and nip-05 npub DNS verification and own TLS certificates

CGO and secp256k1 signatures library

By default, Go will usually be configured with CGO_ENABLED=1. This selects the use of the C library from bitcoin core, which does signatures and verifications much faster (4x and better) but complicates the build process as you have to install the library beforehand. There is instructions in p256k/README.md for doing this.

In order to disable the use of this, you must set the environment variable CGO_ENABLED=0 and it the Go compiler will automatically revert to using the btcec based secp256k1 signatures library.

export CGO_ENABLED=0
cd cmd/realy
go build .

This will build the binary and place it in cmd/realy and then you can move it where you like.

Static build

To produce a static binary, whether you use the CGO secp256k1 or disable CGO as above:

go build --ldflags '-extldflags "-static"' -o ~/bin/realy ./cmd/realy/.

will place it into your ~/bin/ directory, and it will work on any system of the same architecture with the same glibc major version (has been 2 for a long time).

Export and Import functions

You can export everything in the event store through the default http://localhost:3337 endpoint like so:

curl http://localhost:3337/export > everything.jsonl

or just all of the whitelisted users and all events with p tags with them in it:

curl http://localhost:3337/export/users > users.jsonl

or just one user: (includes also matching p tags)

curl http://localhost:3337/export/4c800257a588a82849d049817c2bdaad984b25a45ad9f6dad66e47d3b47e3b2f > mleku.jsonl

or several users with hyphens between the hexadecimal public keys: (ditto above)

curl http://localhost:3337/export/4c800257a588a82849d049817c2bdaad984b25a45ad9f6dad66e47d3b47e3b2f-454bc2771a69e30843d0fccfde6e105ff3edc5c6739983ef61042633e4a9561a > mleku_gojiberra.jsonl

and import also, to put one of these files (also nostrudel and coracle have functions to export the app database of events in jsonl)

curl -XPOST -T nostrudel.jsonl http://localhost:3337/import

todo: more documentation coming

Directories

Path Synopsis
Package atomic provides simple wrappers around numerics to enforce atomic access.
Package atomic provides simple wrappers around numerics to enforce atomic access.
internal/gen-atomicint
gen-atomicint generates an atomic wrapper around an integer type.
gen-atomicint generates an atomic wrapper around an integer type.
internal/gen-atomicwrapper
gen-atomicwrapper generates wrapper types around other atomic types.
gen-atomicwrapper generates wrapper types around other atomic types.
cmd
lerproxy
Command lerproxy implements https reverse proxy with automatic LetsEncrypt usage for multiple hostnames/backends, and URL rewriting capability.
Command lerproxy implements https reverse proxy with automatic LetsEncrypt usage for multiple hostnames/backends, and URL rewriting capability.
Package context is a set of shorter names for the very stuttery context library.
Package context is a set of shorter names for the very stuttery context library.
ec
Package btcec implements support for the elliptic curves needed for bitcoin.
Package btcec implements support for the elliptic curves needed for bitcoin.
base58
Package base58 provides an API for working with modified base58 and Base58Check encodings.
Package base58 provides an API for working with modified base58 and Base58Check encodings.
bech32
Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.
Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.
chainhash
Package chainhash provides abstracted hash functionality.
Package chainhash provides abstracted hash functionality.
ecdsa
Package ecdsa provides secp256k1-optimized ECDSA signing and verification.
Package ecdsa provides secp256k1-optimized ECDSA signing and verification.
hex
schnorr
Package schnorr provides custom Schnorr signing and verification via secp256k1.
Package schnorr provides custom Schnorr signing and verification via secp256k1.
secp256k1
Package secp256k1 implements optimized secp256k1 elliptic curve operations in pure Go.
Package secp256k1 implements optimized secp256k1 elliptic curve operations in pure Go.
gen
del
keys
Package keys is a composable framework for constructing badger keys from fields of events.
Package keys is a composable framework for constructing badger keys from fields of events.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL