aboutsummaryrefslogtreecommitdiff
path: root/src/mod_ping.erl
diff options
context:
space:
mode:
authorEvgeny Khramtsov <ekhramtsov@process-one.net>2019-06-14 12:33:26 +0300
committerEvgeny Khramtsov <ekhramtsov@process-one.net>2019-06-14 12:33:26 +0300
commita02cff0e780bb735531594c4ece81e8628f79782 (patch)
tree6fe7d8219d14f58183be1741fcea262c216db447 /src/mod_ping.erl
parentReturn jid_malformed error when sending presence without nick to conference (diff)
Use new configuration validator
Diffstat (limited to 'src/mod_ping.erl')
-rw-r--r--src/mod_ping.erl20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mod_ping.erl b/src/mod_ping.erl
index fd3a08909..aeb3aedbd 100644
--- a/src/mod_ping.erl
+++ b/src/mod_ping.erl
@@ -189,10 +189,10 @@ user_send({Packet, #{jid := JID} = C2SState}) ->
%% Internal functions
%%====================================================================
init_state(Host, Opts) ->
- SendPings = gen_mod:get_opt(send_pings, Opts),
- PingInterval = gen_mod:get_opt(ping_interval, Opts),
- PingAckTimeout = gen_mod:get_opt(ping_ack_timeout, Opts),
- TimeoutAction = gen_mod:get_opt(timeout_action, Opts),
+ SendPings = mod_ping_opt:send_pings(Opts),
+ PingInterval = mod_ping_opt:ping_interval(Opts),
+ PingAckTimeout = mod_ping_opt:ping_ack_timeout(Opts),
+ TimeoutAction = mod_ping_opt:timeout_action(Opts),
#state{host = Host,
send_pings = SendPings,
ping_interval = PingInterval,
@@ -253,17 +253,13 @@ depends(_Host, _Opts) ->
[].
mod_opt_type(ping_interval) ->
- fun (I) when is_integer(I), I > 0 -> I end;
+ econf:pos_int();
mod_opt_type(ping_ack_timeout) ->
- fun(undefined) -> undefined;
- (I) when is_integer(I), I>0 -> timer:seconds(I)
- end;
+ econf:timeout(second);
mod_opt_type(send_pings) ->
- fun (B) when is_boolean(B) -> B end;
+ econf:bool();
mod_opt_type(timeout_action) ->
- fun (none) -> none;
- (kill) -> kill
- end.
+ econf:enum([none, kill]).
mod_options(_Host) ->
[{ping_interval, 60},