~ubuntu-branches/ubuntu/wily/steam/wily

« back to all changes in this revision

Viewing changes to server/net/port/jabbers.pike

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-10-29 19:51:18 UTC
  • mfrom: (1.1.4) (0.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029195118-b9bxciz5hwx5z459
Tags: 1:1.0.0.39-2ubuntu1
Add an epoch to the version number as there was an unrelated steam package
in the archive with a higher version number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2004  Thomas Bopp, Thorsten Hampel, Ludger Merkens
2
 
 *
3
 
 *  This program is free software; you can redistribute it and/or modify
4
 
 *  it under the terms of the GNU General Public License as published by
5
 
 *  the Free Software Foundation; either version 2 of the License, or
6
 
 *  (at your option) any later version.
7
 
 *
8
 
 *  This program is distributed in the hope that it will be useful,
9
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 *  GNU General Public License for more details.
12
 
 *
13
 
 *  You should have received a copy of the GNU General Public License
14
 
 *  along with this program; if not, write to the Free Software
15
 
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
 
 * 
17
 
 */
18
 
inherit SSL.sslport;
19
 
 
20
 
import cert;
21
 
 
22
 
#include <config.h>
23
 
#include <macros.h>
24
 
 
25
 
static object context;
26
 
 
27
 
/***
28
 
 *
29
 
 *
30
 
 * @return 
31
 
 * @author Thomas Bopp 
32
 
 * @see 
33
 
 */
34
 
 
35
 
void setup_port() 
36
 
{
37
 
    object          tmp, u;
38
 
 
39
 
    tmp = ::accept();
40
 
    if ( !objectp(tmp) ) {
41
 
        werror("Failed to bind socket !\n");
42
 
        return;
43
 
    }
44
 
    master()->register_user((u=new(OBJ_JABBER, tmp, context)));
45
 
}
46
 
 
47
 
/**
48
 
 * Gets the program for the corresponding socket.
49
 
 *  
50
 
 * @return The socket for this port.
51
 
 * @author <a href="mailto:astra@upb.de">Thomas Bopp</a>) 
52
 
 */
53
 
program get_socket_program()
54
 
{
55
 
    return (program)OBJ_JABBER;
56
 
}
57
 
 
58
 
bool port_required() { return false; }
59
 
 
60
 
bool open_port()
61
 
{
62
 
    int port_nr = _Server->query_config("jabber_port")+1;
63
 
    if ( port_nr == 1 ) 
64
 
        port_nr = 5223;
65
 
 
66
 
    string ip = _Server->query_config("ip");
67
 
    if ( ! stringp(ip) || sizeof(ip)==0 ) ip = 0;
68
 
    if ( !bind(port_nr, setup_port, ip) ) {
69
 
        werror("Failed to bind jabber ssl port on "
70
 
            + (stringp(ip) ? ip+":" : "port ") + port_nr + " !\n");
71
 
        return false;
72
 
    }
73
 
    mapping cert_map = ([ ]);
74
 
    if ( catch ( cert_map = _Server->read_certificate() ) ) {
75
 
      FATAL("Cannot read server certificate for JABBERS !");
76
 
      return false;
77
 
    }
78
 
    certificates = ({ cert_map->cert });
79
 
    random = cert_map->random;
80
 
    rsa = cert_map->rsa;
81
 
    
82
 
    context = SSL.context();
83
 
    context->rsa = cert_map->rsa;
84
 
    context->random = cert_map->random;
85
 
    context->certificates = certificates;
86
 
 
87
 
    MESSAGE("JABBER SSL Port registered on "
88
 
        + (stringp(ip) ? ip+":" : "port ") + port_nr);
89
 
    return true;
90
 
}
91
 
 
92
 
string get_port_config()
93
 
{
94
 
    return "jabbers_port";
95
 
}
96
 
 
97
 
string get_port_name()
98
 
{
99
 
    return "jabber";
100
 
}
101
 
 
102
 
bool close_port()
103
 
{
104
 
    destruct(this_object());
105
 
}
106
 
 
107
 
int get_port() { return _Server->query_config("jabbers_port"); }
108
 
string describe() { return "JabberSSL(#"+get_port()+")"; }    
109
 
 
110
 
 
111