1 /* Copyright (C) 2000-2004 Thomas Bopp, Thorsten Hampel, Ludger Merkens
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.
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.
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
17 * $Id: cluster.pike,v 1.1 2008/03/31 13:39:57 exodusd Exp $
19 inherit "/kernel/module";
23 //! Server Cluster implementation. Keeps track of inter-Server connections
24 //! and a list of servers with certificates.
25 class cluster : public module{
35 ServerList list = ServerList();
39 private object get_cert()
41 if ( objectp(serverCert) )
44 object cert = get_module("filepath:tree")->path_to_object("/documents/steam.cer");
45 if ( !objectp(cert) ) {
46 string c = create_cert( ([
48 "organization": "Uni Paderborn",
50 "locality": "Paderborn",
52 "name": _Server->get_server_name(),
54 cert = get_factory(CLASS_DOCUMENT)->execute(([ "name":"steam.cer", ]));
56 cert->move(OBJ("/documents"));
67 add_data_storage(STORE_SERVERS, save_servers, load_servers, 1);
72 object add_server(string name, string hostname, void|string certificate)
74 Server s = Server(name, hostname, certificate);
76 require_save(STORE_SERVERS);
80 Server hello(string name, string cert)
82 Server s = list->get(name);
83 if ( s->verify(cert) )
88 ServerList get_serverlist()
95 return list->list_servers();
98 mixed send_command(string server, int oid, string func, mixed args)
103 object build_connection(Server|string s)
107 object conn = ((program)"/base/client_base.pike")();
108 conn->connect_server(s->get_hostname(), 1900);
109 conn->server_hello(get_cert());
110 list->set_connection(s, conn);
114 mapping save_servers()
119 void load_servers(mapping data)
124 string get_identifier() { return "Cluster"; }