aboutsummaryrefslogtreecommitdiff
path: root/plugins/ice/src/module.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-04-30 21:37:02 +0200
committerfiaxh <git@lightrise.org>2021-05-01 22:57:38 +0200
commit0ad968df367f5a44c568329834115018866ff8b9 (patch)
tree72b1594207656ad6e87bb03aa3658a3e9309c5d0 /plugins/ice/src/module.vala
parent7d2e64769067c1b47e0500f6456dd7e6f4eb435a (diff)
downloaddino-0ad968df367f5a44c568329834115018866ff8b9.tar.gz
dino-0ad968df367f5a44c568329834115018866ff8b9.zip
Use the same DTLS fingerprint in all contents. Display audio+video enc keys in UI if they differ.
Diffstat (limited to 'plugins/ice/src/module.vala')
-rw-r--r--plugins/ice/src/module.vala17
1 files changed, 15 insertions, 2 deletions
diff --git a/plugins/ice/src/module.vala b/plugins/ice/src/module.vala
index e961ffb6..2645d7dc 100644
--- a/plugins/ice/src/module.vala
+++ b/plugins/ice/src/module.vala
@@ -10,6 +10,7 @@ public class Dino.Plugins.Ice.Module : JingleIceUdp.Module {
public Xep.ExternalServiceDiscovery.Service? turn_service = null;
private weak Nice.Agent? agent;
+ private HashMap<string, DtlsSrtp.CredentialsCapsule> cerds = new HashMap<string, DtlsSrtp.CredentialsCapsule>();
private Nice.Agent get_agent() {
Nice.Agent? agent = this.agent;
@@ -29,11 +30,23 @@ public class Dino.Plugins.Ice.Module : JingleIceUdp.Module {
}
public override Jingle.TransportParameters create_transport_parameters(XmppStream stream, uint8 components, Jid local_full_jid, Jid peer_full_jid) {
- return new TransportParameters(get_agent(), turn_service, turn_ip, components, local_full_jid, peer_full_jid);
+ DtlsSrtp.CredentialsCapsule? cred = get_create_credentials(local_full_jid, peer_full_jid);
+ return new TransportParameters(get_agent(), cred, turn_service, turn_ip, components, local_full_jid, peer_full_jid);
}
public override Jingle.TransportParameters parse_transport_parameters(XmppStream stream, uint8 components, Jid local_full_jid, Jid peer_full_jid, StanzaNode transport) throws Jingle.IqError {
- return new TransportParameters(get_agent(), turn_service, turn_ip, components, local_full_jid, peer_full_jid, transport);
+ DtlsSrtp.CredentialsCapsule? cred = get_create_credentials(local_full_jid, peer_full_jid);
+ return new TransportParameters(get_agent(), cred, turn_service, turn_ip, components, local_full_jid, peer_full_jid, transport);
+ }
+
+ private DtlsSrtp.CredentialsCapsule? get_create_credentials(Jid local_full_jid, Jid peer_full_jid) {
+ string from_to_id = local_full_jid.to_string() + peer_full_jid.to_string();
+ try {
+ if (!cerds.has_key(from_to_id)) cerds[from_to_id] = DtlsSrtp.Handler.generate_credentials();
+ } catch (Error e) {
+ warning("Error creating dtls credentials: %s", e.message);
+ }
+ return cerds[from_to_id];
}
private void agent_unweak() {