From 341fce1b653fc00190fce1e90456a6018523813e Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Tue, 24 Feb 2026 14:22:06 +0330 Subject: default ports + hardcode protection --- README.md | 5 +++++ layer/broadlayer.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/README.md b/README.md index 9d3f860..ccb8d36 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,11 @@ broadcast demon ## specs server specification is listed inside of the `broadd.c` file. +the default ports are: +- 5001 for tbroadd +- 5002 for ubroadd +- 10000 for broadlayer + ## browser compatibility layer broadlayer is typescript software that exposes an http/websocket interface for connecting to tcp/udp broadd servers. the specification is listed inside of `layer/broadlayer.ts`. diff --git a/layer/broadlayer.ts b/layer/broadlayer.ts index 8b6ed31..53eab39 100644 --- a/layer/broadlayer.ts +++ b/layer/broadlayer.ts @@ -3,6 +3,9 @@ -- BEOFRE RUNNING: ------ THIS SERVER OPENS ACCESS TO YOUR PRIVATE IP NETWORK AND LOCALHOST PORTS. ------ IF THIS IS NOT INTENDED BEHAVIOR, PATCH IT OUT OF THE PROGRAM. +------ there is a hardcode_target const variable provided below, which you can modify to override any and all +------ incoming ip:port combos to the one that you set below. +------ it is enabled by default, and configured for the respective tcp and udp broadd ports on localhost. -- ------ http: ------ all error replies start with `err_`. @@ -41,6 +44,11 @@ ---------- only difference is a special command "ping", which returns "pong" and nothing is relayed to the target server. */ +const hardcode_target = true +const hardcode_host = '127.0.0.1' +const hardcode_tcp_port = 5001 +const hardcode_udp_port = 5002 + import { dns, randomUUIDv7 } from "bun" if (process.argv.length < 4) { @@ -118,6 +126,11 @@ const connectionsPerIp = new Map() const sessions: Record = {} async function establishTCP(ip: string, port: number, clientIp: string): Promise { + if (hardcode_target) { + ip = hardcode_host + port = hardcode_tcp_port + } + const id = randomUUIDv7() const conn: connection = { @@ -174,6 +187,11 @@ async function establishTCP(ip: string, port: number, clientIp: string): Promise } async function establishUDP(hostname: string, port: number, clientIp: string): Promise { + if (hardcode_target) { + hostname = hardcode_host + port = hardcode_udp_port + } + const id = randomUUIDv7() const ip = (await dns.lookup(hostname, { family: 'IPv4' }))[0]?.address if (!ip) return false -- cgit v1.2.3