aboutsummaryrefslogtreecommitdiff
path: root/plugins/ice/src/module.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2021-03-21 12:41:27 +0100
committerMarvin W <git@larma.de>2021-03-21 12:41:27 +0100
commitd703b7c09d5eea81ec383fd09c9d320199e6d577 (patch)
tree23a89c8324d145c750b5be354188352fb693bc4b /plugins/ice/src/module.vala
parentf328bf93fbdd8e99a2fa27757a07223473fff4a5 (diff)
downloaddino-d703b7c09d5eea81ec383fd09c9d320199e6d577.tar.gz
dino-d703b7c09d5eea81ec383fd09c9d320199e6d577.zip
Add libnice-based ICE-UDP implementation as plugin
Diffstat (limited to 'plugins/ice/src/module.vala')
-rw-r--r--plugins/ice/src/module.vala42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/ice/src/module.vala b/plugins/ice/src/module.vala
new file mode 100644
index 00000000..e961ffb6
--- /dev/null
+++ b/plugins/ice/src/module.vala
@@ -0,0 +1,42 @@
+using Gee;
+using Xmpp;
+using Xmpp.Xep;
+
+public class Dino.Plugins.Ice.Module : JingleIceUdp.Module {
+
+ public string? stun_ip = null;
+ public uint stun_port = 0;
+ public string? turn_ip = null;
+ public Xep.ExternalServiceDiscovery.Service? turn_service = null;
+
+ private weak Nice.Agent? agent;
+
+ private Nice.Agent get_agent() {
+ Nice.Agent? agent = this.agent;
+ if (agent == null) {
+ agent = new Nice.Agent(MainContext.@default(), Nice.Compatibility.RFC5245);
+ if (stun_ip != null) {
+ agent.stun_server = stun_ip;
+ agent.stun_server_port = stun_port;
+ }
+ agent.ice_tcp = false;
+ agent.set_software("Dino");
+ agent.weak_ref(agent_unweak);
+ this.agent = agent;
+ debug("STUN server for libnice %s %u", agent.stun_server, agent.stun_server_port);
+ }
+ return agent;
+ }
+
+ 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);
+ }
+
+ 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);
+ }
+
+ private void agent_unweak() {
+ this.agent = null;
+ }
+} \ No newline at end of file