From d194eae61d4fda8504a037daa721d9810ed1fe3e Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 29 Nov 2019 16:03:18 +0100 Subject: Set ALPN info on XMPP connections if GIO >= 2.60 --- cmake/UseVala.cmake | 7 ++++--- xmpp-vala/CMakeLists.txt | 12 ++++++++++++ xmpp-vala/src/module/xep/0368_srv_records_tls.vala | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cmake/UseVala.cmake b/cmake/UseVala.cmake index 436a03ce..822ac005 100644 --- a/cmake/UseVala.cmake +++ b/cmake/UseVala.cmake @@ -146,9 +146,9 @@ function(vala_precompile output) endforeach(pkg ${ARGS_PACKAGES}) set(vala_define_opts "") - foreach(def ${ARGS_DEFINTIONS}) + foreach(def ${ARGS_DEFINITIONS}) list(APPEND vala_define_opts "--define=${def}") - endforeach(def ${ARGS_DEFINTIONS}) + endforeach(def ${ARGS_DEFINITIONS}) set(custom_vapi_arguments "") if(ARGS_CUSTOM_VAPIS) @@ -212,6 +212,7 @@ function(vala_precompile output) ${VALA_EXECUTABLE} ARGS --fast-vapi ${fast_vapi_file} + ${vala_define_opts} ${ARGS_OPTIONS} ${VALAC_FLAGS} ${in_file} @@ -326,4 +327,4 @@ function(vala_precompile output) ) endif(ARGS_FAST_VAPI) set(${output} ${out_files} PARENT_SCOPE) -endfunction(vala_precompile) \ No newline at end of file +endfunction(vala_precompile) diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt index 5836f96f..57347282 100644 --- a/xmpp-vala/CMakeLists.txt +++ b/xmpp-vala/CMakeLists.txt @@ -6,6 +6,16 @@ find_packages(ENGINE_PACKAGES REQUIRED GObject ) +set(ENGINE_DEFINITIONS "") + +find_package(GIO) +if(GIO_VERSION VERSION_GREATER "2.60") + message(STATUS "ALPN support enabled") + set(ENGINE_DEFINITIONS ALPN_SUPPORT) +else() + message(STATUS "No ALPN support, needs GIO >= 2.60") +endif() + vala_precompile(ENGINE_VALA_C SOURCES "src/glib_fixes.vapi" @@ -91,6 +101,8 @@ GENERATE_VAPI xmpp-vala GENERATE_HEADER xmpp-vala +DEFINITIONS + ${ENGINE_DEFINITIONS} ) add_custom_target(xmpp-vala-vapi diff --git a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala index 3d0708fb..5a2a4559 100644 --- a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala +++ b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala @@ -39,6 +39,9 @@ public class TlsConnectionProvider : ConnectionProvider { debug("Connecting to %s %i (tls)", srv_target.get_hostname(), srv_target.get_port()); IOStream? io_stream = yield client.connect_to_host_async(srv_target.get_hostname(), srv_target.get_port()); TlsConnection tls_connection = TlsClientConnection.new(io_stream, new NetworkAddress(stream.remote_name.to_string(), srv_target.get_port())); +#if ALPN_SUPPORT + tls_connection.set_advertised_protocols(new string[]{"xmpp-client"}); +#endif tls_connection.accept_certificate.connect(stream.get_module(Tls.Module.IDENTITY).on_invalid_certificate); stream.add_flag(new Tls.Flag() { finished=true }); return tls_connection; -- cgit v1.2.3-70-g09d2