aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0176_jingle_ice_udp
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2021-03-24 14:12:42 +0100
committerfiaxh <git@lightrise.org>2021-03-25 14:45:54 +0100
commitec35f95e13f4f2f756c81a35ded0980245acc5f4 (patch)
treee5920e372955091cfb511b42e034d505030594bd /xmpp-vala/src/module/xep/0176_jingle_ice_udp
parent4b230808b9566322fae8d1ef0d1a5cb3e8027d3b (diff)
downloaddino-ec35f95e13f4f2f756c81a35ded0980245acc5f4.tar.gz
dino-ec35f95e13f4f2f756c81a35ded0980245acc5f4.zip
Add initial support for DTLS-SRTP
Diffstat (limited to 'xmpp-vala/src/module/xep/0176_jingle_ice_udp')
-rw-r--r--xmpp-vala/src/module/xep/0176_jingle_ice_udp/jingle_ice_udp_module.vala1
-rw-r--r--xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala27
2 files changed, 28 insertions, 0 deletions
diff --git a/xmpp-vala/src/module/xep/0176_jingle_ice_udp/jingle_ice_udp_module.vala b/xmpp-vala/src/module/xep/0176_jingle_ice_udp/jingle_ice_udp_module.vala
index 9ed494ff..4b7c7a36 100644
--- a/xmpp-vala/src/module/xep/0176_jingle_ice_udp/jingle_ice_udp_module.vala
+++ b/xmpp-vala/src/module/xep/0176_jingle_ice_udp/jingle_ice_udp_module.vala
@@ -12,6 +12,7 @@ public abstract class Module : XmppStreamModule, Jingle.Transport {
public override void attach(XmppStream stream) {
stream.get_module(Jingle.Module.IDENTITY).register_transport(this);
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
+ stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, "urn:xmpp:jingle:apps:dtls:0");
}
public override void detach(XmppStream stream) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).remove_feature(stream, NS_URI);
diff --git a/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala b/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala
index 8b8aa07d..3c69d0af 100644
--- a/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala
+++ b/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala
@@ -13,6 +13,9 @@ public abstract class Xmpp.Xep.JingleIceUdp.IceUdpTransportParameters : Jingle.T
public ConcurrentList<Candidate> unsent_local_candidates = new ConcurrentList<Candidate>(Candidate.equals_func);
public Gee.List<Candidate> remote_candidates = new ArrayList<Candidate>(Candidate.equals_func);
+ public string? own_fingerprint = null;
+ public string? peer_fingerprint = null;
+
public Jid local_full_jid { get; private set; }
public Jid peer_full_jid { get; private set; }
private uint8 components_;
@@ -34,6 +37,11 @@ public abstract class Xmpp.Xep.JingleIceUdp.IceUdpTransportParameters : Jingle.T
foreach (StanzaNode candidateNode in node.get_subnodes("candidate")) {
remote_candidates.add(Candidate.parse(candidateNode));
}
+
+ StanzaNode? fingerprint_node = node.get_subnode("fingerprint", "urn:xmpp:jingle:apps:dtls:0");
+ if (fingerprint_node != null) {
+ peer_fingerprint = fingerprint_node.get_deep_string_content();
+ }
}
}
@@ -57,6 +65,20 @@ public abstract class Xmpp.Xep.JingleIceUdp.IceUdpTransportParameters : Jingle.T
.add_self_xmlns()
.put_attribute("ufrag", local_ufrag)
.put_attribute("pwd", local_pwd);
+
+ if (own_fingerprint != null) {
+ var fingerprint_node = new StanzaNode.build("fingerprint", "urn:xmpp:jingle:apps:dtls:0")
+ .add_self_xmlns()
+ .put_attribute("hash", "sha-256")
+ .put_node(new StanzaNode.text(own_fingerprint));
+ if (incoming) {
+ fingerprint_node.put_attribute("setup", "active");
+ } else {
+ fingerprint_node.put_attribute("setup", "actpass");
+ }
+ node.put_node(fingerprint_node);
+ }
+
foreach (Candidate candidate in unsent_local_candidates) {
node.put_node(candidate.to_xml());
}
@@ -72,6 +94,11 @@ public abstract class Xmpp.Xep.JingleIceUdp.IceUdpTransportParameters : Jingle.T
foreach (StanzaNode candidateNode in node.get_subnodes("candidate")) {
remote_candidates.add(Candidate.parse(candidateNode));
}
+
+ StanzaNode? fingerprint_node = node.get_subnode("fingerprint", "urn:xmpp:jingle:apps:dtls:0");
+ if (fingerprint_node != null) {
+ peer_fingerprint = fingerprint_node.get_deep_string_content();
+ }
}
public virtual void handle_transport_info(StanzaNode node) throws Jingle.IqError {