aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2003-10-11 17:39:36 +0000
committerAlexey Shchepin <alexey@process-one.net>2003-10-11 17:39:36 +0000
commit146d464f96228db6e61c3ca9bdff4990fea25343 (patch)
tree50575683e24d735c40a25a72dc99d89c35f82dea /src
parent* src/stringprep/stringprep_drv.c: Removed needless iconv.h (diff)
* doc/guide.tex: Updated
* src/ejabberd.cfg: Added "register" rule, added some comments, this file renamed to ejabberd.cfg.example * src/mod_register.erl (try_register): Fixed error reply, added check for "register" access rule * src/stringprep/Makefile.win32: Added Makefile for Win32 (thanks to Sergei Golovan) SVN Revision: 148
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd.cfg.example (renamed from src/ejabberd.cfg)48
-rw-r--r--src/ejabberd_listener.erl3
-rw-r--r--src/jlib.erl34
-rw-r--r--src/mod_register.erl20
-rw-r--r--src/stringprep/Makefile.win3240
5 files changed, 96 insertions, 49 deletions
diff --git a/src/ejabberd.cfg b/src/ejabberd.cfg.example
index 7c4bf9cd2..2cc561b65 100644
--- a/src/ejabberd.cfg
+++ b/src/ejabberd.cfg.example
@@ -2,45 +2,51 @@
%override_acls.
-{acl, admin, {user, "aleksey"}}.
-{acl, admin, {user, "ermine"}}.
-{acl, admin, {user, "test"}}.
-{acl, admin, {user, "aleksey", "jabber.ru"}}.
-{acl, admin, {user, "ermine", "jabber.ru"}}.
+% Users that have admin access. Add line like one of the following after you
+% will be successfully registered on server to get admin access:
+%{acl, admin, {user, "aleksey"}}.
+%{acl, admin, {user, "ermine"}}.
-{acl, blocked, {user, "test2"}}.
-
-{acl, jabberorg, {server, "jabber.org"}}.
-{acl, aleksey, {user, "aleksey", "jabber.ru"}}.
+% Blocked users:
+%{acl, blocked, {user, "test"}}.
+% Another examples of ACLs:
+%{acl, jabberorg, {server, "jabber.org"}}.
+%{acl, aleksey, {user, "aleksey", "jabber.ru"}}.
%{acl, test, {user_regexp, "^test"}}.
-%{acl, test2, {user_glob, "test*"}}.
+%{acl, test, {user_glob, "test*"}}.
-{shaper, normal, {maxrate, 1000}}.
+% Only admins can use configuration interface:
+{access, configure, [{allow, admin}]}.
+% Every username can be registered via in-band registration:
+{access, register, [{allow, all}]}.
-{access, disco_admin, [{allow, admin},
- {deny, all}]}.
-
-{access, configure, [{allow, admin}]}.
+% Only non-blocked users can use c2s connections:
{access, c2s, [{deny, blocked},
{allow, all}]}.
+% Set shaper with name "normal" to limit traffic speed to 1000B/s
+{shaper, normal, {maxrate, 1000}}.
+% For all users except admins used "normal" shaper
{access, c2s_shaper, [{none, admin},
{normal, all}]}.
+% Admins of this server are also admins of MUC service:
{access, muc_admin, [{allow, admin}]}.
+% Host name:
+{host, "localhost"}.
-{host, "e.localhost"}.
-{listen, [{5522, ejabberd_c2s, [{access, c2s},
+% Listened ports:
+{listen, [{5222, ejabberd_c2s, [{access, c2s},
{shaper, c2s_shaper}]},
- {5523, ejabberd_c2s, [{access, c2s},
+ {5223, ejabberd_c2s, [{access, c2s},
{ssl, [{certfile, "./ssl.pem"}]}]},
{5269, ejabberd_s2s_in, []},
{8888, ejabberd_service, [{host,
@@ -48,9 +54,11 @@
[{password, "asdqwe"}]}]}
]}.
-% This value (5569) is only for debugging, must be 5269
-{outgoing_s2s_port, 5569}.
+% If SRV lookup fails, then port 5269 used to communicate with other servers
+{outgoing_s2s_port, 5269}.
+
+% Used modules:
{modules, [
{mod_register, []},
{mod_roster, []},
diff --git a/src/ejabberd_listener.erl b/src/ejabberd_listener.erl
index 9de102be0..36dad2e13 100644
--- a/src/ejabberd_listener.erl
+++ b/src/ejabberd_listener.erl
@@ -52,7 +52,8 @@ init(Port, Module, Opts) ->
{ok, ListenSocket} = gen_tcp:listen(Port, [binary,
{packet, 0},
{active, false},
- {reuseaddr, true}]),
+ {reuseaddr, true},
+ {nodelay, true}]),
accept(ListenSocket, Module, Opts).
accept(ListenSocket, Module, Opts) ->
diff --git a/src/jlib.erl b/src/jlib.erl
index ced408945..839d6739c 100644
--- a/src/jlib.erl
+++ b/src/jlib.erl
@@ -227,25 +227,7 @@ jid_to_string({Node, Server, Resource}) ->
is_nodename([]) ->
false;
is_nodename(J) ->
- is_nodename1(J).
-
-is_nodename1([C | J])
- when (C =< 32) or
- (C == $") or
- (C == $&) or
- (C == $') or
- (C == $:) or
- (C == $<) or
- (C == $>) or
- (C == $@) or
- (C == $/) or
- (C == 127)
- ->
- false;
-is_nodename1([C | J]) ->
- is_nodename1(J);
-is_nodename1([]) ->
- true.
+ nodeprep(J).
@@ -301,7 +283,19 @@ resourceprep(S) ->
jid_tolower(#jid{luser = U, lserver = S, lresource = R}) ->
{U, S, R};
jid_tolower({U, S, R}) ->
- {tolower(U), tolower(S), R}.
+ case stringprep:nodeprep(U) of
+ error -> error;
+ LUser ->
+ case stringprep:nameprep(S) of
+ error -> error;
+ LServer ->
+ case stringprep:resourceprep(R) of
+ error -> error;
+ LResource ->
+ {LUser, LServer, LResource}
+ end
+ end
+ end.
jid_remove_resource(#jid{} = JID) ->
JID#jid{resource = "", lresource = ""};
diff --git a/src/mod_register.erl b/src/mod_register.erl
index b480dace9..9bf89f05e 100644
--- a/src/mod_register.erl
+++ b/src/mod_register.erl
@@ -116,14 +116,18 @@ try_register(User, Password) ->
false ->
{error, ?ERR_BAD_REQUEST};
_ ->
- case ejabberd_auth:try_register(User, Password) of
- {atomic, ok} ->
- ok;
- {atomic, exists} ->
- % TODO: replace to "username unavailable"
- {error, ?ERR_NOT_ALLOWED};
- {error, Reason} ->
- {error, ?ERR_INTERNAL_SERVER_ERROR}
+ case acl:match_rule(register, jlib:make_jid(User, ?MYNAME, "")) of
+ deny ->
+ {error, ?ERR_CONFLICT};
+ allow ->
+ case ejabberd_auth:try_register(User, Password) of
+ {atomic, ok} ->
+ ok;
+ {atomic, exists} ->
+ {error, ?ERR_CONFLICT};
+ {error, _Reason} ->
+ {error, ?ERR_INTERNAL_SERVER_ERROR}
+ end
end
end.
diff --git a/src/stringprep/Makefile.win32 b/src/stringprep/Makefile.win32
new file mode 100644
index 000000000..5339e3d2e
--- /dev/null
+++ b/src/stringprep/Makefile.win32
@@ -0,0 +1,40 @@
+
+include ..\Makefile.inc
+
+OUTDIR = ..
+EFLAGS = -I .. -pz ..
+
+ALL : $(OUTDIR)\stringprep_drv.dll $(OUTDIR)\stringprep.beam
+
+CLEAN :
+ -@erase $(OUTDIR)\stringprep_drv.dll
+ -@erase $(OUTDIR)\stringprep_drv.exp
+ -@erase $(OUTDIR)\stringprep_drv.lib
+ -@erase stringprep_drv.obj
+ -@erase stringprep_drv.pch
+ -@erase vc60.idb
+ -@erase $(OUTDIR)\stringprep.beam
+
+$(OUTDIR)\stringprep.beam : stringprep.erl
+ erlc -W $(EFLAGS) -o $(OUTDIR) stringprep.erl
+
+CPP=cl.exe
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "$(ERLANG_DIR)\usr\include" /I "$(EI_DIR)\include" /D "WIN32" /D "NDEBUG" /D "_USRDLL" /D "_MBCS" /Fpstringprep_drv.pch /YX /FD /c
+
+.c.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib "$(ERLANG_DIR)\usr\lib\erl_dll.lib" "$(EI_DIR)\lib\ei.lib" "$(EI_DIR)\lib\erl_interface.lib" /nologo /subsystem:console /dll /pdb:none /machine:I386 /out:$(OUTDIR)\stringprep_drv.dll
+
+LINK32_OBJS=stringprep_drv.obj
+
+$(OUTDIR)\stringprep_drv.dll : $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+stringprep_drv.obj : stringprep_drv.c
+