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() {
52 // set up an RPC request
53 require_once $CFG->dirroot
.'/mnet/xmlrpc/client.php';
54 $mnetrequest = new mnet_xmlrpc_client();
55 // Use any method - listServices is pretty lightweight.
56 $mnetrequest->set_method('system/listServices');
58 // Do RPC call and store response
59 if ($mnetrequest->send($this) === true) {
60 // Ok - we actually don't care about the result
61 $temp = new mnet_peer();
62 $temp->set_id($this->id
);
63 if($this->public_key
!= $temp->public_key
) {
64 $newkey = param_clean($temp->public_key
, PARAM_PEM
);
66 $this->public_key
= $newkey;