aboutsummaryrefslogtreecommitdiff
path: root/layer
diff options
context:
space:
mode:
Diffstat (limited to 'layer')
-rw-r--r--layer/broadlayer.ts18
1 files changed, 18 insertions, 0 deletions
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<string, number>()
const sessions: Record<string, connection> = {}
async function establishTCP(ip: string, port: number, clientIp: string): Promise<string | false> {
+ 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<string | false> {
+ 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