diff --git a/var/www/common.php b/var/www/common.php
index db819de..3555301 100644
--- a/var/www/common.php
+++ b/var/www/common.php
@@ -4,7 +4,7 @@ const DBUSER='hosting'; // Database user
const DBPASS='MY_PASSWORD'; // Database password
const DBNAME='hosting'; // Database
const PERSISTENT=true; // Use persistent database conection true/false
-const DBVERSION=6; //database layout version
+const DBVERSION=7; //database layout version
const CAPTCHA=0; // Captcha difficulty (0=off, 1=simple, 2=moderate, 3=extreme)
const ADDRESS='dhosting4okcs22v.onion'; // our own address
const SERVERS=[ //servers and ports we are running on
@@ -210,12 +210,14 @@ NumEntryGuards 6
NumDirectoryGuards 6
NumPrimaryGuards 6
";
- $stmt=$db->prepare('SELECT onions.onion, users.system_account, onions.num_intros, onions.enable_smtp, onions.version FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion LIKE ? AND enabled=1;');
+ $stmt=$db->prepare('SELECT onions.onion, users.system_account, onions.num_intros, onions.enable_smtp, onions.version, onions.max_streams FROM onions INNER JOIN users ON (users.id=onions.user_id) WHERE onions.onion LIKE ? AND onions.enabled=1;');
$stmt->execute(["$key%"]);
while($tmp=$stmt->fetch(PDO::FETCH_NUM)){
$torrc.="HiddenServiceDir /var/lib/tor-instances/$key/hidden_service_$tmp[0].onion/
HiddenServiceNumIntroductionPoints $tmp[2]
HiddenServiceVersion $tmp[4]
+HiddenServiceMaxStreamsCloseCircuit 1
+HiddenServiceMaxStreams $tmp[5]
HiddenServicePort 80 unix:/var/run/nginx/$tmp[1]
";
if($tmp[3]){
diff --git a/var/www/cron.php b/var/www/cron.php
index 4e059da..c2603b3 100644
--- a/var/www/cron.php
+++ b/var/www/cron.php
@@ -5,7 +5,14 @@ try{
}catch(PDOException $e){
die('No Connection to MySQL database!');
}
+
+//instances to reload
$reload=[];
+$stmt=$db->query('SELECT id FROM service_instances WHERE reload=1;');
+while($tmp=$stmt->fetch(PDO::FETCH_NUM)){
+ $reload[$tmp[0]]=true;
+}
+$db->query('UPDATE service_instances SET reload=0 WHERE reload=1;');
//add new accounts
$del=$db->prepare("DELETE FROM new_account WHERE user_id=?;");
@@ -34,7 +41,7 @@ while($id=$stmt->fetch(PDO::FETCH_NUM)){
chown("/home/$system_account/$dir", $system_account);
chgrp("/home/$system_account/$dir", 'www-data');
}
- foreach(['logs']){
+ foreach(['logs'] as $dir){
mkdir("/home/$system_account/$dir", 0550);
chown("/home/$system_account/$dir", $system_account);
chgrp("/home/$system_account/$dir", 'www-data');
@@ -139,7 +146,9 @@ foreach($onions as $onion){
unlink("/etc/php/$v/fpm/pool.d/$firstchar/".substr($onion[0], 0, 16).".conf");
}
}
- unlink("/etc/nginx/sites-enabled/$onion[0]");
+ if(file_exists("/etc/nginx/sites-enabled/$onion[0]")){
+ unlink("/etc/nginx/sites-enabled/$onion[0]");
+ }
$stmt->execute([$onion[1]]);
while($tmp=$stmt->fetch(PDO::FETCH_NUM)){
//delete hidden service from tor
diff --git a/var/www/html/home.php b/var/www/html/home.php
index a57e86c..01ade44 100644
--- a/var/www/html/home.php
+++ b/var/www/html/home.php
@@ -18,8 +18,8 @@ echo "
Logged in as $user[username] Logout | Enter system account password to check your $user[system_account]@" . ADDRESS . " mail:
";
echo 'Domains';
echo '';
-echo 'Onion | Private key | Enabled | SMTP enabled | Nr. of intros | ';
-$stmt=$db->prepare('SELECT onion, private_key, enabled, enable_smtp, num_intros FROM onions WHERE user_id=?;');
+echo 'Onion | Private key | Enabled | SMTP enabled | Nr. of intros | Max streams per rendezvous circuit | ';
+$stmt=$db->prepare('SELECT onion, private_key, enabled, enable_smtp, num_intros, max_streams FROM onions WHERE user_id=?;');
$stmt->execute([$user['id']]);
while($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
echo "$onion[onion].onion | ";
@@ -32,7 +32,10 @@ while($onion=$stmt->fetch(PDO::FETCH_ASSOC)){
echo $onion['enabled'] ? 'Yes' : 'No';
echo ' | ';
echo $onion['enable_smtp'] ? 'Yes' : 'No';
- echo " | $onion[num_intros] | ";
+ echo '';
+ echo "$onion[num_intros] | ";
+ echo "$onion[max_streams] | ";
+ echo '';
}
echo ' ';
echo 'MySQL Database';
diff --git a/var/www/setup.php b/var/www/setup.php
index 3eeb294..dc79bd6 100644
--- a/var/www/setup.php
+++ b/var/www/setup.php
@@ -26,8 +26,13 @@ if(!@$version=$db->query("SELECT value FROM settings WHERE setting='version';"))
$db->exec('CREATE TABLE new_account (user_id int(11) NOT NULL PRIMARY KEY, password varchar(255) COLLATE latin1_bin NOT NULL, approved tinyint(1) UNSIGNED NOT NULL, CONSTRAINT new_account_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;');
$db->exec('CREATE TABLE pass_change (user_id int(11) NOT NULL PRIMARY KEY, password varchar(255) COLLATE latin1_bin NOT NULL, CONSTRAINT pass_change_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;');
$db->exec('CREATE TABLE mysql_databases (user_id int(11) NOT NULL, mysql_database varchar(64) COLLATE latin1_bin NOT NULL, KEY user_id, CONSTRAINT mysql_database_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;');
+ $db->exec("CREATE TABLE onions (user_id int(11) NOT NULL, onion varchar(56) COLLATE latin1_bin NOT NULL PRIMARY KEY, private_key varchar(1000) COLLATE latin1_bin NOT NULL, version tinyint(1) NOT NULL, enabled tinyint(1) NOT NULL DEFAULT '1', num_intros tinyint(3) NOT NULL DEFAULT '3', enable_smtp tinyint(1) NOT NULL DEFAULT '1', max_streams tinyint(3) unsigned NOT NULL DEFAULT '20', KEY user_id (user_id), KEY enabled (enabled), CONSTRAINT onions_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
+ $db->exec("CREATE TABLE service_instances (id char(1) NOT NULL PRIMARY KEY, reload tinyint(1) UNSIGNED NOT NULL DEFAULT '0', KEY reload (reload)) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
+ $stmt=$db->prepare('INSERT INTO service_instances (id) VALUES (?);');
+ foreach(['2', '3', '4', '5', '6', '7', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] as $key){
+ $stmt->execute([$key]);
+ }
$db->exec('CREATE TABLE settings (setting varchar(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL PRIMARY KEY, value text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;');
- $db->exec("CREATE TABLE onions (user_id int(11) NOT NULL, onion varchar(56) COLLATE latin1_bin NOT NULL PRIMARY KEY, private_key varchar(1000) COLLATE latin1_bin NOT NULL, version tinyint(1) NOT NULL, enabled tinyint(1) NOT NULL DEFAULT '1', num_intros tinyint(3) NOT NULL DEFAULT '3', enable_smtp tinyint(1) NOT NULL DEFAULT '1', KEY user_id (user_id), KEY enabled (enabled), CONSTRAINT onions_ibfk_1 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
$stmt=$db->prepare("INSERT INTO settings (setting, value) VALUES ('version', ?);");
$stmt->execute([DBVERSION]);
echo "Database has successfully been set up\n";
@@ -73,11 +78,16 @@ if(!@$version=$db->query("SELECT value FROM settings WHERE setting='version';"))
$replace=preg_replace("~listen\sunix:/var/run/nginx(/[a-z2-7]{16}|\.sock)(\sbacklog=2048)?;~", "listen unix:/var/run/nginx/$system_account backlog=2048;", file_get_contents("/etc/nginx/sites-enabled/$system_account"));
file_put_contents("/etc/nginx/sites-enabled/$system_account", $replace);
}
- foreach(['2', '3', '4', '5', '6', '7', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] as $key){
- rewrite_torrc($db, $key);
- }
exec('service nginx reload');
}
+ if($version<7){
+ $db->exec("ALTER TABLE onions ADD max_streams tinyint(3) unsigned NOT NULL DEFAULT '20';");
+ $db->exec("CREATE TABLE service_instances (id char(1) NOT NULL PRIMARY KEY, reload tinyint(1) UNSIGNED NOT NULL DEFAULT '0', KEY reload (reload)) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;");
+ $stmt=$db->prepare('INSERT INTO service_instances (id, reload) VALUES (?, 1)');
+ foreach(['2', '3', '4', '5', '6', '7', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] as $key){
+ $stmt->execute([$key]);
+ }
+ }
$stmt=$db->prepare("UPDATE settings SET value=? WHERE setting='version';");
$stmt->execute([DBVERSION]);
if(DBVERSION!=$version){
|