request_was_encrypted = true; } function was_signed() { $this->request_was_signed = true; } function object_to_call($object) { $this->object_to_call = $object; } function plaintext_is_ok() { global $CFG; $trusted_hosts = explode(',', get_config('mnet', 'mnet_trusted_hosts')); foreach($trusted_hosts as $host) { list($network, $mask) = explode('/', $host.'/'); if (empty($network)) continue; if (strlen($mask) == 0) $mask = 32; if (ip_in_range($_SERVER['REMOTE_ADDR'], $network, $mask)) { return true; } } return false; } function refresh_key() { global $CFG; // set up an RPC request require_once $CFG->dirroot.'/mnet/xmlrpc/client.php'; $mnetrequest = new mnet_xmlrpc_client(); // Use any method - listServices is pretty lightweight. $mnetrequest->set_method('system/listServices'); // Do RPC call and store response if ($mnetrequest->send($this) === true) { // Ok - we actually don't care about the result $temp = new mnet_peer(); $temp->set_id($this->id); if($this->public_key != $temp->public_key) { $newkey = clean_param($temp->public_key, PARAM_PEM); if(!empty($newkey)) { $this->public_key = $newkey; $this->updateparams->public_key = $newkey; $this->commit(); return true; } } } return false; } } ?>