From 1c15a4e07f3dace24a4b4570f4a7fa8349cfc5b3 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Fri, 6 May 2022 18:27:03 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20(un)secure=20option=20for=20p?= =?UTF-8?q?roxies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DomainList/DomainListVC+Actions.swift | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/phpmon/Domain/DomainList/DomainListVC+Actions.swift b/phpmon/Domain/DomainList/DomainListVC+Actions.swift index f5da528..34c0a3e 100644 --- a/phpmon/Domain/DomainList/DomainListVC+Actions.swift +++ b/phpmon/Domain/DomainList/DomainListVC+Actions.swift @@ -20,8 +20,26 @@ extension DomainListVC { } func toggleSecureForProxy() { - // TODO: Handle this correctly - print("Will secure or unsecure proxy") + let originalSecureStatus = selectedProxy!.secured + let selectedProxy = selectedProxy! + + self.waitAndExecute { + // 1. Remove the original proxy + Shell.run("\(Paths.valet) unproxy \(selectedProxy.domain)", requiresPath: true) + + // 2. Add a new proxy, which is either secured/unsecured + let secure = originalSecureStatus ? "" : " --secure" + Shell.run("\(Paths.valet) proxy \(selectedProxy.domain) \(selectedProxy.target)\(secure)", + requiresPath: true) + + // 3. Restart nginx + Actions.restartNginx() + + // 4. Reload site list + DispatchQueue.main.async { + App.shared.domainListWindowController?.pressedReload(nil) + } + } } func toggleSecureForSite() {