diff --git a/deploy/info.php b/deploy/info.php index 06dae44..2154369 100644 --- a/deploy/info.php +++ b/deploy/info.php @@ -4,7 +4,7 @@ // General information ///////////////////////////////////////////////////////////////////////////// $app['basename'] = 'syncthing'; -$app['version'] = '1.1.15'; +$app['version'] = '1.2.0'; $app['release'] = '1'; $app['vendor'] = 'WikiSuite'; $app['packager'] = 'WikiSuite'; diff --git a/deploy/service-check b/deploy/service-check index edc8d77..197604a 100755 --- a/deploy/service-check +++ b/deploy/service-check @@ -89,4 +89,12 @@ try { echo clearos_exception_message($e) . "\n"; } +if ($force) { + try { + $syncthing->update(); + } catch (Exception $e) { + echo clearos_exception_message($e) . "\n"; + } +} + // vim: syntax=php ts=4 diff --git a/libraries/Syncthing.php b/libraries/Syncthing.php index 1d3c0f0..1f3f6ee 100644 --- a/libraries/Syncthing.php +++ b/libraries/Syncthing.php @@ -539,6 +539,18 @@ function update() $iface_manager = new Iface_Manager(); $lan = $iface_manager->get_most_trusted_ips()[0]; $users = $this->get_users_config(); + if ($access == self::VIA_REVERSE_PROXY) { + // Delete any users that don't exist anymore + $lines = $proxy->get_contents_as_array(); + foreach ($lines as $line) { + if (preg_match("/RewriteCond %{REMOTE_USER} \"(.*)\"/", $line, $match)) { + if (!array_key_exists($match[1], $users)) { + $proxy->delete_lines("/\s*RewriteCond.* \"" . $match[1] . "\"$/i"); + $proxy->delete_lines("/\s*RewriteRule.* # " . $match[1] . "$/i"); + } + } + } + } foreach ($users as $user => $meta) { $file = new File(self::FOLDER_HOME . "/$user" . self::FILE_USER_CONFIG, TRUE); if (!$file->exists()) @@ -562,7 +574,16 @@ function update() } try { $proxy->lookup_line("/\s*RewriteCond %{REMOTE_USER} \"$user\"/i"); - $proxy->replace_lines("/\s*RewriteRule \"\\/syncthing\\/\\(\\.\\*\\)\" \"http:\\/\\/127\\.0\\.0\\.1:\d+\\/\\$1\" \\[P\\] # $user/i", "\tRewriteRule \"/syncthing/(.*)\" \"http://127.0.0.1:" . $meta['port'] . "/$1\" [P] # $user\n"); + if ($meta['enabled']) { + $proxy->replace_lines("/\s*RewriteRule \"\\/syncthing\\/\\(\\.\\*\\)\" \"http:\\/\\/127\\.0\\.0\\.1:\d+\\/\\$1\" \\[P\\] # $user$/i", "\tRewriteRule \"/syncthing/(.*)\" \"http://127.0.0.1:" . $meta['port'] . "/$1\" [P] # $user\n"); + } else { + try { + $proxy->delete_lines("/\s*RewriteCond.* \"$user\"$/i"); + $proxy->delete_lines("/\s*RewriteRule.* # $user$/i"); + } catch (File_No_Match_Exception $e) { + // Don't need to do anything + } + } } catch (File_No_Match_Exception $e) { $proxy->add_lines_after("\tRewriteRule \"/syncthing/(.*)\" \"http://127.0.0.1:" . $meta['port'] . "/$1\" [P] # $user\n", "/RewriteEngine on/i"); $proxy->add_lines_after("\tRewriteCond %{REMOTE_USER} \"$user\"\n", "/RewriteEngine on/i"); diff --git a/packaging/app-syncthing.spec b/packaging/app-syncthing.spec index c986038..457d159 100644 --- a/packaging/app-syncthing.spec +++ b/packaging/app-syncthing.spec @@ -1,7 +1,7 @@ Name: app-syncthing Epoch: 1 -Version: 1.1.15 +Version: 1.2.0 Release: 1%{dist} Summary: Syncthing License: GPLv3