Skip to content

Commit 82c1611

Browse files
committed
_
1 parent 35d5296 commit 82c1611

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<script type="module">
33
import { cert, Cert } from '/src/cert.js';
4-
import { Conn } from '/src/conn.js';
4+
import { Addr } from '/src/addr.js';
55

66
// Log everything.
77
function log_everything(conn, label = conn.pid) {
@@ -18,12 +18,10 @@
1818
const certa = await Cert.load('peera');
1919
const certb = await Cert.load('peerb');
2020

21-
const a = new Conn(BigInt(certb), {cert: certa});
22-
const b = new Conn(BigInt(certa), {cert: certb});
21+
const a = new Addr(`turn+tcp:${certb}@localhost?setup`).connect({cert: certa});
22+
const b = new Addr(`turn+tcp:${certa}@localhost?setup`).connect({cert: certb});
2323
log_everything(a, 'a');
2424
log_everything(b, 'b');
25-
26-
a.dc.addEventListener('open', () => a.restartIce()); // Trigger an ICE restart once the connection is open.
2725
</script>
2826
<script type="_module">
2927
import { state } from '/src/util.js';

src/addr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Addr extends URL {
6060
return {
6161
/**
6262
* HACK: If iceTransportPolicy=='relay' then Firefox will kill local relay candidates if they become prflx candidates.
63-
* Chrome doesn't do this.
63+
* Chrome will mark the local candidate as prflx but that doesn't stop it from utilizing it.
6464
* - https://www.rfc-editor.org/rfc/rfc9429#section-4.1.1
6565
* - https://www.rfc-editor.org/rfc/rfc9429#sec.ice-candidate-policy
6666
*
@@ -106,7 +106,7 @@ export class Addr extends URL {
106106
} else if (/^(turns?)(?:\+(tcp|udp))?:/i.test(this.protocol)) {
107107
yield {
108108
address: '::ffff:ffff:ffff',
109-
port: 3478,
109+
port: 65535,
110110
usernameFragment,
111111
};
112112
}

src/conn.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export class Conn extends RTCPeerConnection {
4848
ice_pwd,
4949
mung = true,
5050
timeout = 10_000,
51-
starter = ['::ffff:255.255.255.255', 65535],
5251
...config
5352
} = {}) {
5453
const cert = config?.cert ?? default_cert;
@@ -84,7 +83,6 @@ export class Conn extends RTCPeerConnection {
8483
console.error(e);
8584
this.close();
8685
});
87-
if (starter) this.addIceCandidate(starter);
8886
}
8987

9088
async addIceCandidate(candidate) {
@@ -163,7 +161,7 @@ export class Conn extends RTCPeerConnection {
163161
'a=group:BUNDLE dc',
164162
`a=fingerprint:${to_fingerprint(this.pid)}`,
165163
`a=ice-ufrag:${to_string(this.pid)}`,
166-
// TODO: ice-pwd needs to be different per connection I want to prefix it with to_string(this.#cert) but that means need_cert would need to be called before setRemoteDescription and thus mung must always be true and manual certs must always be provided...
164+
// TODO: ice-pwd would need to be unique if you do broadcasting. One option: ice_pwd + to_string(this.cert) for theirs and ice_pwd + to_string(this.pid) for ours.
167165
`a=ice-pwd:${ice_pwd || default_ice_pwd}`,
168166
'a=ice-options:trickle',
169167
...(ice_lite != undefined ? ['a=ice-lite'] : []),

0 commit comments

Comments
 (0)