forked from foxssake/natty
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
113 changed files
with
1,949 additions
and
4,532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ name: CI | |
|
||
env: | ||
node-version: 18.x | ||
NODE_OPTIONS: --max_old_space_size=8192 | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.