浏览代码

ht/ rework for onions step 2

Miraty 3 年之前
父节点
当前提交
91441c5f1d
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      public/ht/http-onion.php

+ 3 - 1
public/ht/http-onion.php

@@ -64,7 +64,7 @@ HiddenServicePort 80 [::1]:" . INTERNAL_ONION_HTTP_PORT . "
 ";
 	file_put_contents(TOR_CONFIG_PATH, $torConf);
 
-	exec(SUDO_PATH . " " . SYSTEMCTL_PATH . " reload-tor", $output);
+	exec(SUDO_PATH . " " . SYSTEMCTL_PATH . " reload tor", $output);
 	addNiverLog("Tor reloaded by " . $_SESSION['username'], $output);
 
 	// Copy generated address to a location readable by PHP
@@ -77,6 +77,8 @@ HiddenServicePort 80 [::1]:" . INTERNAL_ONION_HTTP_PORT . "
 	// Get the address generated by Tor
 	$onion = file_get_contents(HT_PATH . "/" . $_SESSION['username'] . "/" . $_POST['dir'] . "/hostname");
 	$onion = str_replace(array("\r", "\n"), "", $onion);
+	if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
+		exit("ERROR: No onion address found");
 
 	// Store it in the database
 	addSite($_SESSION['username'], $_POST['dir'], $onion, "onion", "http");