Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c6cb556
chore: Strip unused code (#3)
elementbound May 29, 2023
48d7e62
chore: Rebrand (#4)
elementbound May 29, 2023
d901e6e
chore: Fix branding
elementbound Jun 3, 2023
1549b1f
chore: Remove CI
elementbound Jun 3, 2023
41aaf31
chore: Add CI
elementbound Jun 3, 2023
525952b
feat: Implement protocol
elementbound Jun 3, 2023
48da100
feat: Implement hosts
elementbound Jun 3, 2023
81f60ad
feat: UDP port registrar (#14)
elementbound Jun 4, 2023
ea85333
feat: Connection request handler (#15)
elementbound Jun 4, 2023
aa2664c
feat: Dynamic relays (#17)
elementbound Jun 4, 2023
1954a0f
feat: Implement relay connection request handler (#19)
elementbound Jun 4, 2023
6f1a25c
fix: Use external address for handshakes
elementbound Jun 15, 2023
22fc702
feat: Two-way relay connection orchestration (#24)
elementbound Jun 22, 2023
2b9028f
chore: Add start:prod script (#25)
elementbound Jun 22, 2023
e65104e
feat: Port ranges (#29)
elementbound Jul 2, 2023
d428424
feat: On-demand relay allocation (#30)
elementbound Jul 6, 2023
73ff4be
chore: Remove dynamic relaying (#31)
elementbound Jul 7, 2023
1f1467d
doc: Update README (#32)
elementbound Jul 8, 2023
ad9ebfc
chore: Update package.json (#33)
elementbound Jul 8, 2023
6f52f54
chore: Bump to 1.0.0 🎉
elementbound Jul 8, 2023
dcf8fb2
feat: Integrate Prometheus for metrics (#35)
elementbound Jul 8, 2023
44ccedd
feat: Report protocol metrics (#38)
elementbound Jul 8, 2023
b4e93e0
feat: Report relay metrics (#39)
elementbound Jul 8, 2023
4047174
fix: UDP relaying (#41)
elementbound Jul 9, 2023
bb80e47
fix: Duplicate relay creation (#43)
elementbound Aug 12, 2023
822deca
chore: Dockerize application (#47)
Ughuuu Nov 28, 2023
97188b9
doc: Update example config to use IPv4 (#49)
elementbound Nov 28, 2023
e01f8e7
Generate id's with custom length and letters (#48)
Ughuuu Nov 28, 2023
ed756d1
fix: Docker expose protocol (#52)
elementbound Nov 29, 2023
0db49ad
fix: Dockerfile port protocol (#53)
elementbound Dec 17, 2023
5924a20
fix: Clarify default ports and docs (#55)
Mondanzo Sep 10, 2024
56b2819
fix: Application restart on ECONNRESET (#58)
elementbound May 30, 2025
94d0382
fix: Use UDP port range for dynamic relays (#61)
elementbound Jun 23, 2025
edd1ad3
setup deps
elementbound Jul 29, 2025
115fb3e
update commands
elementbound Jul 29, 2025
147b660
fxs
elementbound Jul 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.github
test/
.editorconfig
.env.example
.eslintrc.js
.jsdoc.js
node_modules/
82 changes: 38 additions & 44 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,73 +1,67 @@
# Id generation ===========================================================
# If you change this, check the collision probability https://zelark.github.io/nano-id-cc/
# 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
NATTY_SOCKET_HOST=::1
NORAY_SOCKET_HOST=0.0.0.0
# TCP port to listen on
NATTY_SOCKET_PORT=8808

# Session =====================================================================
# Session timeout
#
# After this amount of no communication, sessions are terminated
NATTY_SESSION_TIMEOUT=1hr

# Session cleanup interval
#
# Specifies the interval between checks for expired sessions ( see above )
NATTY_SESSION_CLEANUP_INTERVAL=10m

# Lobby =======================================================================
# Minimum length for a lobby name
NATTY_LOBBY_MIN_NAME_LENGTH=3
# Maximum length for a lobby name
NATTY_LOBBY_MAX_NAME_LENGTH=128
NORAY_SOCKET_PORT=8890

# Timeout for connection diagnostics, i.e. how much to wait for peers to report
# connectivity to eachoter
NATTY_CONNECTION_DIAGNOSTICS_TIMEOUT=8s
# HTTP ========================================================================
# HTTP hostname to listen on
NORAY_HTTP_HOST=0.0.0.0
# HTTP port to listen on
NORAY_HTTP_PORT=8891

# UDP Relays ==================================================================
# Maximum number of active relay slots
NATTY_UDP_RELAY_MAX_SLOTS=16384
# Ports reserved for relays - this also determines the number of relay slots
# Valid forms include:
# Literal ports: 2048, 2049, 2050, 2051
# Port ranges: 2048-2051
# Offset ranges: 2048+3
# The above forms can be freely combined, separated by commas
NORAY_UDP_RELAY_PORTS=49152-51200

# Seconds of inactivity before a relay is freed
NATTY_UDP_RELAY_TIMEOUT=30s
NORAY_UDP_RELAY_TIMEOUT=30s

# Interval at which the UDP relay cleanup is run in seconds
NATTY_UDP_RELAY_CLEANUP_INTERVAL=30s
NORAY_UDP_RELAY_CLEANUP_INTERVAL=30s

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

# Maximum traffic per relay, in bytes / sec
NATTY_UDP_RELAY_MAX_INDIVIDUAL_TRAFFIC=128kb
NORAY_UDP_RELAY_MAX_INDIVIDUAL_TRAFFIC=128kb

# Maximum traffic for relaying, globally, in bytes / sec
NATTY_UDP_RELAY_MAX_GLOBAL_TRAFFIC=1Gb
NORAY_UDP_RELAY_MAX_GLOBAL_TRAFFIC=1Gb

# Traffic measurement interval
# This is the timeslice used to limit traffic, i.e. 2 sec means we'll track the
# traffic for 2 seconds, reset our counter and start again.
NATTY_UDP_RELAY_TRAFFIC_INTERVAL=100ms
NORAY_UDP_RELAY_TRAFFIC_INTERVAL=100ms

# Maximum relay lifetime
# Relays will be blocked after being active for this duration
NATTY_UDP_RELAY_MAX_LIFETIME_DURATION=4hr
NORAY_UDP_RELAY_MAX_LIFETIME_DURATION=4hr

# Maximum relay traffic
# Relays will be blocked after throughputting this amount of data
NATTY_UDP_RELAY_MAX_LIFETIME_TRAFFIC=4Gb
NORAY_UDP_RELAY_MAX_LIFETIME_TRAFFIC=4Gb

# Other =======================================================================
# Known games
#
# Each game should reside in its own line, with its id followed by a whitespace
# and its name.
#
# Spaces are trimmed from the ends of the lines
NATTY_GAMES="
q5jMbqNLKQSy0FxhTCHZ9 Game 1
Yf8cBD_EmJa26xRr_2hoX Game 2
"

# Logging level - silent, trace, debug, info, warn, error, fatal
NATTY_LOGLEVEL=info
NORAY_LOGLEVEL=info
2 changes: 1 addition & 1 deletion .github/actions/setup.node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
pnpm-version:
description: 'pnpm version'
required: false
default: '7'
default: '8'
runs:
using: composite
steps:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: CI

env:
node-version: 18.x
NODE_OPTIONS: --max_old_space_size=8192

on:
push:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Docker Publish

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# From https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
jobs:
docker-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- name: Build and push ( if on main ) Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:18-alpine
# From https://github.com/pnpm/pnpm/issues/4837

# UDP host for remote address registration
EXPOSE 8809/udp
# TCP host for commands
EXPOSE 8890/tcp
# HTTP host for Prometheus metrics
EXPOSE 8891/tcp

COPY . noray

WORKDIR noray

RUN npm i -g npm@latest; \
# Install pnpm
npm install -g pnpm; \
pnpm --version; \
pnpm setup; \
mkdir -p /usr/local/share/pnpm &&\
export PNPM_HOME="/usr/local/share/pnpm" &&\
export PATH="$PNPM_HOME:$PATH"; \
pnpm bin -g && \
# Install dependencies
pnpm install

CMD pnpm start:prod
18 changes: 18 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Copyright 2023 Gálffy Tamás

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading
Loading