Skip to content

Commit

Permalink
examples: update the examples README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuhvi committed Feb 8, 2025
1 parent c502253 commit 1fc0814
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
48 changes: 33 additions & 15 deletions pkarr/examples/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,59 @@

# Examples

## Publish

```sh
cargo run --example publish
```

or to use a Relay client:
Publish a SignedPacket for a randomly generated keypair.

```sh
cargo run --features relay --example publish
cargo run --example publish [MODE] [RELAYS]
```
```
Arguments:
[MODE] Publish to DHT only, Relays only, or default to both [possible values: dht, relays, both]
[RELAYS]... List of relays (only valid if mode is 'relays')
```

## Resolve

```sh
cargo run --example resolve <zbase32 public key from Publish step>
```

or to use a Relay client:
Resolve a SignedPacket for a given public key.

```sh
cargo run --features relay --example resolve <zbase32 public key from Publish step>
cargo run --example resolve <PUBLIC_KEY> [MODE] [RELAYS]
```
```
Arguments:
<PUBLIC_KEY> Pkarr public key (z-base32 encoded) or a url where the TLD is a Pkarr key
[MODE] Resolve from DHT only, Relays only, or default to both [possible values: dht, relays, both]
[RELAYS]... List of relays (only valid if mode is 'relays')
```

## HTTP

### Serve

Run an HTTP server listening on a Pkarr key

```sh
cargo run --features endpoints --example http-serve <ip address> <port number>
cargo run --features=tls --example http-serve <IP> <PORT>
```
```
Arguments:
<IP> IP address to listen on (needs to be a public IP address)
<PORT> Port number to listen no (needs to be an open port)
```

An HTTPs url will be printend with the Pkarr key as the TLD, paste in another terminal window:
An HTTPs url will be printend with the Pkarr key as the TLD, paste in another terminal window with the next command.

### Get


```sh
cargo run --features reqwest-resolve --example http-get <url>
cargo run --features=reqwest-builder --example http-get <URL>
```
```
Arguments:
<URL> Url to GET from
```

And you should see a `Hello, World!` response.
2 changes: 1 addition & 1 deletion pkarr/examples/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use pkarr::{Client, PublicKey};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Mutable data public key.
/// Pkarr public key (z-base32 encoded) or a url where the TLD is a Pkarr key.
public_key: String,
/// Resolve from DHT only, Relays only, or default to both.
#[arg(value_enum)]
Expand Down

0 comments on commit 1fc0814

Please # to comment.