SDP-Minify: TCP/IPv6/Non-Host-Candidates vor pack() entfernt
All checks were successful
Pin to IPFS / pin (push) Successful in 10s

This commit is contained in:
Ole 2026-06-14 17:22:31 +02:00
parent 14aa83ff6e
commit 09c36ac6c1
2 changed files with 15 additions and 2 deletions

View file

@ -71,6 +71,17 @@ function hexToBuf(hex) {
/* ─── QR compression: deflate-raw + base45 ─── */
function stripSDP(sdp) {
return sdp.split('\r\n').map(line => {
if (!line.startsWith('a=candidate:')) return line;
const parts = line.split(' ');
if (parts[2] === 'tcp') return null;
if (parts[7] !== 'host') return null;
if (parts[4] && parts[4].includes(':')) return null;
return line;
}).filter(Boolean).join('\r\n');
}
async function pack(obj) {
const json = JSON.stringify(obj);
const blob = new Blob([json]);

6
p2p.js
View file

@ -43,7 +43,8 @@ class MeshNet {
if (signalSent) return;
signalSent = true;
const packed = await pack({ v: 1, id: this.myPeerId, s: signal });
const minSignal = signal.sdp ? { ...signal, sdp: stripSDP(signal.sdp) } : signal;
const packed = await pack({ v: 1, id: this.myPeerId, s: minSignal });
this._currentQRData = encode45(packed);
this._fullSDPData = this._currentQRData;
@ -95,7 +96,8 @@ class MeshNet {
peer.on('signal', async signal => {
if (answerSent) return;
answerSent = true;
const packed = await pack({ v: 1, id: this.myPeerId, s: signal, to: remoteId });
const minSignal = signal.sdp ? { ...signal, sdp: stripSDP(signal.sdp) } : signal;
const packed = await pack({ v: 1, id: this.myPeerId, s: minSignal, to: remoteId });
const answerData = encode45(packed);
if (this.onanswerready) this.onanswerready(answerData);
});