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

*** empty log message ***

SVN Revision: 28
This commit is contained in:
Alexey Shchepin 2003-01-04 20:09:25 +00:00
parent 5755092b92
commit 083e2b75d0
7 changed files with 53 additions and 25 deletions

View File

@ -16,5 +16,5 @@
-endif.
-define(MYNAME,"127.0.0.1").
-define(MYNAME,"e.localhost").

View File

@ -11,7 +11,9 @@
-vsn('$Revision$ ').
-export([route/3, register_route/1, register_local_route/1,
dirty_get_all_routes/0]).
dirty_get_all_routes/0,
dirty_get_all_domains/0
]).
-export([start/0, init/0]).
@ -132,3 +134,7 @@ dirty_get_all_routes() ->
lists:umerge(lists:sort(mnesia:dirty_all_keys(route)),
lists:sort(mnesia:dirty_all_keys(local_route)))).
dirty_get_all_domains() ->
lists:umerge(lists:sort(mnesia:dirty_all_keys(route)),
lists:sort(mnesia:dirty_all_keys(local_route))).

View File

@ -137,6 +137,7 @@ try_register(Server) ->
do_route(From, To, Packet) ->
?DEBUG("s2s manager~n\tfrom ~p~n\tto ~p~n\tpacket ~P~n",
[From, To, Packet, 8]),
{_, MyServer, _} = From,
{User, Server, Resource} = To,
Key = randoms:get_string(),
F = fun() ->
@ -172,7 +173,7 @@ do_route(From, To, Packet) ->
ok;
{atomic, new} ->
?DEBUG("starting new s2s connection~n", []),
Pid = ejabberd_s2s_out:start(Server, {new, Key}),
Pid = ejabberd_s2s_out:start(MyServer, Server, {new, Key}),
mnesia:transaction(fun() -> mnesia:write(#mys2s{server = Server,
pid = Pid}) end),
{xmlelement, Name, Attrs, Els} = Packet,

View File

