mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
* src/ejabberd_c2s.erl: Fixed bind namespace
* src/ejabberd_ctl.erl: New module for ejabberd administration * tools/ejabberdctl: Shell script for ejabberd administration * src/mod_vcard.erl: Copyright update * src/ejabberd_service.erl: Now possible to specify access rules for service * src/ejabberd.cfg.example: Updated SVN Revision: 198
This commit is contained in:
parent
41cc38aa6f
commit
c7d15b12df
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
||||
2004-01-11 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/ejabberd_c2s.erl: Fixed bind namespace
|
||||
|
||||
* src/ejabberd_ctl.erl: New module for ejabberd administration
|
||||
* tools/ejabberdctl: Shell script for ejabberd administration
|
||||
|
||||
* src/mod_vcard.erl: Copyright update
|
||||
|
||||
* src/ejabberd_service.erl: Now possible to specify access rules
|
||||
for service
|
||||
* src/ejabberd.cfg.example: Updated
|
||||
|
||||
2004-01-06 Alexey Shchepin <alexey@sevcom.net>
|
||||
|
||||
* src/ejabberd_router.erl: Added monitoring of processess that
|
||||
|
4
TODO
4
TODO
@ -1,3 +1,6 @@
|
||||
admin tool
|
||||
mod_muc logging
|
||||
|
||||
admin interface
|
||||
users management
|
||||
statistics about each user
|
||||
@ -10,7 +13,6 @@ S2S:
|
||||
rewrite S2S key validation
|
||||
check "id" attributes in db:verify packets
|
||||
|
||||
last presence
|
||||
more correctly work with SRV DNS records (priority, weight, etc...)
|
||||
TLS
|
||||
make roster set to work in one transaction
|
||||
|
@ -11,6 +11,9 @@
|
||||
% Blocked users:
|
||||
%{acl, blocked, {user, "test"}}.
|
||||
|
||||
% Local users:
|
||||
{acl, local, {user_regexp, ""}}.
|
||||
|
||||
% Another examples of ACLs:
|
||||
%{acl, jabberorg, {server, "jabber.org"}}.
|
||||
%{acl, aleksey, {user, "aleksey", "jabber.ru"}}.
|
||||
@ -61,6 +64,9 @@
|
||||
% Admins of this server are also admins of MUC service:
|
||||
{access, muc_admin, [{allow, admin}]}.
|
||||
|
||||
% This rule allows access only for local users:
|
||||
{access, local, [{allow, local}]}.
|
||||
|
||||
|
||||
% Authentification method. If you want to use internal user base, then use
|
||||
% this line:
|
||||
@ -83,7 +89,8 @@
|
||||
{5223, ejabberd_c2s, [{access, c2s},
|
||||
{ssl, [{certfile, "./ssl.pem"}]}]},
|
||||
{5269, ejabberd_s2s_in, [{shaper, s2s_shaper}]},
|
||||
{8888, ejabberd_service, [{hosts,
|
||||
{8888, ejabberd_service, [%{access, local},
|
||||
{hosts,
|
||||
["conference.e.localhost",
|
||||
"muc.e.localhost"],
|
||||
[{password, "secret"}]}]}
|
||||
|
@ -157,7 +157,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||
StateData,
|
||||
{xmlelement, "stream:features", [],
|
||||
[{xmlelement, "bind",
|
||||
[{"xmlns", ?NS_SASL}], []}]}),
|
||||
[{"xmlns", ?NS_BIND}], []}]}),
|
||||
{next_state, wait_for_bind, StateData};
|
||||
_ ->
|
||||
send_element(
|
||||
|
86
src/ejabberd_ctl.erl
Normal file
86
src/ejabberd_ctl.erl
Normal file
@ -0,0 +1,86 @@
|
||||
%%%----------------------------------------------------------------------
|
||||
%%% File : ejabberd_ctl.erl
|
||||
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Purpose : Ejabberd admin tool
|
||||
%%% Created : 11 Jan 2004 by Alexey Shchepin <alex@alex.sevcom.net>
|
||||
%%% Id : $Id$
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-module(ejabberd_ctl).
|
||||
-author('alexey@sevcom.net').
|
||||
|
||||
-export([start/0]).
|
||||
|
||||
start() ->
|
||||
case init:get_plain_arguments() of
|
||||
[SNode | Args] ->
|
||||
Node = list_to_atom(SNode),
|
||||
process(Node, Args);
|
||||
_ ->
|
||||
print_usage()
|
||||
end,
|
||||
halt().
|
||||
|
||||
|
||||
process(Node, ["stop"]) ->
|
||||
case rpc:call(Node, init, stop, []) of
|
||||
{badrpc, Reason} ->
|
||||
io:format("Can't stop node ~p: ~p~n",
|
||||
[Node, Reason]);
|
||||
_ ->
|
||||
ok
|
||||
end;
|
||||
|
||||
process(Node, ["restart"]) ->
|
||||
case rpc:call(Node, init, restart, []) of
|
||||
{badrpc, Reason} ->
|
||||
io:format("Can't restart node ~p: ~p~n",
|
||||
[Node, Reason]);
|
||||
_ ->
|
||||
ok
|
||||
end;
|
||||
|
||||
process(Node, ["register", User, Password]) ->
|
||||
case rpc:call(Node, ejabberd_auth, try_register, [User, Password]) of
|
||||
{atomic, ok} ->
|
||||
ok;
|
||||
{atomic, exists} ->
|
||||
io:format("User ~p already registered on node ~p~n",
|
||||
[User, Node]);
|
||||
{error, Reason} ->
|
||||
io:format("Can't register user ~p on node ~p: ~p~n",
|
||||
[User, Node, Reason]);
|
||||
{badrpc, Reason} ->
|
||||
io:format("Can't register user ~p on node ~p: ~p~n",
|
||||
[User, Node, Reason])
|
||||
end;
|
||||
|
||||
process(Node, ["unregister", User]) ->
|
||||
case rpc:call(Node, ejabberd_auth, remove_user, [User]) of
|
||||
{atomic, ok} ->
|
||||
ok;
|
||||
{error, Reason} ->
|
||||
io:format("Can't unregister user ~p on node ~p: ~p~n",
|
||||
[User, Node, Reason]);
|
||||
{badrpc, Reason} ->
|
||||
io:format("Can't unregister user ~p on node ~p: ~p~n",
|
||||
[User, Node, Reason])
|
||||
end;
|
||||
|
||||
process(_Node, _Args) ->
|
||||
print_usage().
|
||||
|
||||
|
||||
|
||||
print_usage() ->
|
||||
io:format("Usage: ejabberdctl node command~n"
|
||||
"~n"
|
||||
"Available commands:~n"
|
||||
" stop\t\t\t\tstop ejabberd~n"
|
||||
" restart\t\t\trestart ejabberd~n"
|
||||
" register user password\tregister user~n"
|
||||
" unregister user\t\tunregister user~n"
|
||||
"~n"
|
||||
"Example:~n"
|
||||
" ejabberdctl ejabberd@host restart~n"
|
||||
).
|
@ -30,7 +30,7 @@
|
||||
-include("jlib.hrl").
|
||||
|
||||
-record(state, {socket, receiver, streamid, sockmod,
|
||||
hosts, password}).
|
||||
hosts, password, access}).
|
||||
|
||||
%-define(DBGFSM, true).
|
||||
|
||||
@ -87,6 +87,10 @@ start_link(SockData, Opts) ->
|
||||
%% {stop, StopReason}
|
||||
%%----------------------------------------------------------------------
|
||||
init([{SockMod, Socket}, Opts]) ->
|
||||
Access = case lists:keysearch(access, 1, Opts) of
|
||||
{value, {_, A}} -> A;
|
||||
_ -> all
|
||||
end,
|
||||
{Hosts, Password} =
|
||||
case lists:keysearch(hosts, 1, Opts) of
|
||||
{value, {_, Hs, HOpts}} ->
|
||||
@ -118,7 +122,8 @@ init([{SockMod, Socket}, Opts]) ->
|
||||
streamid = new_id(),
|
||||
sockmod = SockMod,
|
||||
hosts = Hosts,
|
||||
password = Password
|
||||
password = Password,
|
||||
access = Access
|
||||
}}.
|
||||
|
||||
%%----------------------------------------------------------------------
|
||||
@ -127,8 +132,6 @@ init([{SockMod, Socket}, Opts]) ->
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
%state_name(Event, StateData) ->
|
||||
% {next_state, state_name, StateData}.
|
||||
|
||||
wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||
% TODO
|
||||
@ -280,12 +283,18 @@ handle_info({send_element, El}, StateName, StateData) ->
|
||||
send_element(StateData, El),
|
||||
{next_state, StateName, StateData};
|
||||
handle_info({route, From, To, Packet}, StateName, StateData) ->
|
||||
{xmlelement, Name, Attrs, Els} = Packet,
|
||||
Attrs2 = jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To),
|
||||
Attrs),
|
||||
Text = xml:element_to_string({xmlelement, Name, Attrs2, Els}),
|
||||
send_text(StateData, Text),
|
||||
case acl:match_rule(StateData#state.access, From) of
|
||||
allow ->
|
||||
{xmlelement, Name, Attrs, Els} = Packet,
|
||||
Attrs2 = jlib:replace_from_to_attrs(jlib:jid_to_string(From),
|
||||
jlib:jid_to_string(To),
|
||||
Attrs),
|
||||
Text = xml:element_to_string({xmlelement, Name, Attrs2, Els}),
|
||||
send_text(StateData, Text);
|
||||
deny ->
|
||||
Err = jlib:make_error_reply(Packet, ?ERR_NOT_ALLOWED),
|
||||
ejabberd_router:route(To, From, Err)
|
||||
end,
|
||||
{next_state, StateName, StateData}.
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ process_local_iq(_From, _To, #iq{type = Type, sub_el = SubEl} = IQ) ->
|
||||
"http://ejabberd.jabberstudio.org/"}]},
|
||||
{xmlelement, "DESC", [],
|
||||
[{xmlcdata, "Erlang Jabber Server\n"
|
||||
"Copyright (c) 2002, 2003 Alexey Shchepin"}]},
|
||||
"Copyright (c) 2002-2004 Alexey Shchepin"}]},
|
||||
{xmlelement, "BDAY", [],
|
||||
[{xmlcdata, "2002-11-16"}]}
|
||||
]}]}
|
||||
|
4
tools/ejabberdctl
Executable file
4
tools/ejabberdctl
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
erl -noinput -sname ejabberdctl -s ejabberd_ctl -extra $@
|
||||
|
Loading…
Reference in New Issue
Block a user