Ejabberd

Dari SmartCommunity

Langsung ke: navigasi, cari

ejabberd is world’s most popular Jabber/XMPP server software. Despite the fact that it is known to be very bulky and hard to manage, it’s used at about 70% of all existing Jabber/XMPP servers.

Daftar isi

ODBC authentication method

TODO

LDAP authentication method

TODO

External authentication method

External authentifation script is supposed to do theses actions, in an infinite loop:

   * read from stdin: AABBBBBBBBB.....
         o A: 2 bytes of length data (a short in network byte order)
         o B: a string of length found in A that contains operation in plain text operation are as follows:
               + auth:User:Server:Password (check if a username/password pair is correct)
               + isuser:User:Server (check if it’s a valid user)
               + setpass:User:Server:Password (set user’s password)
               + tryregister:User:Server:Password (try to register an account)
               + removeuser:User:Server (remove this account)
               + removeuser3:User:Server:Password (remove this account if the password is correct) 
   * write to stdout: AABB
         o A: the number 2 (coded as a short, which is bytes length of following result)
         o B: the result code (coded as a short), should be 1 for success/valid, or 0 for failure/invalid 

Example (Python)

#!/usr/bin/python
import sys
from struct import *
def from_ejabberd():
  input_length = sys.stdin.read(2)
  (size,) = unpack('>h', input_length)
  return sys.stdin.read(size).split(':')
def to_ejabberd(bool):
  answer = 0
  if bool:
      answer = 1
  token = pack('>hh', 2, answer)
  sys.stdout.write(token)
  sys.stdout.flush()
def auth(username, server, password):
  return True
def isuser(username, server):
  return True
def setpass(username, server, password):
  return True
while True:
  data = from_ejabberd()
  success = False
  if data[0] == "auth":
      success = auth(data[1], data[2], data[3])
  elif data[0] == "isuser":
      success = isuser(data[1], data[2])
  elif data[0] == "setpass":
      success = setpass(data[1], data[2], data[3])
  to_ejabberd(success)

ejabberd tricks

These tips are useful to adjust running server settings from ejabberd console (ejabberdctl debug).

Please don't try unless you know what you are doing. Most of the tips are just a notices and require viewing source code before use.

who is using my nickname?

	mnesia:dirty_select(muc_registered, [{#muc_registered{us_host = '$1', nick = "WST", _ = '_'},[],['$1']}]).

release my nickname!

	mnesia:transaction(fun() -> mnesia:delete({muc_registered, {{"nany","jsmart.web.id"},"conference.jsmart.web.id"}}) end).

where's muc_register record?

	rd(muc_registered, {us_host, nick}).

who is online?

	rp(ejabberd_sm:get_vh_session_list("jabber.ru")).

how do I update config on-fly?

	ejabberd_config:get_global_option
                add_global_option

how do I invoke GC?

I summon thee almighty GC hallowed by thy name
accept this sacrifice and collect our memory
amen

© Author Unknown

Note that manual GC is not recommended unless it is required measure. Consult erlang manual

		etop
		etop:config(sort, memory).
		etop:config(lines, 50).

		erlang:garbage_collect(c:pid(0, 12810, 20)).

note that 1st argument of c:pid is now 0, because we'r in the same node now

		lists:foreach(fun(X) -> erlang:garbage_collect(X) end, processes()).

how do I reload modules?

Erlang modules, not ejabberd modules.

	code:soft_purge(module_name). -- try until true (code:purge, in contrast, terminates all processes using it)
	code:delete(module_name). == true
	code:load_file(module_name)

how do I rotate logs?

	ejabberd_logger_h:rotate_log("/path/to/logfile").

or just rename the file

then

	ejabberd_logger_h:reopen_log().

how do I get user's IP/conn.type/etc?

	ejabberd_sm:user_resources("user", "domain.tld").
	ejabberd_sm:get_user_info("user", "domain.tld", "Resource").

how do I change loglevel?

	ejabberd_loglevel:get().
	ejabberd_loglevel:set(warning).

possible levels are:

both symbol or integer representation is allowed

how do I change affiliation in a room?

	rd(muc_room_affiliation, {name_host, jid, affiliation, reason}).
    gen_storage:write(
      Host,
				      #muc_room_affiliation{name_host = {Name, Host},
							    jid = exmpp_jid:make(Username, Server, Resource),
							    affiliation = Affiliation,
							    reason = Reason})

INCOMPLETE! TODO!


how do I start/stop a module?

	gen_mod:start_module("jabber.web.id", mod_logxml, []).
            stop_module

how do I become an admin?

	acl:add("jabber.web.id", admin, {user, "dot", "by1"}).

Alert.png This article is marked as unfinished. You may contribute by writing it or wait for it’s author to do it.
Peralatan pribadi
Ruang nama
Varian
Tindakan
Navigasi
Kotak peralatan
Flattr this