@ -27,7 +27,7 @@
-include("ejabberd.hrl").
-record(state, {socket, receiver, streamid,
myself = ?MYNAME, server, queue}).
myname, server, queue}).
-define(DBGFSM, true).
@ -53,6 +53,12 @@
"</stream:stream>"
).
-define(INVALID_DOMAIN_ERR,
"<stream:stream>"
"<stream:error>Invalid Destination</stream:error>"
"</stream:stream>"
).
%%%----------------------------------------------------------------------
%%% API
%%%----------------------------------------------------------------------
@ -90,8 +96,19 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
% TODO
case {xml:get_attr_s("xmlns", Attrs), xml:get_attr_s("xmlns:db", Attrs)} of
{"jabber:server", "jabber:server:dialback"} ->
send_text(StateData#state.socket, ?STREAM_HEADER),
{next_state, wait_for_key, StateData};
Me = case xml:get_attr_s("to", Attrs) of
"" -> ?MYNAME;
Dom -> Dom
end,
case lists:member(Me, ejabberd_router:dirty_get_all_domains()) of
true ->
send_text(StateData#state.socket, ?STREAM_HEADER),
{next_state, wait_for_key, StateData#state{myname = Me}};
_ ->
send_text(StateData#state.socket, ?INVALID_DOMAIN_ERR),
{stop, normal, StateData}
end;
_ ->
send_text(StateData#state.socket, ?INVALID_HEADER_ERR),
{stop, normal, StateData}
@ -105,7 +122,8 @@ wait_for_key({xmlstreamelement, El}, StateData) ->
case is_key_packet(El) of
{key, To, From, Id, Key} ->
io:format("GET KEY: ~p~n", [{To, From, Id, Key}]),
ejabberd_s2s_out:start(From, {verify, self(), Key}),
ejabberd_s2s_out:start(StateData#state.myname, From,
{verify, self(), Key}),
{next_state,
wait_for_verification,
StateData#state{server = From}};
@ -118,7 +136,7 @@ wait_for_key({xmlstreamelement, El}, StateData) ->
send_element(StateData#state.socket,
{xmlelement,
"db:verify",
[{"from", ?MYNAME},
[{"from", StateData#state.myname},
{"to", From},
{"id", Id},
{"type", Type}],
@ -139,7 +157,7 @@ wait_for_verification(valid, StateData) ->
send_element(StateData#state.socket,
{xmlelement,
"db:result",
[{"from", ?MYNAME},
[{"from", StateData#state.myname},
{"to", StateData#state.server},
{"type", "valid"}],
[]}),
@ -150,7 +168,7 @@ wait_for_verification(invalid, StateData) ->
send_element(StateData#state.socket,
{xmlelement,
"db:result",
[{"from", ?MYNAME},
[{"from", StateData#state.myname},
{"to", StateData#state.server},
{"type", "invalid"}],
[]}),
@ -167,7 +185,7 @@ wait_for_verification({xmlstreamelement, El}, StateData) ->
send_element(StateData#state.socket,
{xmlelement,
"db:verify",
[{"from", ?MYNAME},
[{"from", StateData#state.myname},
{"to", From},
{"id", Id},
{"type", Type}],
@ -198,7 +216,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
send_element(StateData#state.socket,
{xmlelement,
"db:verify",
[{"from", ?MYNAME},
[{"from", StateData#state.myname},
{"to", From},
{"id", Id},
{"type", Type}],

View File

@ -13,7 +13,7 @@
-behaviour(gen_fsm).
%% External exports
-export([start/2, receiver/2, send_text/2, send_element/2]).
-export([start/3, receiver/2, send_text/2, send_element/2]).
%% gen_fsm callbacks
-export([init/1,
@ -27,7 +27,7 @@
-include("ejabberd.hrl").
-record(state, {socket, receiver, streamid,
myself = ?MYNAME, server, xmlpid, queue,
myname, server, xmlpid, queue,
new = false, verify = false}).
-define(DBGFSM, true).
@ -43,7 +43,8 @@
"<stream:stream "
"xmlns:stream='http://etherx.jabber.org/streams' "
"xmlns='jabber:server' "
"xmlns:db='jabber:server:dialback'>"
"xmlns:db='jabber:server:dialback' "
"to='~s'>"
).
-define(STREAM_TRAILER, "</stream:stream>").
@ -57,8 +58,8 @@
%%%----------------------------------------------------------------------
%%% API
%%%----------------------------------------------------------------------
start(Host, Type) ->
{ok, Pid} = gen_fsm:start(ejabberd_s2s_out, [Host, Type], ?FSMOPTS),
start(From, Host, Type) ->
{ok, Pid} = gen_fsm:start(ejabberd_s2s_out, [From, Host, Type], ?FSMOPTS),
Pid.
%%%----------------------------------------------------------------------
@ -72,7 +73,7 @@ start(Host, Type) ->
%% ignore |
%% {stop, StopReason}
%%----------------------------------------------------------------------
init([Server, Type]) ->
init([From, Server, Type]) ->
gen_fsm:send_event(self(), init),
{New, Verify} = case Type of
{new, Key} ->
@ -81,6 +82,7 @@ init([Server, Type]) ->
{false, {Pid, Key}}
end,
{ok, open_socket, #state{queue = queue:new(),
myname = From,
server = Server,
new = New,
verify = Verify}}.
@ -96,7 +98,8 @@ open_socket(init, StateData) ->
[binary, {packet, 0}]) of
{ok, Socket} ->
XMLStreamPid = xml_stream:start(self()),
send_text(Socket, ?STREAM_HEADER),
send_text(Socket, io_lib:format(?STREAM_HEADER,
[StateData#state.server])),
{next_state, wait_for_stream,
StateData#state{socket = Socket,
xmlpid = XMLStreamPid,
@ -135,7 +138,7 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
send_element(StateData#state.socket,
{xmlelement,
"db:result",
[{"from", ?MYNAME},
[{"from", StateData#state.myname},
{"to", Server}],
[{xmlcdata, Key1}]})
end,
@ -146,7 +149,7 @@ wait_for_stream({xmlstreamstart, Name, Attrs}, StateData) ->
send_element(StateData#state.socket,
{xmlelement,
"db:verify",
[{"from", ?MYNAME},
[{"from", StateData#state.myname},
{"to", StateData#state.server}],
[{xmlcdata, Key2}]})
end,

View File

@ -23,7 +23,7 @@
-record(session, {ur, user, node}).
-record(mysession, {ur, pid}).
-record(presence, {ur, user, priority}).
-record(offline_msg, {user, timestamp, xml}).
start() ->
spawn(ejabberd_sm, init, []).

View File

@ -172,8 +172,8 @@ set_vcard(LUser, VCARD) ->
[{xmlcdata, "Fill in fields to search "
"for any matching Jabber User"}]},
{xmlelement, "field", [{"type", "text-single"},
{"label", "JID"},
{"var", "jid"}], []},
{"label", "User"},
{"var", "user"}], []},
{xmlelement, "field", [{"type", "text-single"},
{"label", "Full Name"},
{"var", "fn"}], []},
@ -403,7 +403,7 @@ filter_fields([], Match) ->
filter_fields([{SVar, [Val]} | Ds], Match)
when is_list(Val) and (Val /= "") ->
NewMatch = case SVar of
"jid" -> Match;
"user" -> Match#vcard_search{user = Val};
"fn" -> Match#vcard_search{fn = Val};
"family" -> Match#vcard_search{family = Val};
"given" -> Match#vcard_search{given = Val};