25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

*** empty log message ***

SVN Revision: 52
This commit is contained in:
Alexey Shchepin 2003-01-28 19:45:13 +00:00
parent aed24c637f
commit 275b31b0cf
13 changed files with 238 additions and 36 deletions

1
TODO
View File

@ -8,3 +8,4 @@ iq:browse(?)
SRV DNS records
karma
SSL
JEP-62,63

View File

@ -72,7 +72,20 @@ Latest alpha version can be retrieved via CVS. Do following steps:
<H3>2.3&nbsp;&nbsp; Compilation</H3><!--SEC END -->
<A NAME="sec:compilation"></A><!--TOC section Configuration-->
<A NAME="sec:compilation"></A><PRE>
./configure
make
</PRE>TBD<BR>
<BR>
<!--TOC subsection Starting-->
<H3>2.4&nbsp;&nbsp; Starting</H3><!--SEC END -->
<A NAME="sec:starting"></A><PRE>
erl -name ejabberd -s ejabberd
</PRE>TBD<BR>
<BR>
<!--TOC section Configuration-->
<H2>3&nbsp;&nbsp; Configuration</H2><!--SEC END -->
@ -216,12 +229,12 @@ TBD<BR>
<H3>4.1&nbsp;&nbsp; How it works</H3><!--SEC END -->
<A NAME="sec:howitworks"></A>Jabber domain is served by one or more <TT>ejabberd</TT> nodes. This nodes can be
runned on different computers that can be connected via network. They all must
runned on different machines that can be connected via network. They all must
have access to connect to port 4369 of all another nodes, and must have same
magic cookie (see Erlang/OTP documentation, in short file
<TT>ejabberd/.erlang.cookie</TT> must be the same on all nodes). This is
needed because all nodes exchange information about connected users, S2S
connection ,registered services, etc...<BR>
connection, registered services, etc...<BR>
<BR>
Each <TT>ejabberd</TT> node run following modules:
<UL>

View File

@ -94,6 +94,12 @@ Latest alpha version can be retrieved via CVS\@. Do following steps:
\subsection{Compilation}
\label{sec:compilation}
\begin{verbatim}
./configure
make
\end{verbatim}
TBD
@ -101,6 +107,15 @@ Latest alpha version can be retrieved via CVS\@. Do following steps:
%\label{sec:initconfig}
\subsection{Starting}
\label{sec:starting}
\begin{verbatim}
erl -name ejabberd -s ejabberd
\end{verbatim}
TBD
\section{Configuration}
\label{sec:configuration}

View File

@ -1,9 +1,11 @@
# $Id$
INCLUDES = -I/usr/lib/erlang/usr/include \
-I/usr/lib/erlang/lib/erl_interface-3.3.0/include
include Makefile.inc
LIBDIRS = -L/usr/lib/erlang/lib/erl_interface-3.3.0/lib
INCLUDES = -I/usr/lib/erlang/usr/include \
-I$(EI_DIR)/include
LIBDIRS = -L$(EI_DIR)/lib
ERLSHLIBS = expat_erl.so
@ -22,3 +24,5 @@ $(ERLSHLIBS): %.so: %.c
clean:
rm -f *.beam
Makefile.inc:
./configure

5
src/configure vendored Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
erlc configure.erl
erl -s configure -noshell

20
src/configure.erl Normal file
View File

@ -0,0 +1,20 @@
%%%----------------------------------------------------------------------
%%% File : configure.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Created : 27 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(configure).
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
-export([start/0]).
start() ->
EIDirS = "EI_DIR = " ++ code:lib_dir("erl_interface") ++ "\n",
file:write_file("Makefile.inc", list_to_binary(EIDirS)),
halt().

View File

@ -31,6 +31,7 @@ init() ->
sha:start(),
translate:start(),
acl:start(),
gen_mod:start(),
ejabberd_config:start(),
ejabberd_auth:start(),
ejabberd_router:start(),

View File

