Skip to content

Commit

Permalink
feat: configure server with env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Feb 29, 2024
1 parent 7476782 commit ae409e1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ $ docker pull ghcr.io/ipfs/someguy:main-latest
$ docker run --rm -it --net=host -e ghcr.io/ipfs/someguy:main-latest
```

See [`/docs/environment-variables.md`](./docs/environment-variables.md).

## Build

```bash
Expand Down
42 changes: 42 additions & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Someguy Environment Variables

`rainbow` ships with some implicit defaults that can be adjusted via env variables below.

- [Configuration](#configuration)
- [`SOMEGUY_PORT`](#someguy_port)
- [`SOMEGUY_ACCELERATED_DHT`](#someguy_accelerated_dht)
- [`SOMEGUY_PROVIDER_ENDPOINTS`](#someguy_provider_endpoints)
- [`SOMEGUY_PEER_ENDPOINTS`](#someguy_peer_endpoints)
- [`SOMEGUY_IPNS_ENDPOINTS`](#someguy_ipns_endpoints)

## Configuration

### `SOMEGUY_PORT`

The port to listen on to.

Default: `8080`

### `SOMEGUY_ACCELERATED_DHT`

Whether or not the Accelerated DHT is enabled or not.

Default: `true`

### `SOMEGUY_PROVIDER_ENDPOINTS`

Comma-separated list of other Delegated Routing V1 endpoints to proxy provider requests to.

Default: `https://cid.contact`

### `SOMEGUY_PEER_ENDPOINTS`

Comma-separated list of other Delegated Routing V1 endpoints to proxy peer requests to.

Default: none

### `SOMEGUY_IPNS_ENDPOINTS`

Comma-separated list of other Delegated Routing V1 endpoints to proxy IPNS requests to.

Default: none
39 changes: 22 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,34 @@ func main() {
Name: "start",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "port",
Usage: "port to serve requests on",
Value: 8080,
Name: "port",
Value: 8080,
EnvVars: []string{"SOMEGUY_PORT"},
Usage: "port to serve requests on",

Check warning on line 29 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L26-L29

Added lines #L26 - L29 were not covered by tests
},
&cli.BoolFlag{
Name: "accelerated-dht",
Usage: "run the accelerated DHT client",
Value: true,
Name: "accelerated-dht",
Value: true,
EnvVars: []string{"SOMEGUY_ACCELERATED_DHT"},
Usage: "run the accelerated DHT client",

Check warning on line 35 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L32-L35

Added lines #L32 - L35 were not covered by tests
},
&cli.StringSliceFlag{
Name: "provider-endpoints",
Usage: "other Delegated Routing V1 endpoints to proxy provider requests to",
Value: cli.NewStringSlice(cidContactEndpoint),
Name: "provider-endpoints",
Value: cli.NewStringSlice(cidContactEndpoint),
EnvVars: []string{"SOMEGUY_PROVIDER_ENDPOINTS"},
Usage: "other Delegated Routing V1 endpoints to proxy provider requests to",

Check warning on line 41 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L38-L41

Added lines #L38 - L41 were not covered by tests
},
&cli.StringSliceFlag{
Name: "peer-endpoints",
Usage: "other Delegated Routing V1 endpoints to proxy peer requests to",
Value: cli.NewStringSlice(),
Name: "peer-endpoints",
Value: cli.NewStringSlice(),
EnvVars: []string{"SOMEGUY_PEER_ENDPOINTS"},
Usage: "other Delegated Routing V1 endpoints to proxy peer requests to",

Check warning on line 47 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L44-L47

Added lines #L44 - L47 were not covered by tests
},
&cli.StringSliceFlag{
Name: "ipns-endpoints",
Usage: "other Delegated Routing V1 endpoints to proxy IPNS requests to",
Value: cli.NewStringSlice(),
Name: "ipns-endpoints",
Value: cli.NewStringSlice(),
EnvVars: []string{"SOMEGUY_IPNS_ENDPOINTS"},
Usage: "other Delegated Routing V1 endpoints to proxy IPNS requests to",

Check warning on line 53 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L50-L53

Added lines #L50 - L53 were not covered by tests
},
},
Action: func(ctx *cli.Context) error {
Expand All @@ -57,13 +62,13 @@ func main() {
Flags: []cli.Flag{
&cli.StringFlag{
Name: "endpoint",
Usage: "the Delegated Routing V1 endpoint to ask",
Value: cidContactEndpoint,
Usage: "the Delegated Routing V1 endpoint to ask",
},
&cli.BoolFlag{
Name: "pretty",
Usage: "output data in a prettier format that may convey less information",
Value: false,
Usage: "output data in a prettier format that may convey less information",
},
},
Subcommands: []*cli.Command{
Expand Down

0 comments on commit ae409e1

Please sign in to comment.