mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Add support in WebAdmin for the new listener network protocol
SVN Revision: 2462
This commit is contained in:
parent
60932b67b1
commit
44ac69f8de
@ -2346,13 +2346,14 @@ node_ports_to_xhtml(Ports, Lang) ->
|
||||
[?XE("tr",
|
||||
[?XCT("td", "Port"),
|
||||
?XCT("td", "IP"),
|
||||
?XCT("td", "Prot"),
|
||||
?XCT("td", "Module"),
|
||||
?XCT("td", "Options")
|
||||
])]),
|
||||
?XE("tbody",
|
||||
lists:map(
|
||||
fun({PortIP, Module, Opts} = _E) ->
|
||||
{_Port, SPort, _TIP, SIP, SSPort, OptsClean} =
|
||||
{_Port, SPort, _TIP, SIP, SSPort, NetProt, OptsClean} =
|
||||
get_port_data(PortIP, Opts),
|
||||
SModule = atom_to_list(Module),
|
||||
{NumLines, SOptsClean} = term_to_paragraph(OptsClean, 40),
|
||||
@ -2360,6 +2361,7 @@ node_ports_to_xhtml(Ports, Lang) ->
|
||||
?XE("tr",
|
||||
[?XAE("td", [{"size", "6"}], [?C(SPort)]),
|
||||
?XAE("td", [{"size", "15"}], [?C(SIP)]),
|
||||
?XAE("td", [{"size", "4"}], [?C(atom_to_list(NetProt))]),
|
||||
?XE("td", [?INPUTS("text", "module" ++ SSPort,
|
||||
SModule, "15")]),
|
||||
?XE("td", [?TEXTAREA("opts" ++ SSPort, integer_to_list(NumLines), "35", SOptsClean)]),
|
||||
@ -2373,6 +2375,7 @@ node_ports_to_xhtml(Ports, Lang) ->
|
||||
[?XE("tr",
|
||||
[?XE("td", [?INPUTS("text", "portnew", "", "6")]),
|
||||
?XE("td", [?INPUTS("text", "ipnew", "0.0.0.0", "15")]),
|
||||
?XE("td", [make_netprot_html("tcp")]),
|
||||
?XE("td", [?INPUTS("text", "modulenew", "", "15")]),
|
||||
?XE("td", [?TEXTAREA("optsnew", "2", "35", "[]")]),
|
||||
?XAE("td", [{"colspan", "2"}],
|
||||
@ -2381,25 +2384,38 @@ node_ports_to_xhtml(Ports, Lang) ->
|
||||
)]
|
||||
)]).
|
||||
|
||||
make_netprot_html(NetProt) ->
|
||||
?XAE("select", [{"name", "netprotnew"}],
|
||||
lists:map(
|
||||
fun(O) ->
|
||||
Sel = if
|
||||
O == NetProt -> [{"selected", "selected"}];
|
||||
true -> []
|
||||
end,
|
||||
?XAC("option",
|
||||
Sel ++ [{"value", O}],
|
||||
O)
|
||||
end, ["tcp", "udp"])).
|
||||
|
||||
get_port_data(PortIP, Opts) ->
|
||||
{Port, IPT, IPS, _IPV, OptsClean} = ejabberd_listener:parse_listener_portip(PortIP, Opts),
|
||||
{Port, IPT, IPS, _IPV, NetProt, OptsClean} = ejabberd_listener:parse_listener_portip(PortIP, Opts),
|
||||
SPort = io_lib:format("~p", [Port]),
|
||||
|
||||
SSPort = lists:flatten(
|
||||
lists:map(
|
||||
fun(N) -> io_lib:format("~.16b", [N]) end,
|
||||
binary_to_list(crypto:md5(SPort++IPS)))),
|
||||
{Port, SPort, IPT, IPS, SSPort, OptsClean}.
|
||||
binary_to_list(crypto:md5(SPort++IPS++atom_to_list(NetProt))))),
|
||||
{Port, SPort, IPT, IPS, SSPort, NetProt, OptsClean}.
|
||||
|
||||
|
||||
node_ports_parse_query(Node, Ports, Query) ->
|
||||
lists:foreach(
|
||||
fun({PortIP, Module1, Opts1}) ->
|
||||
{Port, _SPort, TIP, _SIP, SSPort, _OptsClean} =
|
||||
get_port_data(PortIP, Opts1),
|
||||
fun({PortIpNetp, Module1, Opts1}) ->
|
||||
{Port, _SPort, TIP, _SIP, SSPort, NetProt, _OptsClean} =
|
||||
get_port_data(PortIpNetp, Opts1),
|
||||
case lists:keysearch("add" ++ SSPort, 1, Query) of
|
||||
{value, _} ->
|
||||
PortIP2 = {Port, TIP},
|
||||
PortIpNetp2 = {Port, TIP, NetProt},
|
||||
{{value, {_, SModule}}, {value, {_, SOpts}}} =
|
||||
{lists:keysearch("module" ++ SSPort, 1, Query),
|
||||
lists:keysearch("opts" ++ SSPort, 1, Query)},
|
||||
@ -2407,15 +2423,15 @@ node_ports_parse_query(Node, Ports, Query) ->
|
||||
{ok, Tokens, _} = erl_scan:string(SOpts ++ "."),
|
||||
{ok, Opts} = erl_parse:parse_term(Tokens),
|
||||
rpc:call(Node, ejabberd_listener, delete_listener,
|
||||
[PortIP2, Module1]),
|
||||
[PortIpNetp2, Module1]),
|
||||
R=rpc:call(Node, ejabberd_listener, add_listener,
|
||||
[PortIP2, Module, Opts]),
|
||||
[PortIpNetp2, Module, Opts]),
|
||||
throw({is_added, R});
|
||||
_ ->
|
||||
case lists:keysearch("delete" ++ SSPort, 1, Query) of
|
||||
{value, _} ->
|
||||
rpc:call(Node, ejabberd_listener, delete_listener,
|
||||
[PortIP, Module1]),
|
||||
[PortIpNetp, Module1]),
|
||||
throw(submitted);
|
||||
_ ->
|
||||
ok
|
||||
@ -2426,10 +2442,12 @@ node_ports_parse_query(Node, Ports, Query) ->
|
||||
{value, _} ->
|
||||
{{value, {_, SPort}},
|
||||
{value, {_, STIP}}, %% It is a string that may represent a tuple
|
||||
{value, {_, SNetProt}},
|
||||
{value, {_, SModule}},
|
||||
{value, {_, SOpts}}} =
|
||||
{lists:keysearch("portnew", 1, Query),
|
||||
lists:keysearch("ipnew", 1, Query),
|
||||
lists:keysearch("netprotnew", 1, Query),
|
||||
lists:keysearch("modulenew", 1, Query),
|
||||
lists:keysearch("optsnew", 1, Query)},
|
||||
{ok, Toks, _} = erl_scan:string(SPort ++ "."),
|
||||
@ -2440,12 +2458,13 @@ node_ports_parse_query(Node, Ports, Query) ->
|
||||
{error, _} -> STIP
|
||||
end,
|
||||
Module = list_to_atom(SModule),
|
||||
NetProt2 = list_to_atom(SNetProt),
|
||||
{ok, Tokens, _} = erl_scan:string(SOpts ++ "."),
|
||||
{ok, Opts} = erl_parse:parse_term(Tokens),
|
||||
{Port2, _SPort, IP2, _SIP, _SSPort, OptsClean} =
|
||||
get_port_data({Port2, STIP2}, Opts),
|
||||
{Port2, _SPort, IP2, _SIP, _SSPort, NetProt2, OptsClean} =
|
||||
get_port_data({Port2, STIP2, NetProt2}, Opts),
|
||||
R=rpc:call(Node, ejabberd_listener, add_listener,
|
||||
[{Port2, IP2}, Module, OptsClean]),
|
||||
[{Port2, IP2, NetProt2}, Module, OptsClean]),
|
||||
throw({is_added, R});
|
||||
_ ->
|
||||
ok
|
||||
|
Loading…
Reference in New Issue
Block a user