From 33e7aeaacc35cf3889ccbaa3549708f83b5260e1 Mon Sep 17 00:00:00 2001 From: DavidVentura Date: Wed, 31 Jan 2024 16:13:20 +0100 Subject: [PATCH] cleanup punchpkt --- handlers.ts | 12 +----------- session.ts | 12 ++---------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/handlers.ts b/handlers.ts index 6620476..cb5b1d8 100644 --- a/handlers.ts +++ b/handlers.ts @@ -1,9 +1,7 @@ -import { RemoteInfo } from "node:dgram"; - import { Commands, CommandsByValue, ControlCommands } from "./datatypes.js"; import { XqBytesDec } from "./func_replacements.js"; import { hexdump } from "./hexdump.js"; -import { parse_PunchPkt, create_P2pRdy, SendListWifi, SendUsrChk, DevSerial } from "./impl.js"; +import { create_P2pRdy, SendListWifi, SendUsrChk, DevSerial } from "./impl.js"; import { Session } from "./session.js"; import { u16_swap, u32_swap } from "./utils.js"; @@ -36,19 +34,11 @@ export const handle_P2PRdy = (session: Session, _: DataView) => { export const makePunchPkt = (dev: DevSerial): DataView => { const len = dev.prefix.length + dev.suffix.length + 8; const outbuf = new DataView(new Uint8Array(0x14).buffer); // 8 = serial u64 - console.log(len, dev.prefix.length, dev.serialU64, dev.suffix.length); - console.log(dev.prefix, dev.serialU64, dev.suffix); outbuf.add(0).writeString(dev.prefix); outbuf.add(4).writeU64(dev.serialU64); outbuf.add(8 + dev.prefix.length).writeString(dev.suffix); return create_P2pRdy(outbuf); }; -export const handle_PunchPkt = (session: Session, dv: DataView, rinfo: RemoteInfo) => { - const dev = parse_PunchPkt(dv); - session.eventEmitter.emit("connect", dev.devId, rinfo); - console.log("connect????"); - session.send(makePunchPkt(dev)); -}; export const createResponseForControlCommand = (session: Session, dv: DataView): DataView[] => { const start_type = dv.add(8).readU16(); // 0xa11 on control; data starts here on DATA pkt diff --git a/session.ts b/session.ts index 18f04e0..533bf24 100644 --- a/session.ts +++ b/session.ts @@ -1,15 +1,7 @@ import { createSocket, RemoteInfo } from "node:dgram"; import { create_P2pAlive, DevSerial } from "./impl.js"; import { Commands, CommandsByValue } from "./datatypes.js"; -import { - handle_P2PAlive, - handle_PunchPkt, - handle_P2PRdy, - handle_Drw, - notImpl, - noop, - makePunchPkt, -} from "./handlers.js"; +import { handle_P2PAlive, handle_P2PRdy, handle_Drw, notImpl, noop, makePunchPkt } from "./handlers.js"; import { hexdump } from "./hexdump.js"; import EventEmitter from "node:events"; import { SendVideoResolution, SendStartVideo, SendWifiDetails } from "./impl.js"; @@ -127,7 +119,7 @@ const startVideoStream = (s: Session) => { }; export const Handlers: Record = { - PunchPkt: handle_PunchPkt, + PunchPkt: notImpl, P2PAlive: handle_P2PAlive, P2pRdy: handle_P2PRdy, DrwAck: noop,