Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mondanzo authored Aug 25, 2024
2 parents 1b86ad8 + 22cc80f commit 0d6f88b
Show file tree
Hide file tree
Showing 113 changed files with 1,949 additions and 4,532 deletions.
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/
78 changes: 34 additions & 44 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,73 +1,63 @@
# 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
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=::1
# 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=::1
# 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=8890

# 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.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ 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
```

_Please Note: This configuration will only allow NAT Punching but no port forwarding. Make sure to add `-p 49152-51200/udp` to allow all default udp relay ports. Beware! This will increase the deploy time severely!_
_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!_

#### EADDRNOTAVAIL

Expand Down
4 changes: 0 additions & 4 deletions bin/natty.mjs

This file was deleted.

4 changes: 4 additions & 0 deletions bin/noray.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Noray } from '../src/noray.mjs'

const noray = new Noray()
noray.start()
116 changes: 0 additions & 116 deletions docs/connection-orchestration.md

This file was deleted.

27 changes: 0 additions & 27 deletions docs/handshake.md

This file was deleted.

Loading

0 comments on commit 0d6f88b

Please sign in to comment.