3 * An object to represent lots of information about an RPC-peer machine
5 * @author Donal McMullan donal@catalyst.net.nz
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
11 class mnet_remote_client
extends mnet_peer
{
13 // If the remote client is trying to execute a method on an object instead
14 // of just a function, we'll instantiate the proper class and store it in
15 // this 'object_to_call' property.
16 var $object_to_call = false;
17 var $request_was_encrypted = false;
18 var $request_was_signed = false;
20 function was_encrypted() {
21 $this->request_was_encrypted
= true;
24 function was_signed() {
25 $this->request_was_signed
= true;
28 function object_to_call($object) {
29 $this->object_to_call
= $object;
32 function plaintext_is_ok() {
35 $trusted_hosts = explode(',', get_config('mnet', 'mnet_trusted_hosts'));
37 foreach($trusted_hosts as $host) {
38 list($network, $mask) = explode('/', $host.'/');
39 if (empty($network)) continue;
40 if (strlen($mask) == 0) $mask = 32;
42 if (ip_in_range($_SERVER['REMOTE_ADDR'], $network, $mask)) {
50 function refresh_key() {
51 // set up an RPC request
52 $mnetrequest = new mnet_xmlrpc_client();
53 // Use any method - listServices is pretty lightweight.
54 $mnetrequest->set_method('system/listServices');
56 // Do RPC call and store response
57 if ($mnetrequest->send($this) === true) {
58 // Ok - we actually don't care about the result
59 $temp = new mnet_peer();
60 $temp->set_id($this->id
);
61 if($this->public_key
!= $temp->public_key
) {
62 $newkey = param_clean($temp->public_key
, PARAM_PEM
);
64 $this->public_key
= $newkey;