summaryrefslogtreecommitdiff
path: root/src/mod_proxy65_service.erl
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/mod_proxy65_service.erl22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/mod_proxy65_service.erl b/src/mod_proxy65_service.erl
index 1e7735c5..32cd4443 100644
--- a/src/mod_proxy65_service.erl
+++ b/src/mod_proxy65_service.erl
@@ -33,9 +33,9 @@
-export([init/1, handle_info/2, handle_call/3,
handle_cast/2, terminate/2, code_change/3]).
-%% API.
--export([start_link/2, add_listener/2, transform_module_options/1,
- delete_listener/1]).
+-export([start_link/2, add_listener/2,
+ transform_module_options/1, delete_listener/1,
+ mod_opt_type/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@@ -292,3 +292,19 @@ get_my_ip() ->
{ok, Addr} -> Addr;
{error, _} -> {127, 0, 0, 1}
end.
+
+mod_opt_type(access) ->
+ fun (A) when is_atom(A) -> A end;
+mod_opt_type(host) -> fun iolist_to_binary/1;
+mod_opt_type(hostname) -> fun iolist_to_binary/1;
+mod_opt_type(ip) ->
+ fun (S) ->
+ {ok, Addr} =
+ inet_parse:address(binary_to_list(iolist_to_binary(S))),
+ Addr
+ end;
+mod_opt_type(name) -> fun iolist_to_binary/1;
+mod_opt_type(port) ->
+ fun (P) when is_integer(P), P > 0, P < 65536 -> P end;
+mod_opt_type(_) ->
+ [access, host, hostname, ip, name, port].