SDP-Minify: TCP/IPv6/Non-Host-Candidates vor pack() entfernt
All checks were successful
Pin to IPFS / pin (push) Successful in 10s
All checks were successful
Pin to IPFS / pin (push) Successful in 10s
This commit is contained in:
parent
14aa83ff6e
commit
09c36ac6c1
2 changed files with 15 additions and 2 deletions
11
crypto.js
11
crypto.js
|
|
@ -71,6 +71,17 @@ function hexToBuf(hex) {
|
||||||
|
|
||||||
/* ─── QR compression: deflate-raw + base45 ─── */
|
/* ─── 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) {
|
async function pack(obj) {
|
||||||
const json = JSON.stringify(obj);
|
const json = JSON.stringify(obj);
|
||||||
const blob = new Blob([json]);
|
const blob = new Blob([json]);
|
||||||
|
|
|
||||||
6
p2p.js
6
p2p.js
|
|
@ -43,7 +43,8 @@ class MeshNet {
|
||||||
if (signalSent) return;
|
if (signalSent) return;
|
||||||
signalSent = true;
|
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._currentQRData = encode45(packed);
|
||||||
this._fullSDPData = this._currentQRData;
|
this._fullSDPData = this._currentQRData;
|
||||||
|
|
||||||
|
|
@ -95,7 +96,8 @@ class MeshNet {
|
||||||
peer.on('signal', async signal => {
|
peer.on('signal', async signal => {
|
||||||
if (answerSent) return;
|
if (answerSent) return;
|
||||||
answerSent = true;
|
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);
|
const answerData = encode45(packed);
|
||||||
if (this.onanswerready) this.onanswerready(answerData);
|
if (this.onanswerready) this.onanswerready(answerData);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue