예제 #1
0
 /**
  * Verify the disponibility of the tunnel
  *
  * @return bool
  */
 function checkStatus()
 {
     try {
         $http_client = new CHTTPClient($this->address);
         $http_client->setOption(CURLOPT_HEADER, true);
         $http_client->setOption(CURLOPT_TIMEOUT, 10);
         $http_client->setOption(CURLOPT_CUSTOMREQUEST, "CMD TEST");
         if ($this->ca_file) {
             $http_client->setSSLPeer($this->ca_file);
         }
         $result = $http_client->executeRequest();
     } catch (Exception $e) {
         $this->_message_status = $e->getMessage();
         $result = "";
     }
     $return = preg_match("#200#", $result) ? "1" : "0";
     if ($this->status !== $return) {
         $this->status = $return;
         if ($return && !$this->start_date) {
             $this->start_date = "now";
         } else {
             $this->start_date = "";
         }
         $this->store();
     }
     return $return;
 }
예제 #2
0
 * @link     http://www.mediboard.org
 */
$action = CValue::get("action", null);
$id = CValue::get("idTunnel", null);
$param = CValue::get("param", null);
$tunnel = new CHTTPTunnelObject();
$tunnel->load($id);
$http_client = new CHTTPClient($tunnel->address);
if ($tunnel->ca_file) {
    $http_client->setSSLPeer($tunnel->ca_file);
}
$result = "";
switch ($action) {
    case "restart":
        $http_client->setOption(CURLOPT_CUSTOMREQUEST, "CMD RESTART");
        $result = $http_client->executeRequest();
        break;
    case "stop":
        $http_client->setOption(CURLOPT_CUSTOMREQUEST, "CMD STOP");
        $result = $http_client->executeRequest();
        break;
    case "stat":
        $http_client->setOption(CURLOPT_CUSTOMREQUEST, "CMD STAT");
        $result = $http_client->executeRequest();
        $result = json_decode($result, true);
        break;
    case "test":
        $http_client->setOption(CURLOPT_HEADER, true);
        $result = $http_client->executeRequest();
        break;
    case "setlog":