From cd7595e3f41ff103cf7c96d0699f5a738405d82f Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Thu, 19 Oct 2006 04:46:24 +0000 Subject: [PATCH] * src/ejabberd_socket.erl: Added sockname/1 and peername/1 functions * src/ejabberd_frontend_socket.erl: Likewise * src/tls/tls.erl: Likewise * src/ejabberd_zlib/ejabberd_zlib.erl: Likewise * src/mod_private_odbc.erl: Private storage support using odbc * src/odbc/pg.sql: Likewise SVN Revision: 663 --- ChangeLog | 11 ++++++++++ src/ejabberd_frontend_socket.erl | 31 ++++++++++++++++++++++++++++- src/ejabberd_socket.erl | 21 +++++++++++++++++-- src/ejabberd_zlib/ejabberd_zlib.erl | 17 ++++++++++++++++ src/odbc/pg.sql | 8 ++++++++ src/tls/tls.erl | 7 +++++++ 6 files changed, 92 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index f554609a5..ea3b19079 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-10-17 Alexey Shchepin + + * src/ejabberd_socket.erl: Added sockname/1 and peername/1 + functions + * src/ejabberd_frontend_socket.erl: Likewise + * src/tls/tls.erl: Likewise + * src/ejabberd_zlib/ejabberd_zlib.erl: Likewise + + * src/mod_private_odbc.erl: Private storage support using odbc + * src/odbc/pg.sql: Likewise + 2006-10-17 Mickael Remond * src/ejabberd_auth_ldap.erl: LDAP authentication now allows to diff --git a/src/ejabberd_frontend_socket.erl b/src/ejabberd_frontend_socket.erl index c69fac5b2..bafb96e41 100644 --- a/src/ejabberd_frontend_socket.erl +++ b/src/ejabberd_frontend_socket.erl @@ -25,7 +25,8 @@ get_sockmod/1, get_peer_certificate/1, get_verify_result/1, - close/1]). + close/1, + sockname/1, peername/1]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, @@ -109,6 +110,12 @@ get_verify_result(FsmRef) -> close(FsmRef) -> gen_server:call(FsmRef, close). +sockname(FsmRef) -> + gen_server:call(FsmRef, sockname). + +peername(FsmRef) -> + gen_server:call(FsmRef, peername). + %%==================================================================== %% gen_server callbacks @@ -205,6 +212,28 @@ handle_call(close, _From, State) -> Reply = ok, {stop, normal, Reply, State}; +handle_call(sockname, _From, State) -> + #state{sockmod = SockMod, socket = Socket} = State, + Reply = + case SockMod of + gen_tcp -> + inet:sockname(Socket); + _ -> + SockMod:sockname(Socket) + end, + {reply, Reply, State}; + +handle_call(peername, _From, State) -> + #state{sockmod = SockMod, socket = Socket} = State, + Reply = + case SockMod of + gen_tcp -> + inet:peername(Socket); + _ -> + SockMod:peername(Socket) + end, + {reply, Reply, State}; + handle_call(_Request, _From, State) -> Reply = ok, {reply, Reply, State}. diff --git a/src/ejabberd_socket.erl b/src/ejabberd_socket.erl index ba7a24f60..61040bf53 100644 --- a/src/ejabberd_socket.erl +++ b/src/ejabberd_socket.erl @@ -2,7 +2,7 @@ %%% File : ejabberd_socket.erl %%% Author : Alexey Shchepin %%% Purpose : Socket with zlib and TLS support library -%%% Created : 23 Aug 2006 by Alexey Shchepin +%%% Created : 23 Aug 2006 by Alexey Shchepin %%% Id : $Id$ %%%---------------------------------------------------------------------- @@ -22,7 +22,8 @@ get_sockmod/1, get_peer_certificate/1, get_verify_result/1, - close/1]). + close/1, + sockname/1, peername/1]). -record(socket_state, {sockmod, socket, receiver}). @@ -131,6 +132,22 @@ get_verify_result(SocketData) -> close(SocketData) -> ejabberd_receiver:close(SocketData#socket_state.receiver). +sockname(#socket_state{sockmod = SockMod, socket = Socket}) -> + case SockMod of + gen_tcp -> + inet:sockname(Socket); + _ -> + SockMod:sockname(Socket) + end. + +peername(#socket_state{sockmod = SockMod, socket = Socket}) -> + case SockMod of + gen_tcp -> + inet:peername(Socket); + _ -> + SockMod:peername(Socket) + end. + %%==================================================================== %% Internal functions %%==================================================================== diff --git a/src/ejabberd_zlib/ejabberd_zlib.erl b/src/ejabberd_zlib/ejabberd_zlib.erl index 2f74108df..99536651d 100644 --- a/src/ejabberd_zlib/ejabberd_zlib.erl +++ b/src/ejabberd_zlib/ejabberd_zlib.erl @@ -17,6 +17,7 @@ send/2, recv/2, recv/3, recv_data/2, setopts/2, + sockname/1, peername/1, controlling_process/2, close/1]). @@ -124,6 +125,22 @@ setopts(#zlibsock{sockmod = SockMod, socket = Socket}, Opts) -> SockMod:setopts(Socket, Opts) end. +sockname(#zlibsock{sockmod = SockMod, socket = Socket}) -> + case SockMod of + gen_tcp -> + inet:sockname(Socket); + _ -> + SockMod:sockname(Socket) + end. + +peername(#zlibsock{sockmod = SockMod, socket = Socket}) -> + case SockMod of + gen_tcp -> + inet:peername(Socket); + _ -> + SockMod:peername(Socket) + end. + controlling_process(#zlibsock{sockmod = SockMod, socket = Socket}, Pid) -> SockMod:controlling_process(Socket, Pid). diff --git a/src/odbc/pg.sql b/src/odbc/pg.sql index ba9ba089c..9f88756fe 100644 --- a/src/odbc/pg.sql +++ b/src/odbc/pg.sql @@ -118,6 +118,14 @@ CREATE TABLE privacy_list_data ( match_presence_out boolean NOT NULL ); +CREATE TABLE private_storage ( + username text NOT NULL, + namespace text NOT NULL, + data text NOT NULL +); + +CREATE INDEX i_private_storage_username ON private_storage USING btree (username); +CREATE UNIQUE INDEX i_private_storage_username_namespace ON private_storage USING btree (username, namespace); --- To update from 0.9.8: diff --git a/src/tls/tls.erl b/src/tls/tls.erl index 7c7d07bad..755697b0b 100644 --- a/src/tls/tls.erl +++ b/src/tls/tls.erl @@ -17,6 +17,7 @@ send/2, recv/2, recv/3, recv_data/2, setopts/2, + sockname/1, peername/1, controlling_process/2, close/1, get_peer_certificate/1, @@ -180,6 +181,12 @@ send(#tlssock{tcpsock = TCPSocket, tlsport = Port}, Packet) -> setopts(#tlssock{tcpsock = TCPSocket}, Opts) -> inet:setopts(TCPSocket, Opts). +sockname(#tlssock{tcpsock = TCPSocket}) -> + inet:sockname(TCPSocket). + +peername(#tlssock{tcpsock = TCPSocket}) -> + inet:peername(TCPSocket). + controlling_process(#tlssock{tcpsock = TCPSocket}, Pid) -> gen_tcp:controlling_process(TCPSocket, Pid).