Skip to content

Commit

Permalink
clarify + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
elementbound committed Sep 10, 2024
1 parent 82308b4 commit b26da91
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
18 changes: 11 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# Id generation ===========================================================
# If you change this, check the collision probability https://zelark.github.io/nano-id-cc/
NORAY_OID_LENGTH=21 # For 10 id/hour, 15 trillion years
# NORAY_OID_LENGTH=4 # For 10 id/hour, 2 days
# NORAY_OID_LENGTH=5 # For 10 id/hour, 19 days
# NORAY_OID_LENGTH=6 # For 10 id/hour, 155 days
# For 10 id/hour, 15 trillion years
NORAY_OID_LENGTH=21
# For 10 id/hour, 2 days
# NORAY_OID_LENGTH=4
# For 10 id/hour, 19 days
# NORAY_OID_LENGTH=5
# For 10 id/hour, 155 days
# NORAY_OID_LENGTH=6
NORAY_OID_CHARSET=useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict
NORAY_PID_LENGTH=128
NORAY_PID_CHARSET=useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict

# Socket ======================================================================
# TCP hostname to listen on
NORAY_SOCKET_HOST=::1
NORAY_SOCKET_HOST=0.0.0.0
# TCP port to listen on
NORAY_SOCKET_PORT=8890

# HTTP ========================================================================
# HTTP hostname to listen on
NORAY_HTTP_HOST=::1
NORAY_HTTP_HOST=0.0.0.0
# HTTP port to listen on
NORAY_HTTP_PORT=8891

Expand All @@ -36,7 +40,7 @@ NORAY_UDP_RELAY_TIMEOUT=30s
NORAY_UDP_RELAY_CLEANUP_INTERVAL=30s

# Port where noray listens for UDP relay requests from hosts
NORAY_UDP_REGISTRAR_PORT=8890
NORAY_UDP_REGISTRAR_PORT=8809

# Maximum traffic per relay, in bytes / sec
NORAY_UDP_RELAY_MAX_INDIVIDUAL_TRAFFIC=128kb
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,40 @@ listening for incoming connections. Logs are written to `stdout`.

### Usage with Docker

Create `.env` file from `.env.example`.
Create `.env` file based on `.env.example`.

Build and run docker:

```
docker build . -t noray
docker run -p 8890:8890 -p 8890:8890/udp -p 8091:8091 --env-file=.env -t noray
docker run -p 8890:8890 -p 8891:8891 -p 8809:8809/udp -p 49152-51200:49152-51200/udp --env-file=.env -t noray
```

Or run prebuilt docker:
```
docker run -p 8890:8890 -p 8890:8890/udp -p 8091:8891 --env-file=.env -t ghcr.io/foxssake/noray:main
docker run -p 8890:8890 -p 8891:8891 -p 8809:8809/udp -p 49152-51200:49152-51200/udp --env-file=.env -t ghcr.io/foxssake/noray:main
```

_Please Note: This configuration will only allow NAT Punching but no port forwarding. Make sure to add `-p 49152-51200:49152-51200/udp` to allow all default udp relay ports. Beware! This will increase the deploy time severely!_
The above will expose the following ports:

* Port 8890 for clients to register and request connections
* Port 8891 to expose metrics over HTTP
* Port 8809 for the remote port registrar
* Ports 49152 to 51200 for relays
* Make sure these are the same ports as configured in `.env`!

Note that exposing a lot of relay ports can severely impact deploy time.

In case of relays not working - i.e. clients can register and request
connections, but the handshake process fails -, Docker might be mapping ports
as data arrives from outside of the container. In these cases, try running
noray using the [host network]:

```
docker run --network host --env-file=.env -t noray
```

[host network]: https://docs.docker.com/engine/network/tutorials/host/

#### EADDRNOTAVAIL

Expand Down
4 changes: 2 additions & 2 deletions src/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export class NorayConfig {
}

socket = {
host: env.NORAY_SOCKET_HOST ?? '::1',
host: env.NORAY_SOCKET_HOST ?? '0.0.0.0',
port: integer(env.NORAY_SOCKET_PORT) ?? 8890
}

http = {
host: env.NORAY_HTTP_HOST ?? '::1',
host: env.NORAY_HTTP_HOST ?? '0.0.0.0',
port: integer(env.NORAY_HTTP_PORT) ?? 8891
}

Expand Down

0 comments on commit b26da91

Please sign in to comment.