From 148cf48d2b68354881066e2587e2673c91d2619a Mon Sep 17 00:00:00 2001 From: hrxi Date: Sat, 28 Dec 2019 03:11:51 +0100 Subject: Add libnice and listen for direct connections in Jingle SOCKS5 (#608) Add libnice as a plugin. If it is present, use libnice to enumerate local IP addresses and listen on them to support direct connections for Jingle SOCKS5. Tested with Conversations and Gajim. Created the nice.vapi file using ``` vapigen --library nice --pkg gio-2.0 --metadatadir metadata /usr/share/gir-1.0/Nice-0.1.gir ``` --- xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala') diff --git a/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala b/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala index fdee2411..c184877c 100644 --- a/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala +++ b/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala @@ -18,21 +18,34 @@ public class Proxy : Object { } } +public delegate Gee.List GetLocalIpAddresses(); + public class Module : XmppStreamModule, Iq.Handler { public static Xmpp.ModuleIdentity IDENTITY = new Xmpp.ModuleIdentity(NS_URI, "0065_socks5_bytestreams"); + private GetLocalIpAddresses? get_local_ip_addresses_impl = null; + public override void attach(XmppStream stream) { stream.add_flag(new Flag()); query_availability.begin(stream); } public override void detach(XmppStream stream) { } - public async void on_iq_set(XmppStream stream, Iq.Stanza iq) { } - public Gee.List get_proxies(XmppStream stream) { return stream.get_flag(Flag.IDENTITY).proxies; } + public void set_local_ip_address_handler(owned GetLocalIpAddresses get_local_ip_addresses) { + get_local_ip_addresses_impl = (owned)get_local_ip_addresses; + } + + public Gee.List get_local_ip_addresses() { + if (get_local_ip_addresses_impl == null) { + return Gee.List.empty(); + } + return get_local_ip_addresses_impl(); + } + private async void query_availability(XmppStream stream) { ServiceDiscovery.ItemsResult? items_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name); if (items_result == null) return; -- cgit v1.2.3-54-g00ecf