Giter Site home page Giter Site logo

nostcat's Introduction

nostcat

Crates.io Crates.io Crates.io

Websocket client command line tool for nostr relay scripting, with docker and tor support

Examples

Using interactive input

$ nostcat wss://relay.damus.io <return>
["REQ", "RAND", {"kinds": [1], "limit": 8}] <return>
<ctrl-D>

Using stdin (supports multiple lines of commands)

$ echo '["REQ", "RAND", {"kinds": [1], "limit": 8}]' |
  nostcat wss://relay.damus.io

$ cat commands.txt
["REQ", "RAND", {"kinds": [1], "limit": 2}]
["REQ", "RAND2", {"kinds": [2], "limit": 2}]

$ cat commands.txt | nostcat wss://relay.damus.io

Using jq to query Nostr JSON events and select the event JSON

$ echo '["REQ", "RAND", {"kinds": [1], "limit": 8}]' |
  nostcat wss://relay.damus.io |
  jq '.[2]'

$ echo '["REQ", "RAND", {"kinds": [1], "limit": 8}]' |
  nostcat wss://relay.damus.io |
  jq '.[2].content'

Unique (dedupe) results as they come in (note: no longer applies sorting events - FIFO)

$ echo '["REQ", "RAND", {"kinds": [1], "limit": 8}]' |
  nostcat --unique wss://relay.damus.io wss://nostr.ono.re

With a websocket connection timeout in milliseconds

$ echo '["REQ", "RAND", {"kinds": [1], "limit": 2}]' |
  nostcat --connect-timeout 250 wss://relay.damus.io

Stream websocket data (like tail -f)

$ echo '["REQ", "RAND", {"kinds": [1], "limit": 8}]' |
  nostcat --stream wss://relay.damus.io

Output info log messages which can assist with debugging

$ echo '["REQ", "RAND", {"kinds": [1], "limit": 8}]' |
  RUST_LOG=info nostcat wss://relay.damus.io

Pipe events from one server to another (currently limited to 1 event at a time)

$ echo '["REQ", "RAND", {"limit": 1}]' |
  nostcat wss://relay.damus.io |
  jq -c 'del(.[1])' |
  nostcat wss://nostr.ono.re

Pipe events from one server to another (for multiple events, ctrl-C when finished)

$ echo '["REQ", "RAND", {"limit": 3}]' |
  nostcat wss://relay.damus.io |
  jq -c 'del(.[1])' |
  nostcat --stream wss://nostr.ono.re
  <ctrl-C>

Getting started

Using Cargo to install (requires ~/.cargo/bin to be in PATH)

$ cargo install nostcat

Building from source (may be unstable)

$ git clone https://github.com/blakejakopovic/nostcat
$ cargo build --release

Running inside a Docker image

$ docker build -t nostcat .

# Run the the docker image as an executable
$ echo '["REQ", "RAND", {"kinds": [1], "limit": 2}]' | docker run --rm -i nostcat wss://relay.damus.io

nostcat's People

Contributors

blakejakopovic avatar jb55 avatar mattn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nostcat's Issues

Support multiple relays

you should be able to pass multiple relays as an argument to have it query them all at once.

So instead of 1 EOSE/OK we would expect N EOSE/OKs

Received unsupported nostr data:

When downloading events from wss://relay.realsearch.cc i get this error:
Received unsupported nostr data: "\n[\n\"EVENT\",\n\"RAND\",\n{\n\"id\":\"f9cb12c2e433b29a7441f897204804b83a5b9b7fdd903a759927029f17feac4e\",\n\"pubkey\":\"e022f5138944612a5cdbdaf13591fcf85c881f6616b8527eb24175aaca2c0aa0\",\n\"created_at\":1672993199,\n\"kind\":1,\n\"tags\":[\n[\n\"client\",\n\"astral\"\n]\n],\n\"content\":\"@5e7ae588d7d11eac4c25906e6da807e68c6498f49a38e4692be5a089616ceb18 Verifying My Public Key: \\\"highfar888\\\"\",\n\"sig\":\"621eba3ac2f6dc793c53a227a0553b83fca5355c8cc37546bbda87c983784af6e5ba6494639dd1612533e62b40249143852b061d225bc6a838d3a4823cf8323a\"\n}\n]"

Support for proxies / Tor

It would be nice if nostcat had built-in support for proxies (or just Tor, since my goal is to connect to a relay hosted on a .onion).

I found this tungstenite issue, but I'm not familiar enough with Rust to know how easy it'd be to implement any of the workarounds mentioned.

I can work around this in the meantime by doing torify nostcat, and was successfully able to connect to my onion that way. The downside is that since I'm running nostcat in Docker (see #5), that means installing extra dependencies in my container.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.