@ -8,8 +8,8 @@
-define(VERSION, "0.0.1-alpha").
-define(ejabberd_debug, true).
-define(DBGFSM, true).
%-define(ejabberd_debug, true).
%-define(DBGFSM, true).
-ifdef(ejabberd_debug).
-define(DEBUG(Format, Args), io:format("D(~p:~p:~p) : "++Format++"~n",
@ -25,7 +25,8 @@
%-define(MYNAME,"e.localhost").
-define(MYNAME, ejabberd_config:get_global_option(host)).
-define(S2STIMEOUT, 1200000).
-define(S2STIMEOUT, 600000).
%-define(S2STIMEOUT, 6000).
-define(MSGS_DIR, "msgs").
-define(CONFIG_PATH, "ejabberd.cfg").

View File

@ -56,13 +56,13 @@ loop() ->
loop();
{register_route, Domain, Pid, Node} ->
F = fun() ->
case mnesia:wread({route, Domain}) of
[] ->
ok;
[Old] ->
% TODO: notify
ok
end,
%case mnesia:wread({route, Domain}) of
% [] ->
% ok;
% [Old] ->
% % TODO: notify
% ok
%end,
mnesia:write(#route{domain = Domain,
node = Node,
pid = Pid})
@ -78,13 +78,13 @@ loop() ->
loop();
{unregister_route, Domain} ->
F = fun() ->
case mnesia:wread({route, Domain}) of
[] ->
ok;
[Old] ->
% TODO: notify
ok
end,
%case mnesia:wread({route, Domain}) of
% [] ->
% ok;
% [Old] ->
% % TODO: notify
% ok
%end,
mnesia:delete({route, Domain})
end,
mnesia:transaction(F),

View File

@ -10,15 +10,18 @@
-author('alexey@sevcom.net').
-vsn('$Revision$ ').
-export([start_module/2,
-export([start/0,
start_module/2,
stop_module/1,
get_opt/2,
get_opt/3]).
get_opt/3,
loaded_modules/0]).
-export([behaviour_info/1]).
-include("ejabberd.hrl").
-record(ejabberd_module, {module, opts}).
behaviour_info(callbacks) ->
[{start, 1},
@ -26,17 +29,31 @@ behaviour_info(callbacks) ->
behaviour_info(Other) ->
undefined.
start() ->
ets:new(ejabberd_modules, [named_table,
public,
{keypos, #ejabberd_module.module}]),
ok.
start_module(Module, Opts) ->
case catch Module:start(Opts) of
{'EXIT', Reason} ->
?ERROR_MSG("~p", [Reason]);
_ ->
ets:insert(ejabberd_modules, #ejabberd_module{module = Module,
opts = Opts}),
ok
end.
stop_module(Module) ->
Module:stop().
case catch Module:stop() of
{'EXIT', Reason} ->
?ERROR_MSG("~p", [Reason]);
_ ->
ets:delete(ejabberd_modules, Module),
ok
end.
get_opt(Opt, Opts) ->
@ -56,3 +73,6 @@ get_opt(Opt, Opts, Default) ->
Val
end.
loaded_modules() ->
ets:select(ejabberd_modules,
[{#ejabberd_module{_ = '_', module = '$1'}, [],['$1']}]).

View File

@ -1,7 +1,7 @@
%%%----------------------------------------------------------------------
%%% File : mod_configure.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Purpose : Support for online configuration of ejabberd via x:data
%%% Created : 19 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
@ -162,6 +162,50 @@ get_form(["running nodes", ENode, "DB"], Lang) ->
end
end;
get_form(["running nodes", ENode, "modules", "stop"], Lang) ->
case search_running_node(ENode) of
false ->
{error, "404", "Not Found"};
Node ->
case rpc:call(Node, gen_mod, loaded_modules, []) of
{badrpc, Reason} ->
{error, "500", "Internal Server Error"};
Modules ->
SModules = lists:sort(Modules),
{result, [{xmlelement, "title", [],
[{xmlcdata,
translate:translate(
Lang, "Stop Modules")}]},
{xmlelement, "instructions", [],
[{xmlcdata,
translate:translate(
Lang, "Choose modules to stop")}]} |
lists:map(fun(M) ->
S = atom_to_list(M),
?XFIELD("boolean", S, S, "0")
end, SModules)
]}
end
end;
get_form(["running nodes", ENode, "modules", "start"], Lang) ->
{result, [{xmlelement, "title", [],
[{xmlcdata,
translate:translate(
Lang, "Start Modules")}]},
{xmlelement, "instructions", [],
[{xmlcdata,
translate:translate(
Lang, "Enter list of {Module, [Options]}")}]},
{xmlelement, "field", [{"type", "text-multi"},
{"label",
translate:translate(
Lang, "List of modules to start")},
{"var", "modules"}],
[{xmlelement, "value", [], [{xmlcdata, "[]."}]}]
}
]};
get_form(["config", "hostname"], Lang) ->
{result, [{xmlelement, "title", [],
[{xmlcdata,
@ -260,6 +304,63 @@ set_form(["running nodes", ENode, "DB"], Lang, XData) ->
{result, []}
end;
set_form(["running nodes", ENode, "modules", "stop"], Lang, XData) ->
case search_running_node(ENode) of
false ->
{error, "404", "Not Found"};
Node ->
lists:foreach(
fun({Var, Vals}) ->
case Vals of
["1"] ->
Module = list_to_atom(Var),
rpc:call(Node, gen_mod, stop_module, [Module]);
_ ->
ok
end
end, XData),
{result, []}
end;
set_form(["running nodes", ENode, "modules", "start"], Lang, XData) ->
case search_running_node(ENode) of
false ->
{error, "404", "Not Found"};
Node ->
case lists:keysearch("modules", 1, XData) of
false ->
{error, "406", "Not Acceptable"};
{value, {_, Strings}} ->
String = lists:foldl(fun(S, Res) ->
Res ++ S ++ "\n"
end, "", Strings),
case erl_scan:string(String) of
{ok, Tokens, _} ->
case erl_parse:parse_term(Tokens) of
{ok, Modules} ->
case catch lists:foreach(
fun({Module, Args}) ->
gen_mod:start_module(
Module, Args)
end, Modules) of
{'EXIT', Reason} ->
{error,
"500", "Internal Server Error"};
_ ->
{result, []}
end;
_ ->
{error, "500", "Internal Server Error"}
end;
_ ->
{error, "500", "Internal Server Error"}
end;
_ ->
{error, "406", "Not Acceptable"}
end
end;
set_form(["config", "hostname"], Lang, XData) ->
case lists:keysearch("hostname", 1, XData) of
false ->

View File

@ -1,7 +1,7 @@
%%%----------------------------------------------------------------------
%%% File : mod_disco.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Purpose : Service Discovery (JEP-0030) support
%%% Created : 1 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%----------------------------------------------------------------------
@ -114,6 +114,11 @@ process_local_iq_info(From, To, {iq, ID, Type, XMLNS, SubEl}) ->
[feature_to_xml({?NS_XDATA})
]
}]};
["running nodes", ENode, "modules"] -> ?EMPTY_INFO_RESULT;
["running nodes", ENode, "modules", _] ->
{iq, ID, result, XMLNS,
[{xmlelement, "query", [{"xmlns", XMLNS}],
[feature_to_xml({?NS_XDATA})]}]};
["config", _] ->
{iq, ID, result, XMLNS,
[{xmlelement, "query", [{"xmlns", XMLNS}],
@ -160,7 +165,6 @@ get_local_items(["config"], Server, Lang) ->
[?NODE("Host Name", "config/hostname"),
?NODE("ACLs", "config/acls"),
?NODE("Access Rules", "config/access"),
?NODE("Loaded Modules", "config/modules"),
?NODE("Remove Users", "config/remusers")
]};
@ -187,11 +191,22 @@ get_local_items(["stopped nodes"], Server, Lang) ->
get_local_items(["running nodes", ENode], Server, Lang) ->
{result,
[?NODE("DB", "running nodes/" ++ ENode ++ "/DB")]};
[?NODE("DB", "running nodes/" ++ ENode ++ "/DB"),
?NODE("Modules", "running nodes/" ++ ENode ++ "/modules")
]};
get_local_items(["running nodes", ENode, "DB"], Server, Lang) ->
{result, []};
get_local_items(["running nodes", ENode, "modules"], Server, Lang) ->
{result,
[?NODE("Start Modules", "running nodes/" ++ ENode ++ "/modules/start"),
?NODE("Stop Modules", "running nodes/" ++ ENode ++ "/modules/stop")
]};
get_local_items(["running nodes", ENode, "modules", _], Server, Lang) ->
{result, []};
get_local_items(_, _, _) ->
{error, "501", "Not Implemented"}.

View File

@ -12,7 +12,7 @@
-behaviour(gen_mod).
-export([start/1, init/1]).
-export([start/1, init/1, stop/0]).
-include("ejabberd.hrl").
-include("namespaces.hrl").
@ -22,18 +22,24 @@
start(Opts) ->
%Host = gen_mod:get_opt(host, Opts),
Host = gen_mod:get_opt(host, Opts, "echo." ++ ?MYNAME),
spawn(?MODULE, init, [Host]).
register(ejabberd_mod_echo, spawn(?MODULE, init, [Host])).
init(Host) ->
ejabberd_router:register_local_route(Host),
loop().
loop(Host).
loop() ->
loop(Host) ->
receive
{route, From, To, Packet} ->
ejabberd_router:route(To, From, Packet),
loop();
loop(Host);
stop ->
ejabberd_router:unregister_local_route(Host),
ok;
_ ->
loop()
loop(Host)
end.
stop() ->
ejabberd_mod_echo ! stop,
ok.