Projects
Kolab:16
guam
0001-introduce-net_iface-for-listeners.patch
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-introduce-net_iface-for-listeners.patch of Package guam (Revision 9)
Currently displaying revision
9
,
Show latest
From f527fde7a659f67314adb161025965b242655b83 Mon Sep 17 00:00:00 2001 From: Aaron Seigo <aseigo@kde.org> Date: Tue, 5 Jan 2016 10:49:13 +0100 Subject: [PATCH 1/8] introduce net_iface for listeners --- apps/kolab_guam/src/kolab_guam_listener.erl | 17 +++++++++++++---- docs/deployment.md | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/apps/kolab_guam/src/kolab_guam_listener.erl b/apps/kolab_guam/src/kolab_guam_listener.erl index 7b7a283..c50b4b1 100644 --- a/apps/kolab_guam/src/kolab_guam_listener.erl +++ b/apps/kolab_guam/src/kolab_guam_listener.erl @@ -35,11 +35,12 @@ start_link(Name, Config) -> supervisor:start_link(?MODULE, [Name, Config]). %% gen_server API init([Name, Config]) -> Host = proplists:get_value(host, Config, none), + NetIface = proplists:get_value(net_iface, Config, none), Port = proplists:get_value(port, Config, ?DEFAULT_IMAP_PORT), ImplicitTLS = proplists:get_value(implicit_tls, Config, false), TLSConfig = proplists:get_value(tls_config, Config, []), Rules = proplists:get_value(rules, Config, []), - Options = listen_options(Host, ImplicitTLS, TLSConfig), + Options = listen_options(NetIface, Host, ImplicitTLS, TLSConfig), lager:info("Starting listener \"~p\" on port ~B (~p) with ~B rules", [Name, Port, Options, length(Rules)]), { ok, ListenSocket } = listen(ImplicitTLS, Port, Options), spawn_link(?MODULE, cleanup, [ListenSocket]), @@ -55,13 +56,21 @@ init([Name, Config]) -> imap_config(none) -> kolab_guam_sup:default_imap_server_config(); imap_config(Backend) -> kolab_guam_sup:imap_server_config(Backend). -listen_options(none, ImplicitTLS, TLSConfig) -> default_listen_options(ImplicitTLS, TLSConfig); -listen_options(Hostname, ImplicitTLS, TLSConfig) -> +listen_options(none, none, ImplicitTLS, TLSConfig) -> default_listen_options(ImplicitTLS, TLSConfig); +listen_options(none, Hostname, ImplicitTLS, TLSConfig) -> case inet:gethostbyname(Hostname) of { ok, { hostent, _HostName, _Unused, inet, _Ver, [IP] } } -> [ { ip, IP } | default_listen_options(ImplicitTLS, TLSConfig) ]; _ -> - listen_options(none, ImplicitTLS, TLSConfig) + listen_options(none, none, ImplicitTLS, TLSConfig) + end; +listen_options(Iface, Hostname, ImplicitTLS, TLSConfig) -> + { ok, Ifaces } = inet:getifaddrs(), + case proplists:get_value(Iface, Ifaces) of + undefined -> listen_options(none, Hostname, ImplicitTLS, TLSConfig); + Info -> Addr = proplists:get_value(addr, Info, none), + lager:info("YEAH! ~p", [Addr]), + listen_options(none, Addr, ImplicitTLS, TLSConfig) end. default_listen_options(true, TLSConfig) -> [ { reuseaddr, true }, {active, once } | TLSConfig ]; diff --git a/docs/deployment.md b/docs/deployment.md index 33cd450..484d0ed 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -84,14 +84,26 @@ contains the configuration specifics. Example: { rules, [ { filter_groupware, [] } ] }, { tls_config, [ { certfile, "/etc/ssl/sample.pem" } ] } ] + }, + { default, [ + { net_iface, "eth0" }, + { port, 1993 }, + { imap_server, default }, + { implicit_tls, true }, + { rules, [ { filter_groupware, [] } ] }, + { tls_config, [ { certfile, "/etc/ssl/sample.pem" } ] } + ] } } The host entry is optional, and is used to bind the connection to a specific -network interface. Leaving it empty will cause Guam to bind to the port accross +network interface by ip address. Alternatively, the net_iface may be defined and +guam will attempt to bind to an address on that network device. net_iface overrides +host, though host will be used as a fallback if net_iface does not produce a network +interface. Leaving host and net_iface empty will cause Guam to bind to the port accross all network interfaces available to it. -port defines the port it is listening on. +port defines the port the listener is active on. imap_server refers to the entry in the imap_servers block. If not provided, the default entry in the imap_servers configuration is used. -- 2.5.5
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.