├── .gitignore ├── .swiftlint.yml ├── LICENSE ├── PiHoleStats.xcodeproj ├── project.pbxproj └── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ ├── IDEWorkspaceChecks.plist │ └── swiftpm │ └── Package.resolved ├── PiHoleStats ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── icon-1024.png │ │ ├── icon-128.png │ │ ├── icon-256.png │ │ ├── icon-257.png │ │ ├── icon-512.png │ │ ├── icon-513.png │ │ └── icon-64.png │ ├── Contents.json │ ├── disabled.colorset │ │ └── Contents.json │ ├── domainBlocked.colorset │ │ └── Contents.json │ ├── enabled.colorset │ │ └── Contents.json │ ├── enabledAndDisabled.colorset │ │ └── Contents.json │ ├── globe.imageset │ │ ├── Contents.json │ │ └── globe.pdf │ ├── percentBlocked.colorset │ │ └── Contents.json │ ├── qrcode.imageset │ │ ├── Contents.json │ │ └── qrcode.pdf │ ├── queryBlocked.colorset │ │ └── Contents.json │ ├── shield.imageset │ │ ├── Contents.json │ │ └── shield.pdf │ ├── shieldIcon.imageset │ │ ├── Contents.json │ │ ├── shieldIcon.png │ │ └── shieldIcon@2x.png │ └── totalQuery.colorset │ │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── Config │ ├── Main.xcconfig │ └── OpenSource.xcconfig ├── Controllers │ ├── MenuController.swift │ └── NavigationController.swift ├── Core │ ├── Pihole.swift │ └── PiholeDataProvider.swift ├── Info.plist ├── Model │ ├── APIToken.swift │ └── UserPreferences.swift ├── PiHoleStats.entitlements ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── Util │ ├── DataMigrationManager.swift │ ├── EqualFrame.swift │ ├── EventMonitor.swift │ ├── KeyChainPasswordItem.swift │ ├── Logger.swift │ ├── PiHoleStats-Bridging-Header.h │ ├── QRCodeGenerator.swift │ ├── SharedFileList.h │ ├── SharedFileList.m │ ├── ToolTip.swift │ └── UIConstants.swift ├── ViewControllers │ ├── PreferencesViewController.swift │ └── SummaryViewController.swift ├── ViewModel │ ├── PiholeListViewModel.swift │ └── PiholeViewModel.swift └── Views │ ├── Preferences │ ├── AboutView.swift │ ├── PiholeConfigView.swift │ ├── PiholeItemConfig.swift │ ├── PiholeItemConfigView.swift │ ├── PiholeListConfigView.swift │ └── PreferencesView.swift │ └── Summary │ ├── SummaryItem.swift │ └── SummaryView.swift ├── PrivacyPolicy.md ├── README.md ├── bootstrap.sh └── images ├── icon.png ├── macstadium.png └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | ## Build generated 2 | build/ 3 | DerivedData/ 4 | 5 | ## Various settings 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | 16 | ## Other 17 | *.moved-aside 18 | *.xccheckout 19 | *.xcscmblueprint 20 | *.DS_Store 21 | 22 | ## Obj-C/Swift specific 23 | *.hmap 24 | *.ipa 25 | *.dSYM.zip 26 | *.dSYM 27 | 28 | PiHoleStats.xcodeproj/xcuserdata 29 | 30 | # Generated Config Files 31 | 32 | TeamID.xcconfig -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | disabled_rules: 2 | - line_length 3 | - nesting 4 | - trailing_whitespace 5 | - identifier_name 6 | - orphaned_doc_comment 7 | 8 | force_cast: warning 9 | force_try: 10 | severity: warning 11 | 12 | file_length: 13 | warning: 500 14 | error: 1200 15 | 16 | reporter: "xcode" 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2020, Fernando Bunn 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /PiHoleStats.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3114424124732D9D00042625 /* SwiftHole in Frameworks */ = {isa = PBXBuildFile; productRef = 3114424024732D9D00042625 /* SwiftHole */; }; 11 | 3124948C24701BD300634933 /* KeyChainPasswordItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3124948B24701BD300634933 /* KeyChainPasswordItem.swift */; }; 12 | 3124948E24701D2800634933 /* APIToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3124948D24701D2800634933 /* APIToken.swift */; }; 13 | 3129E20224F2B79800473269 /* ToolTip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3129E20124F2B79800473269 /* ToolTip.swift */; }; 14 | 313278EA2469FD7C00520124 /* UIConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 313278E92469FD7C00520124 /* UIConstants.swift */; }; 15 | 313278EE246A086000520124 /* UserPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 313278ED246A086000520124 /* UserPreferences.swift */; }; 16 | 313408DB24688456005D73E7 /* SummaryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 313408DA24688456005D73E7 /* SummaryViewController.swift */; }; 17 | 313408DD24689028005D73E7 /* PiholeListConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 313408DC24689028005D73E7 /* PiholeListConfigView.swift */; }; 18 | 3150BE8B2483149400EF0EF6 /* PiholeItemConfigView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3150BE8A2483149400EF0EF6 /* PiholeItemConfigView.swift */; }; 19 | 315CA2D8247925A10079F555 /* PreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 315CA2D7247925A10079F555 /* PreferencesView.swift */; }; 20 | 315CA2DC247931FE0079F555 /* SharedFileList.m in Sources */ = {isa = PBXBuildFile; fileRef = 315CA2DB247931FE0079F555 /* SharedFileList.m */; }; 21 | 3160C4F5247875D600FAB226 /* MenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3160C4F4247875D600FAB226 /* MenuController.swift */; }; 22 | 3160C4F7247876AC00FAB226 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3160C4F6247876AC00FAB226 /* EventMonitor.swift */; }; 23 | 3160C4FD2478791000FAB226 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3160C4FC2478791000FAB226 /* AboutView.swift */; }; 24 | 3160C50324787AF300FAB226 /* PreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3160C50224787AF300FAB226 /* PreferencesViewController.swift */; }; 25 | 31653448248C261B00733357 /* Preferences in Frameworks */ = {isa = PBXBuildFile; productRef = 31653447248C261B00733357 /* Preferences */; }; 26 | 31718236246B22E1003BBF0C /* SummaryItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31718235246B22E1003BBF0C /* SummaryItem.swift */; }; 27 | 317278892468AED900B5BE3D /* SummaryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 317278882468AED900B5BE3D /* SummaryView.swift */; }; 28 | 3173B1D6248F8A97000343BB /* PiholeListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3173B1D5248F8A97000343BB /* PiholeListViewModel.swift */; }; 29 | 31844F5C24D70CCE006CB0F7 /* EqualFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31844F5B24D70CCD006CB0F7 /* EqualFrame.swift */; }; 30 | 319044D824788C2D00BE4797 /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 319044D724788C2D00BE4797 /* NavigationController.swift */; }; 31 | 319084BC2454920700D47980 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 319084BB2454920700D47980 /* AppDelegate.swift */; }; 32 | 319084C02454920900D47980 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 319084BF2454920900D47980 /* Assets.xcassets */; }; 33 | 319084C32454920900D47980 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 319084C22454920900D47980 /* Preview Assets.xcassets */; }; 34 | 319084C62454920900D47980 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 319084C42454920900D47980 /* Main.storyboard */; }; 35 | 319F10952483F04A003EB3CD /* PiholeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 319F10942483F04A003EB3CD /* PiholeViewModel.swift */; }; 36 | 31ABD138247B14B700D76618 /* PiholeDataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31ABD137247B14B700D76618 /* PiholeDataProvider.swift */; }; 37 | 31ABD13A247B14C200D76618 /* Pihole.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31ABD139247B14C200D76618 /* Pihole.swift */; }; 38 | 31CC8174249F8072008DA24C /* DataMigrationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31CC8173249F8072008DA24C /* DataMigrationManager.swift */; }; 39 | 31CC8176249FA290008DA24C /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31CC8175249FA290008DA24C /* Logger.swift */; }; 40 | 31DC927924D7103500C6E8F7 /* QRCodeGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DC927824D7103500C6E8F7 /* QRCodeGenerator.swift */; }; 41 | /* End PBXBuildFile section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | 3124948B24701BD300634933 /* KeyChainPasswordItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyChainPasswordItem.swift; sourceTree = ""; }; 45 | 3124948D24701D2800634933 /* APIToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIToken.swift; sourceTree = ""; }; 46 | 3129E20124F2B79800473269 /* ToolTip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolTip.swift; sourceTree = ""; }; 47 | 313278E92469FD7C00520124 /* UIConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIConstants.swift; sourceTree = ""; }; 48 | 313278ED246A086000520124 /* UserPreferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserPreferences.swift; sourceTree = ""; }; 49 | 313408DA24688456005D73E7 /* SummaryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SummaryViewController.swift; sourceTree = ""; }; 50 | 313408DC24689028005D73E7 /* PiholeListConfigView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiholeListConfigView.swift; sourceTree = ""; }; 51 | 3150BE8A2483149400EF0EF6 /* PiholeItemConfigView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiholeItemConfigView.swift; sourceTree = ""; }; 52 | 315CA2D7247925A10079F555 /* PreferencesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesView.swift; sourceTree = ""; }; 53 | 315CA2D9247931FE0079F555 /* PiHoleStats-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PiHoleStats-Bridging-Header.h"; sourceTree = ""; }; 54 | 315CA2DA247931FE0079F555 /* SharedFileList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SharedFileList.h; sourceTree = ""; }; 55 | 315CA2DB247931FE0079F555 /* SharedFileList.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SharedFileList.m; sourceTree = ""; }; 56 | 3160C4F4247875D600FAB226 /* MenuController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuController.swift; sourceTree = ""; }; 57 | 3160C4F6247876AC00FAB226 /* EventMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventMonitor.swift; sourceTree = ""; }; 58 | 3160C4FC2478791000FAB226 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = ""; }; 59 | 3160C50224787AF300FAB226 /* PreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesViewController.swift; sourceTree = ""; }; 60 | 31718235246B22E1003BBF0C /* SummaryItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SummaryItem.swift; sourceTree = ""; }; 61 | 317278882468AED900B5BE3D /* SummaryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SummaryView.swift; sourceTree = ""; }; 62 | 3173B1D5248F8A97000343BB /* PiholeListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiholeListViewModel.swift; sourceTree = ""; }; 63 | 31844F5B24D70CCD006CB0F7 /* EqualFrame.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EqualFrame.swift; sourceTree = ""; }; 64 | 319044D724788C2D00BE4797 /* NavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = ""; }; 65 | 319084B82454920700D47980 /* Pi Stats.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Pi Stats.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 66 | 319084BB2454920700D47980 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 67 | 319084BF2454920900D47980 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 68 | 319084C22454920900D47980 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 69 | 319084C52454920900D47980 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 70 | 319084C72454920900D47980 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 71 | 319084C82454920900D47980 /* PiHoleStats.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PiHoleStats.entitlements; sourceTree = ""; }; 72 | 319F10942483F04A003EB3CD /* PiholeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiholeViewModel.swift; sourceTree = ""; }; 73 | 31ABD137247B14B700D76618 /* PiholeDataProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PiholeDataProvider.swift; sourceTree = ""; }; 74 | 31ABD139247B14C200D76618 /* Pihole.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pihole.swift; sourceTree = ""; }; 75 | 31CC8173249F8072008DA24C /* DataMigrationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataMigrationManager.swift; sourceTree = ""; }; 76 | 31CC8175249FA290008DA24C /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = ""; }; 77 | 31DC927824D7103500C6E8F7 /* QRCodeGenerator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeGenerator.swift; sourceTree = ""; }; 78 | F40B653C2C7E0D5B0079F743 /* Main.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Main.xcconfig; sourceTree = ""; }; 79 | F40B653D2C7E0D5B0079F743 /* OpenSource.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = OpenSource.xcconfig; sourceTree = ""; }; 80 | F40B653F2C7E0D8C0079F743 /* TeamID.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = TeamID.xcconfig; sourceTree = ""; }; 81 | /* End PBXFileReference section */ 82 | 83 | /* Begin PBXFrameworksBuildPhase section */ 84 | 319084B52454920700D47980 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | 3114424124732D9D00042625 /* SwiftHole in Frameworks */, 89 | 31653448248C261B00733357 /* Preferences in Frameworks */, 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | /* End PBXFrameworksBuildPhase section */ 94 | 95 | /* Begin PBXGroup section */ 96 | 313278EB246A079000520124 /* Util */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 313278E92469FD7C00520124 /* UIConstants.swift */, 100 | 31844F5B24D70CCD006CB0F7 /* EqualFrame.swift */, 101 | 3124948B24701BD300634933 /* KeyChainPasswordItem.swift */, 102 | 3160C4F6247876AC00FAB226 /* EventMonitor.swift */, 103 | 31CC8173249F8072008DA24C /* DataMigrationManager.swift */, 104 | 315CA2DA247931FE0079F555 /* SharedFileList.h */, 105 | 315CA2DB247931FE0079F555 /* SharedFileList.m */, 106 | 315CA2D9247931FE0079F555 /* PiHoleStats-Bridging-Header.h */, 107 | 31CC8175249FA290008DA24C /* Logger.swift */, 108 | 31DC927824D7103500C6E8F7 /* QRCodeGenerator.swift */, 109 | 3129E20124F2B79800473269 /* ToolTip.swift */, 110 | ); 111 | path = Util; 112 | sourceTree = ""; 113 | }; 114 | 313278EF246A08B900520124 /* ViewModel */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 319F10942483F04A003EB3CD /* PiholeViewModel.swift */, 118 | 3173B1D5248F8A97000343BB /* PiholeListViewModel.swift */, 119 | ); 120 | path = ViewModel; 121 | sourceTree = ""; 122 | }; 123 | 315CA2D5247925220079F555 /* Preferences */ = { 124 | isa = PBXGroup; 125 | children = ( 126 | 315CA2D7247925A10079F555 /* PreferencesView.swift */, 127 | 3160C4FC2478791000FAB226 /* AboutView.swift */, 128 | 313408DC24689028005D73E7 /* PiholeListConfigView.swift */, 129 | 3150BE8A2483149400EF0EF6 /* PiholeItemConfigView.swift */, 130 | ); 131 | path = Preferences; 132 | sourceTree = ""; 133 | }; 134 | 315CA2D62479252E0079F555 /* Summary */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 317278882468AED900B5BE3D /* SummaryView.swift */, 138 | 31718235246B22E1003BBF0C /* SummaryItem.swift */, 139 | ); 140 | path = Summary; 141 | sourceTree = ""; 142 | }; 143 | 3160C4F3247875C100FAB226 /* Controllers */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 3160C4F4247875D600FAB226 /* MenuController.swift */, 147 | 319044D724788C2D00BE4797 /* NavigationController.swift */, 148 | ); 149 | path = Controllers; 150 | sourceTree = ""; 151 | }; 152 | 3172788A2468AF1A00B5BE3D /* Views */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 315CA2D62479252E0079F555 /* Summary */, 156 | 315CA2D5247925220079F555 /* Preferences */, 157 | ); 158 | path = Views; 159 | sourceTree = ""; 160 | }; 161 | 3172788B2468AF2600B5BE3D /* ViewControllers */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 313408DA24688456005D73E7 /* SummaryViewController.swift */, 165 | 3160C50224787AF300FAB226 /* PreferencesViewController.swift */, 166 | ); 167 | path = ViewControllers; 168 | sourceTree = ""; 169 | }; 170 | 3172788C2468B02B00B5BE3D /* Model */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | 313278ED246A086000520124 /* UserPreferences.swift */, 174 | 3124948D24701D2800634933 /* APIToken.swift */, 175 | ); 176 | path = Model; 177 | sourceTree = ""; 178 | }; 179 | 319084AF2454920700D47980 = { 180 | isa = PBXGroup; 181 | children = ( 182 | 319084BA2454920700D47980 /* PiHoleStats */, 183 | 319084B92454920700D47980 /* Products */, 184 | ); 185 | sourceTree = ""; 186 | }; 187 | 319084B92454920700D47980 /* Products */ = { 188 | isa = PBXGroup; 189 | children = ( 190 | 319084B82454920700D47980 /* Pi Stats.app */, 191 | ); 192 | name = Products; 193 | sourceTree = ""; 194 | }; 195 | 319084BA2454920700D47980 /* PiHoleStats */ = { 196 | isa = PBXGroup; 197 | children = ( 198 | F40B653E2C7E0D5B0079F743 /* Config */, 199 | 31ABD136247B14A700D76618 /* Core */, 200 | 3160C4F3247875C100FAB226 /* Controllers */, 201 | 313278EF246A08B900520124 /* ViewModel */, 202 | 3172788C2468B02B00B5BE3D /* Model */, 203 | 3172788B2468AF2600B5BE3D /* ViewControllers */, 204 | 3172788A2468AF1A00B5BE3D /* Views */, 205 | 313278EB246A079000520124 /* Util */, 206 | 319084BB2454920700D47980 /* AppDelegate.swift */, 207 | 319084BF2454920900D47980 /* Assets.xcassets */, 208 | 319084C42454920900D47980 /* Main.storyboard */, 209 | 319084C72454920900D47980 /* Info.plist */, 210 | 319084C82454920900D47980 /* PiHoleStats.entitlements */, 211 | 319084C12454920900D47980 /* Preview Content */, 212 | ); 213 | path = PiHoleStats; 214 | sourceTree = ""; 215 | }; 216 | 319084C12454920900D47980 /* Preview Content */ = { 217 | isa = PBXGroup; 218 | children = ( 219 | 319084C22454920900D47980 /* Preview Assets.xcassets */, 220 | ); 221 | path = "Preview Content"; 222 | sourceTree = ""; 223 | }; 224 | 31ABD136247B14A700D76618 /* Core */ = { 225 | isa = PBXGroup; 226 | children = ( 227 | 31ABD137247B14B700D76618 /* PiholeDataProvider.swift */, 228 | 31ABD139247B14C200D76618 /* Pihole.swift */, 229 | ); 230 | path = Core; 231 | sourceTree = ""; 232 | }; 233 | F40B653E2C7E0D5B0079F743 /* Config */ = { 234 | isa = PBXGroup; 235 | children = ( 236 | F40B653C2C7E0D5B0079F743 /* Main.xcconfig */, 237 | F40B653D2C7E0D5B0079F743 /* OpenSource.xcconfig */, 238 | F40B653F2C7E0D8C0079F743 /* TeamID.xcconfig */, 239 | ); 240 | path = Config; 241 | sourceTree = ""; 242 | }; 243 | /* End PBXGroup section */ 244 | 245 | /* Begin PBXNativeTarget section */ 246 | 319084B72454920700D47980 /* PiHoleStats */ = { 247 | isa = PBXNativeTarget; 248 | buildConfigurationList = 319084CB2454920900D47980 /* Build configuration list for PBXNativeTarget "PiHoleStats" */; 249 | buildPhases = ( 250 | 319084B42454920700D47980 /* Sources */, 251 | 319084B52454920700D47980 /* Frameworks */, 252 | 319084B62454920700D47980 /* Resources */, 253 | 31ABD135247B0AB500D76618 /* ShellScript */, 254 | ); 255 | buildRules = ( 256 | ); 257 | dependencies = ( 258 | ); 259 | name = PiHoleStats; 260 | packageProductDependencies = ( 261 | 3114424024732D9D00042625 /* SwiftHole */, 262 | 31653447248C261B00733357 /* Preferences */, 263 | ); 264 | productName = PiHoleStats; 265 | productReference = 319084B82454920700D47980 /* Pi Stats.app */; 266 | productType = "com.apple.product-type.application"; 267 | }; 268 | /* End PBXNativeTarget section */ 269 | 270 | /* Begin PBXProject section */ 271 | 319084B02454920700D47980 /* Project object */ = { 272 | isa = PBXProject; 273 | attributes = { 274 | LastSwiftUpdateCheck = 1140; 275 | LastUpgradeCheck = 1140; 276 | ORGANIZATIONNAME = "Fernando Bunn"; 277 | TargetAttributes = { 278 | 319084B72454920700D47980 = { 279 | CreatedOnToolsVersion = 11.4.1; 280 | LastSwiftMigration = 1150; 281 | }; 282 | }; 283 | }; 284 | buildConfigurationList = 319084B32454920700D47980 /* Build configuration list for PBXProject "PiHoleStats" */; 285 | compatibilityVersion = "Xcode 9.3"; 286 | developmentRegion = en; 287 | hasScannedForEncodings = 0; 288 | knownRegions = ( 289 | en, 290 | Base, 291 | ); 292 | mainGroup = 319084AF2454920700D47980; 293 | packageReferences = ( 294 | 3114423F24732D9D00042625 /* XCRemoteSwiftPackageReference "SwiftHole" */, 295 | 31653446248C261B00733357 /* XCRemoteSwiftPackageReference "Preferences" */, 296 | ); 297 | productRefGroup = 319084B92454920700D47980 /* Products */; 298 | projectDirPath = ""; 299 | projectRoot = ""; 300 | targets = ( 301 | 319084B72454920700D47980 /* PiHoleStats */, 302 | ); 303 | }; 304 | /* End PBXProject section */ 305 | 306 | /* Begin PBXResourcesBuildPhase section */ 307 | 319084B62454920700D47980 /* Resources */ = { 308 | isa = PBXResourcesBuildPhase; 309 | buildActionMask = 2147483647; 310 | files = ( 311 | 319084C62454920900D47980 /* Main.storyboard in Resources */, 312 | 319084C32454920900D47980 /* Preview Assets.xcassets in Resources */, 313 | 319084C02454920900D47980 /* Assets.xcassets in Resources */, 314 | ); 315 | runOnlyForDeploymentPostprocessing = 0; 316 | }; 317 | /* End PBXResourcesBuildPhase section */ 318 | 319 | /* Begin PBXShellScriptBuildPhase section */ 320 | 31ABD135247B0AB500D76618 /* ShellScript */ = { 321 | isa = PBXShellScriptBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | ); 325 | inputFileListPaths = ( 326 | ); 327 | inputPaths = ( 328 | ); 329 | outputFileListPaths = ( 330 | ); 331 | outputPaths = ( 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | shellPath = /bin/sh; 335 | shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; 336 | }; 337 | /* End PBXShellScriptBuildPhase section */ 338 | 339 | /* Begin PBXSourcesBuildPhase section */ 340 | 319084B42454920700D47980 /* Sources */ = { 341 | isa = PBXSourcesBuildPhase; 342 | buildActionMask = 2147483647; 343 | files = ( 344 | 3160C4FD2478791000FAB226 /* AboutView.swift in Sources */, 345 | 3160C50324787AF300FAB226 /* PreferencesViewController.swift in Sources */, 346 | 315CA2D8247925A10079F555 /* PreferencesView.swift in Sources */, 347 | 313278EE246A086000520124 /* UserPreferences.swift in Sources */, 348 | 31ABD13A247B14C200D76618 /* Pihole.swift in Sources */, 349 | 31DC927924D7103500C6E8F7 /* QRCodeGenerator.swift in Sources */, 350 | 3150BE8B2483149400EF0EF6 /* PiholeItemConfigView.swift in Sources */, 351 | 31844F5C24D70CCE006CB0F7 /* EqualFrame.swift in Sources */, 352 | 31CC8174249F8072008DA24C /* DataMigrationManager.swift in Sources */, 353 | 31ABD138247B14B700D76618 /* PiholeDataProvider.swift in Sources */, 354 | 3173B1D6248F8A97000343BB /* PiholeListViewModel.swift in Sources */, 355 | 3129E20224F2B79800473269 /* ToolTip.swift in Sources */, 356 | 31CC8176249FA290008DA24C /* Logger.swift in Sources */, 357 | 31718236246B22E1003BBF0C /* SummaryItem.swift in Sources */, 358 | 319044D824788C2D00BE4797 /* NavigationController.swift in Sources */, 359 | 3124948E24701D2800634933 /* APIToken.swift in Sources */, 360 | 313408DD24689028005D73E7 /* PiholeListConfigView.swift in Sources */, 361 | 313278EA2469FD7C00520124 /* UIConstants.swift in Sources */, 362 | 317278892468AED900B5BE3D /* SummaryView.swift in Sources */, 363 | 319F10952483F04A003EB3CD /* PiholeViewModel.swift in Sources */, 364 | 319084BC2454920700D47980 /* AppDelegate.swift in Sources */, 365 | 313408DB24688456005D73E7 /* SummaryViewController.swift in Sources */, 366 | 315CA2DC247931FE0079F555 /* SharedFileList.m in Sources */, 367 | 3160C4F7247876AC00FAB226 /* EventMonitor.swift in Sources */, 368 | 3160C4F5247875D600FAB226 /* MenuController.swift in Sources */, 369 | 3124948C24701BD300634933 /* KeyChainPasswordItem.swift in Sources */, 370 | ); 371 | runOnlyForDeploymentPostprocessing = 0; 372 | }; 373 | /* End PBXSourcesBuildPhase section */ 374 | 375 | /* Begin PBXVariantGroup section */ 376 | 319084C42454920900D47980 /* Main.storyboard */ = { 377 | isa = PBXVariantGroup; 378 | children = ( 379 | 319084C52454920900D47980 /* Base */, 380 | ); 381 | name = Main.storyboard; 382 | sourceTree = ""; 383 | }; 384 | /* End PBXVariantGroup section */ 385 | 386 | /* Begin XCBuildConfiguration section */ 387 | 319084C92454920900D47980 /* Debug */ = { 388 | isa = XCBuildConfiguration; 389 | baseConfigurationReference = F40B653D2C7E0D5B0079F743 /* OpenSource.xcconfig */; 390 | buildSettings = { 391 | ALWAYS_SEARCH_USER_PATHS = NO; 392 | CLANG_ANALYZER_NONNULL = YES; 393 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 394 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 395 | CLANG_CXX_LIBRARY = "libc++"; 396 | CLANG_ENABLE_MODULES = YES; 397 | CLANG_ENABLE_OBJC_ARC = YES; 398 | CLANG_ENABLE_OBJC_WEAK = YES; 399 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 400 | CLANG_WARN_BOOL_CONVERSION = YES; 401 | CLANG_WARN_COMMA = YES; 402 | CLANG_WARN_CONSTANT_CONVERSION = YES; 403 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 404 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 405 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 406 | CLANG_WARN_EMPTY_BODY = YES; 407 | CLANG_WARN_ENUM_CONVERSION = YES; 408 | CLANG_WARN_INFINITE_RECURSION = YES; 409 | CLANG_WARN_INT_CONVERSION = YES; 410 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 411 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 412 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 413 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 414 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 415 | CLANG_WARN_STRICT_PROTOTYPES = YES; 416 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 417 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 418 | CLANG_WARN_UNREACHABLE_CODE = YES; 419 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 420 | COPY_PHASE_STRIP = NO; 421 | DEBUG_INFORMATION_FORMAT = dwarf; 422 | ENABLE_STRICT_OBJC_MSGSEND = YES; 423 | ENABLE_TESTABILITY = YES; 424 | GCC_C_LANGUAGE_STANDARD = gnu11; 425 | GCC_DYNAMIC_NO_PIC = NO; 426 | GCC_NO_COMMON_BLOCKS = YES; 427 | GCC_OPTIMIZATION_LEVEL = 0; 428 | GCC_PREPROCESSOR_DEFINITIONS = ( 429 | "DEBUG=1", 430 | "$(inherited)", 431 | ); 432 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 433 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 434 | GCC_WARN_UNDECLARED_SELECTOR = YES; 435 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 436 | GCC_WARN_UNUSED_FUNCTION = YES; 437 | GCC_WARN_UNUSED_VARIABLE = YES; 438 | MACOSX_DEPLOYMENT_TARGET = 10.15; 439 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 440 | MTL_FAST_MATH = YES; 441 | ONLY_ACTIVE_ARCH = YES; 442 | SDKROOT = macosx; 443 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 444 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 445 | }; 446 | name = Debug; 447 | }; 448 | 319084CA2454920900D47980 /* Release */ = { 449 | isa = XCBuildConfiguration; 450 | baseConfigurationReference = F40B653D2C7E0D5B0079F743 /* OpenSource.xcconfig */; 451 | buildSettings = { 452 | ALWAYS_SEARCH_USER_PATHS = NO; 453 | CLANG_ANALYZER_NONNULL = YES; 454 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 455 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 456 | CLANG_CXX_LIBRARY = "libc++"; 457 | CLANG_ENABLE_MODULES = YES; 458 | CLANG_ENABLE_OBJC_ARC = YES; 459 | CLANG_ENABLE_OBJC_WEAK = YES; 460 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 461 | CLANG_WARN_BOOL_CONVERSION = YES; 462 | CLANG_WARN_COMMA = YES; 463 | CLANG_WARN_CONSTANT_CONVERSION = YES; 464 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 465 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 466 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 467 | CLANG_WARN_EMPTY_BODY = YES; 468 | CLANG_WARN_ENUM_CONVERSION = YES; 469 | CLANG_WARN_INFINITE_RECURSION = YES; 470 | CLANG_WARN_INT_CONVERSION = YES; 471 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 472 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 473 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 474 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 475 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 476 | CLANG_WARN_STRICT_PROTOTYPES = YES; 477 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 478 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 479 | CLANG_WARN_UNREACHABLE_CODE = YES; 480 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 481 | COPY_PHASE_STRIP = NO; 482 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 483 | ENABLE_NS_ASSERTIONS = NO; 484 | ENABLE_STRICT_OBJC_MSGSEND = YES; 485 | GCC_C_LANGUAGE_STANDARD = gnu11; 486 | GCC_NO_COMMON_BLOCKS = YES; 487 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 488 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 489 | GCC_WARN_UNDECLARED_SELECTOR = YES; 490 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 491 | GCC_WARN_UNUSED_FUNCTION = YES; 492 | GCC_WARN_UNUSED_VARIABLE = YES; 493 | MACOSX_DEPLOYMENT_TARGET = 10.15; 494 | MTL_ENABLE_DEBUG_INFO = NO; 495 | MTL_FAST_MATH = YES; 496 | SDKROOT = macosx; 497 | SWIFT_COMPILATION_MODE = wholemodule; 498 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 499 | }; 500 | name = Release; 501 | }; 502 | 319084CC2454920900D47980 /* Debug */ = { 503 | isa = XCBuildConfiguration; 504 | buildSettings = { 505 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 506 | CLANG_ENABLE_MODULES = YES; 507 | CODE_SIGN_ENTITLEMENTS = PiHoleStats/PiHoleStats.entitlements; 508 | CODE_SIGN_IDENTITY = "Apple Development"; 509 | CODE_SIGN_STYLE = Automatic; 510 | COMBINE_HIDPI_IMAGES = YES; 511 | CURRENT_PROJECT_VERSION = 19; 512 | DEVELOPMENT_ASSET_PATHS = "\"PiHoleStats/Preview Content\""; 513 | ENABLE_HARDENED_RUNTIME = YES; 514 | ENABLE_PREVIEWS = YES; 515 | INFOPLIST_FILE = PiHoleStats/Info.plist; 516 | LD_RUNPATH_SEARCH_PATHS = ( 517 | "$(inherited)", 518 | "@executable_path/../Frameworks", 519 | ); 520 | MACOSX_DEPLOYMENT_TARGET = 10.15; 521 | MARKETING_VERSION = 2.3.5; 522 | PRODUCT_BUNDLE_IDENTIFIER = "dev.bunn.holestats$(SAMPLE_CODE_DISAMBIGUATOR)"; 523 | PRODUCT_NAME = "Pi Stats"; 524 | PROVISIONING_PROFILE_SPECIFIER = ""; 525 | SWIFT_OBJC_BRIDGING_HEADER = "PiHoleStats/Util/PiHoleStats-Bridging-Header.h"; 526 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 527 | SWIFT_VERSION = 5.0; 528 | }; 529 | name = Debug; 530 | }; 531 | 319084CD2454920900D47980 /* Release */ = { 532 | isa = XCBuildConfiguration; 533 | buildSettings = { 534 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 535 | CLANG_ENABLE_MODULES = YES; 536 | CODE_SIGN_ENTITLEMENTS = PiHoleStats/PiHoleStats.entitlements; 537 | CODE_SIGN_IDENTITY = "Apple Development"; 538 | CODE_SIGN_STYLE = Automatic; 539 | COMBINE_HIDPI_IMAGES = YES; 540 | CURRENT_PROJECT_VERSION = 19; 541 | DEVELOPMENT_ASSET_PATHS = "\"PiHoleStats/Preview Content\""; 542 | ENABLE_HARDENED_RUNTIME = YES; 543 | ENABLE_PREVIEWS = YES; 544 | INFOPLIST_FILE = PiHoleStats/Info.plist; 545 | LD_RUNPATH_SEARCH_PATHS = ( 546 | "$(inherited)", 547 | "@executable_path/../Frameworks", 548 | ); 549 | MACOSX_DEPLOYMENT_TARGET = 10.15; 550 | MARKETING_VERSION = 2.3.5; 551 | PRODUCT_BUNDLE_IDENTIFIER = "dev.bunn.holestats$(SAMPLE_CODE_DISAMBIGUATOR)"; 552 | PRODUCT_NAME = "Pi Stats"; 553 | PROVISIONING_PROFILE_SPECIFIER = ""; 554 | SWIFT_OBJC_BRIDGING_HEADER = "PiHoleStats/Util/PiHoleStats-Bridging-Header.h"; 555 | SWIFT_VERSION = 5.0; 556 | }; 557 | name = Release; 558 | }; 559 | F40B65402C7E0DC60079F743 /* Debug-Private */ = { 560 | isa = XCBuildConfiguration; 561 | baseConfigurationReference = F40B653C2C7E0D5B0079F743 /* Main.xcconfig */; 562 | buildSettings = { 563 | ALWAYS_SEARCH_USER_PATHS = NO; 564 | CLANG_ANALYZER_NONNULL = YES; 565 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 566 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 567 | CLANG_CXX_LIBRARY = "libc++"; 568 | CLANG_ENABLE_MODULES = YES; 569 | CLANG_ENABLE_OBJC_ARC = YES; 570 | CLANG_ENABLE_OBJC_WEAK = YES; 571 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 572 | CLANG_WARN_BOOL_CONVERSION = YES; 573 | CLANG_WARN_COMMA = YES; 574 | CLANG_WARN_CONSTANT_CONVERSION = YES; 575 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 576 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 577 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 578 | CLANG_WARN_EMPTY_BODY = YES; 579 | CLANG_WARN_ENUM_CONVERSION = YES; 580 | CLANG_WARN_INFINITE_RECURSION = YES; 581 | CLANG_WARN_INT_CONVERSION = YES; 582 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 583 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 584 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 585 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 586 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 587 | CLANG_WARN_STRICT_PROTOTYPES = YES; 588 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 589 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 590 | CLANG_WARN_UNREACHABLE_CODE = YES; 591 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 592 | COPY_PHASE_STRIP = NO; 593 | DEBUG_INFORMATION_FORMAT = dwarf; 594 | ENABLE_STRICT_OBJC_MSGSEND = YES; 595 | ENABLE_TESTABILITY = YES; 596 | GCC_C_LANGUAGE_STANDARD = gnu11; 597 | GCC_DYNAMIC_NO_PIC = NO; 598 | GCC_NO_COMMON_BLOCKS = YES; 599 | GCC_OPTIMIZATION_LEVEL = 0; 600 | GCC_PREPROCESSOR_DEFINITIONS = ( 601 | "DEBUG=1", 602 | "$(inherited)", 603 | ); 604 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 605 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 606 | GCC_WARN_UNDECLARED_SELECTOR = YES; 607 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 608 | GCC_WARN_UNUSED_FUNCTION = YES; 609 | GCC_WARN_UNUSED_VARIABLE = YES; 610 | MACOSX_DEPLOYMENT_TARGET = 10.15; 611 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 612 | MTL_FAST_MATH = YES; 613 | ONLY_ACTIVE_ARCH = YES; 614 | SDKROOT = macosx; 615 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 616 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 617 | }; 618 | name = "Debug-Private"; 619 | }; 620 | F40B65412C7E0DC60079F743 /* Debug-Private */ = { 621 | isa = XCBuildConfiguration; 622 | buildSettings = { 623 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 624 | CLANG_ENABLE_MODULES = YES; 625 | CODE_SIGN_ENTITLEMENTS = PiHoleStats/PiHoleStats.entitlements; 626 | CODE_SIGN_IDENTITY = "Apple Development"; 627 | CODE_SIGN_STYLE = Automatic; 628 | COMBINE_HIDPI_IMAGES = YES; 629 | CURRENT_PROJECT_VERSION = 19; 630 | DEVELOPMENT_ASSET_PATHS = "\"PiHoleStats/Preview Content\""; 631 | ENABLE_HARDENED_RUNTIME = YES; 632 | ENABLE_PREVIEWS = YES; 633 | INFOPLIST_FILE = PiHoleStats/Info.plist; 634 | LD_RUNPATH_SEARCH_PATHS = ( 635 | "$(inherited)", 636 | "@executable_path/../Frameworks", 637 | ); 638 | MACOSX_DEPLOYMENT_TARGET = 10.15; 639 | MARKETING_VERSION = 2.3.5; 640 | PRODUCT_BUNDLE_IDENTIFIER = dev.bunn.holestats; 641 | PRODUCT_NAME = "Pi Stats"; 642 | PROVISIONING_PROFILE_SPECIFIER = ""; 643 | SWIFT_OBJC_BRIDGING_HEADER = "PiHoleStats/Util/PiHoleStats-Bridging-Header.h"; 644 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 645 | SWIFT_VERSION = 5.0; 646 | }; 647 | name = "Debug-Private"; 648 | }; 649 | F40B65422C7E0DCB0079F743 /* Release-Private */ = { 650 | isa = XCBuildConfiguration; 651 | baseConfigurationReference = F40B653C2C7E0D5B0079F743 /* Main.xcconfig */; 652 | buildSettings = { 653 | ALWAYS_SEARCH_USER_PATHS = NO; 654 | CLANG_ANALYZER_NONNULL = YES; 655 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 656 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 657 | CLANG_CXX_LIBRARY = "libc++"; 658 | CLANG_ENABLE_MODULES = YES; 659 | CLANG_ENABLE_OBJC_ARC = YES; 660 | CLANG_ENABLE_OBJC_WEAK = YES; 661 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 662 | CLANG_WARN_BOOL_CONVERSION = YES; 663 | CLANG_WARN_COMMA = YES; 664 | CLANG_WARN_CONSTANT_CONVERSION = YES; 665 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 666 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 667 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 668 | CLANG_WARN_EMPTY_BODY = YES; 669 | CLANG_WARN_ENUM_CONVERSION = YES; 670 | CLANG_WARN_INFINITE_RECURSION = YES; 671 | CLANG_WARN_INT_CONVERSION = YES; 672 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 673 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 674 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 675 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 676 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 677 | CLANG_WARN_STRICT_PROTOTYPES = YES; 678 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 679 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 680 | CLANG_WARN_UNREACHABLE_CODE = YES; 681 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 682 | COPY_PHASE_STRIP = NO; 683 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 684 | ENABLE_NS_ASSERTIONS = NO; 685 | ENABLE_STRICT_OBJC_MSGSEND = YES; 686 | GCC_C_LANGUAGE_STANDARD = gnu11; 687 | GCC_NO_COMMON_BLOCKS = YES; 688 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 689 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 690 | GCC_WARN_UNDECLARED_SELECTOR = YES; 691 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 692 | GCC_WARN_UNUSED_FUNCTION = YES; 693 | GCC_WARN_UNUSED_VARIABLE = YES; 694 | MACOSX_DEPLOYMENT_TARGET = 10.15; 695 | MTL_ENABLE_DEBUG_INFO = NO; 696 | MTL_FAST_MATH = YES; 697 | SDKROOT = macosx; 698 | SWIFT_COMPILATION_MODE = wholemodule; 699 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 700 | }; 701 | name = "Release-Private"; 702 | }; 703 | F40B65432C7E0DCB0079F743 /* Release-Private */ = { 704 | isa = XCBuildConfiguration; 705 | buildSettings = { 706 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 707 | CLANG_ENABLE_MODULES = YES; 708 | CODE_SIGN_ENTITLEMENTS = PiHoleStats/PiHoleStats.entitlements; 709 | CODE_SIGN_IDENTITY = "Apple Development"; 710 | CODE_SIGN_STYLE = Automatic; 711 | COMBINE_HIDPI_IMAGES = YES; 712 | CURRENT_PROJECT_VERSION = 19; 713 | DEVELOPMENT_ASSET_PATHS = "\"PiHoleStats/Preview Content\""; 714 | ENABLE_HARDENED_RUNTIME = YES; 715 | ENABLE_PREVIEWS = YES; 716 | INFOPLIST_FILE = PiHoleStats/Info.plist; 717 | LD_RUNPATH_SEARCH_PATHS = ( 718 | "$(inherited)", 719 | "@executable_path/../Frameworks", 720 | ); 721 | MACOSX_DEPLOYMENT_TARGET = 10.15; 722 | MARKETING_VERSION = 2.3.5; 723 | PRODUCT_BUNDLE_IDENTIFIER = dev.bunn.holestats; 724 | PRODUCT_NAME = "Pi Stats"; 725 | PROVISIONING_PROFILE_SPECIFIER = ""; 726 | SWIFT_OBJC_BRIDGING_HEADER = "PiHoleStats/Util/PiHoleStats-Bridging-Header.h"; 727 | SWIFT_VERSION = 5.0; 728 | }; 729 | name = "Release-Private"; 730 | }; 731 | /* End XCBuildConfiguration section */ 732 | 733 | /* Begin XCConfigurationList section */ 734 | 319084B32454920700D47980 /* Build configuration list for PBXProject "PiHoleStats" */ = { 735 | isa = XCConfigurationList; 736 | buildConfigurations = ( 737 | 319084C92454920900D47980 /* Debug */, 738 | F40B65402C7E0DC60079F743 /* Debug-Private */, 739 | 319084CA2454920900D47980 /* Release */, 740 | F40B65422C7E0DCB0079F743 /* Release-Private */, 741 | ); 742 | defaultConfigurationIsVisible = 0; 743 | defaultConfigurationName = Release; 744 | }; 745 | 319084CB2454920900D47980 /* Build configuration list for PBXNativeTarget "PiHoleStats" */ = { 746 | isa = XCConfigurationList; 747 | buildConfigurations = ( 748 | 319084CC2454920900D47980 /* Debug */, 749 | F40B65412C7E0DC60079F743 /* Debug-Private */, 750 | 319084CD2454920900D47980 /* Release */, 751 | F40B65432C7E0DCB0079F743 /* Release-Private */, 752 | ); 753 | defaultConfigurationIsVisible = 0; 754 | defaultConfigurationName = Release; 755 | }; 756 | /* End XCConfigurationList section */ 757 | 758 | /* Begin XCRemoteSwiftPackageReference section */ 759 | 3114423F24732D9D00042625 /* XCRemoteSwiftPackageReference "SwiftHole" */ = { 760 | isa = XCRemoteSwiftPackageReference; 761 | repositoryURL = "git@github.com:Bunn/SwiftHole.git"; 762 | requirement = { 763 | kind = upToNextMajorVersion; 764 | minimumVersion = 3.0.0; 765 | }; 766 | }; 767 | 31653446248C261B00733357 /* XCRemoteSwiftPackageReference "Preferences" */ = { 768 | isa = XCRemoteSwiftPackageReference; 769 | repositoryURL = "https://github.com/sindresorhus/Preferences"; 770 | requirement = { 771 | kind = upToNextMajorVersion; 772 | minimumVersion = 2.0.0; 773 | }; 774 | }; 775 | /* End XCRemoteSwiftPackageReference section */ 776 | 777 | /* Begin XCSwiftPackageProductDependency section */ 778 | 3114424024732D9D00042625 /* SwiftHole */ = { 779 | isa = XCSwiftPackageProductDependency; 780 | package = 3114423F24732D9D00042625 /* XCRemoteSwiftPackageReference "SwiftHole" */; 781 | productName = SwiftHole; 782 | }; 783 | 31653447248C261B00733357 /* Preferences */ = { 784 | isa = XCSwiftPackageProductDependency; 785 | package = 31653446248C261B00733357 /* XCRemoteSwiftPackageReference "Preferences" */; 786 | productName = Preferences; 787 | }; 788 | /* End XCSwiftPackageProductDependency section */ 789 | }; 790 | rootObject = 319084B02454920700D47980 /* Project object */; 791 | } 792 | -------------------------------------------------------------------------------- /PiHoleStats.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PiHoleStats.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PiHoleStats.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "pins" : [ 3 | { 4 | "identity" : "preferences", 5 | "kind" : "remoteSourceControl", 6 | "location" : "https://github.com/sindresorhus/Preferences", 7 | "state" : { 8 | "revision" : "dfb7457dc26891b0e9eb55d602f49c54b8e771fd", 9 | "version" : "2.0.1" 10 | } 11 | }, 12 | { 13 | "identity" : "swifthole", 14 | "kind" : "remoteSourceControl", 15 | "location" : "git@github.com:Bunn/SwiftHole.git", 16 | "state" : { 17 | "revision" : "554d7977ba771157c0a7c7197399763a9a5ecad6", 18 | "version" : "3.0.0" 19 | } 20 | } 21 | ], 22 | "version" : 2 23 | } 24 | -------------------------------------------------------------------------------- /PiHoleStats/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 25/04/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | var window: NSWindow! 14 | let menuController = MenuController() 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | DataMigrationManager().migrateIfNecessary() 18 | menuController.setup() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "scale" : "1x", 6 | "size" : "16x16" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "2x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "1x", 16 | "size" : "32x32" 17 | }, 18 | { 19 | "filename" : "icon-64.png", 20 | "idiom" : "mac", 21 | "scale" : "2x", 22 | "size" : "32x32" 23 | }, 24 | { 25 | "filename" : "icon-128.png", 26 | "idiom" : "mac", 27 | "scale" : "1x", 28 | "size" : "128x128" 29 | }, 30 | { 31 | "filename" : "icon-257.png", 32 | "idiom" : "mac", 33 | "scale" : "2x", 34 | "size" : "128x128" 35 | }, 36 | { 37 | "filename" : "icon-256.png", 38 | "idiom" : "mac", 39 | "scale" : "1x", 40 | "size" : "256x256" 41 | }, 42 | { 43 | "filename" : "icon-513.png", 44 | "idiom" : "mac", 45 | "scale" : "2x", 46 | "size" : "256x256" 47 | }, 48 | { 49 | "filename" : "icon-512.png", 50 | "idiom" : "mac", 51 | "scale" : "1x", 52 | "size" : "512x512" 53 | }, 54 | { 55 | "filename" : "icon-1024.png", 56 | "idiom" : "mac", 57 | "scale" : "2x", 58 | "size" : "512x512" 59 | } 60 | ], 61 | "info" : { 62 | "author" : "xcode", 63 | "version" : 1 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-1024.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-128.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-256.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-257.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-257.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-512.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-513.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-513.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/AppIcon.appiconset/icon-64.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/disabled.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.224", 9 | "green" : "0.294", 10 | "red" : "0.867" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/domainBlocked.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "57", 9 | "green" : "75", 10 | "red" : "221" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/enabled.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.196", 9 | "green" : "0.651", 10 | "red" : "0.004" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/enabledAndDisabled.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "0.071", 9 | "green" : "0.612", 10 | "red" : "0.953" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/globe.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "globe.pdf", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/globe.imageset/globe.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/globe.imageset/globe.pdf -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/percentBlocked.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "18", 9 | "green" : "156", 10 | "red" : "243" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/qrcode.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "qrcode.pdf", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/qrcode.imageset/qrcode.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/qrcode.imageset/qrcode.pdf -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/queryBlocked.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "239", 9 | "green" : "192", 10 | "red" : "0" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/shield.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "shield.pdf", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "author" : "xcode", 19 | "version" : 1 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/shield.imageset/shield.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/shield.imageset/shield.pdf -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/shieldIcon.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "filename" : "shieldIcon.png", 5 | "idiom" : "universal", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "filename" : "shieldIcon@2x.png", 10 | "idiom" : "universal", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "scale" : "3x" 16 | } 17 | ], 18 | "info" : { 19 | "author" : "xcode", 20 | "version" : 1 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/shieldIcon.imageset/shieldIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/shieldIcon.imageset/shieldIcon.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/shieldIcon.imageset/shieldIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/PiHoleStats/Assets.xcassets/shieldIcon.imageset/shieldIcon@2x.png -------------------------------------------------------------------------------- /PiHoleStats/Assets.xcassets/totalQuery.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "color" : { 5 | "color-space" : "srgb", 6 | "components" : { 7 | "alpha" : "1.000", 8 | "blue" : "50", 9 | "green" : "166", 10 | "red" : "1" 11 | } 12 | }, 13 | "idiom" : "universal" 14 | } 15 | ], 16 | "info" : { 17 | "author" : "xcode", 18 | "version" : 1 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | Default 529 | 530 | 531 | 532 | 533 | 534 | 535 | Left to Right 536 | 537 | 538 | 539 | 540 | 541 | 542 | Right to Left 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | Default 554 | 555 | 556 | 557 | 558 | 559 | 560 | Left to Right 561 | 562 | 563 | 564 | 565 | 566 | 567 | Right to Left 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | -------------------------------------------------------------------------------- /PiHoleStats/Config/Main.xcconfig: -------------------------------------------------------------------------------- 1 | // If you see this error: "could not find included file 'TeamID.xcconfig' in search paths" 2 | // Make sure you have run the bootstrap script from the project's root directory to set up signing for your team ID. 3 | // You may need to close and re-open the project after doing so. 4 | #include "TeamID.xcconfig" 5 | 6 | CODE_SIGN_STYLE = Automatic 7 | -------------------------------------------------------------------------------- /PiHoleStats/Config/OpenSource.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Main.xcconfig" 2 | 3 | // Once you set your project's development team, 4 | // you'll have a unique bundle identifier. This is because the bundle identifier 5 | // is derived based on the 'SAMPLE_CODE_DISAMBIGUATOR' value. 6 | SAMPLE_CODE_DISAMBIGUATOR=${DEVELOPMENT_TEAM} 7 | -------------------------------------------------------------------------------- /PiHoleStats/Controllers/MenuController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuController.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 22/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import Combine 11 | 12 | class MenuController: NSObject { 13 | 14 | private lazy var popover = NSPopover() 15 | private let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength) 16 | private let preferences = UserPreferences() 17 | private lazy var navigationController = NavigationController(preferences: preferences, piholeDataProvider: dataProvider) 18 | private lazy var dataProvider = PiholeDataProvider(piholes: Pihole.restoreAll()) 19 | private lazy var summaryViewController = SummaryViewController(preferences: preferences, piHoleDataProvider: dataProvider, navigationController: navigationController) 20 | private var eventMonitor: EventMonitor? 21 | private var eventCancellable: AnyCancellable? 22 | private var statusPreferenceCancellable: AnyCancellable? 23 | private var statusCancellable: AnyCancellable? 24 | private lazy var iconStatusBadgeView: NSView = { 25 | let v = NSView(frame: .zero) 26 | v.wantsLayer = true 27 | return v 28 | }() 29 | 30 | private var buttonImage: NSImage? { 31 | let image = NSImage(named: .init("shield")) 32 | image?.isTemplate = true 33 | return image 34 | } 35 | 36 | public func setup() { 37 | updateButton() 38 | popover.contentViewController = summaryViewController 39 | setupEventMonitor() 40 | dataProvider.startPolling() 41 | dataProvider.updatePollingMode(.background) 42 | updateButtonStatus() 43 | setupCancellables() 44 | } 45 | 46 | private func setupCancellables() { 47 | eventCancellable = preferences.$keepPopoverPanelOpen.receive(on: DispatchQueue.main).sink { [weak self] keepPopoverOpen in 48 | if keepPopoverOpen { 49 | self?.eventMonitor?.stop() 50 | } else { 51 | self?.eventMonitor?.start() 52 | } 53 | } 54 | statusPreferenceCancellable = preferences.$displayStatusColorWhenPiholeIsOffline.receive(on: DispatchQueue.main).sink { [weak self] _ in 55 | self?.updateButtonStatus() 56 | } 57 | 58 | statusCancellable = dataProvider.$status.receive(on: DispatchQueue.main).sink { [weak self] _ in 59 | self?.updateButtonStatus() 60 | } 61 | } 62 | 63 | private func setupEventMonitor() { 64 | eventMonitor = EventMonitor(mask: [.leftMouseDown, .rightMouseDown]) { [weak self] event in 65 | if let strongSelf = self, strongSelf.popover.isShown { 66 | strongSelf.closePopover(sender: event) 67 | } 68 | } 69 | } 70 | 71 | private func destroyEventMonitor() { 72 | eventMonitor?.stop() 73 | eventMonitor = nil 74 | } 75 | 76 | private func updateButtonStatus() { 77 | if !preferences.displayStatusColorWhenPiholeIsOffline || dataProvider.status == .allEnabled { 78 | iconStatusBadgeView.removeFromSuperview() 79 | return 80 | } 81 | 82 | guard let button = statusItem.button else { return } 83 | let size: CGFloat = 6 84 | let badgeX = (button.frame.width / 2) - (size / 2) 85 | let badgeY = (button.frame.height / 2) - (size / 2) 86 | iconStatusBadgeView.frame = NSRect(x: badgeX, y: badgeY, width: size, height: size) 87 | iconStatusBadgeView.layer?.cornerRadius = size / 2 88 | if dataProvider.status == .allDisabled { 89 | iconStatusBadgeView.layer?.backgroundColor = UIConstants.NSColors.disabled?.cgColor 90 | } else if dataProvider.status == .enabledAndDisabled { 91 | iconStatusBadgeView.layer?.backgroundColor = UIConstants.NSColors.enabledAndDisabled?.cgColor 92 | } 93 | 94 | button.addSubview(iconStatusBadgeView) 95 | } 96 | 97 | private func updateButton() { 98 | guard let button = statusItem.button else { return } 99 | button.image = buttonImage 100 | button.image?.size = NSSize(width: 20, height: 20) 101 | button.action = #selector(togglePopover) 102 | button.target = self 103 | } 104 | 105 | @objc private func togglePopover(_ sender: Any?) { 106 | if popover.isShown { 107 | closePopover(sender: sender) 108 | } else { 109 | showPopover(sender: sender) 110 | } 111 | } 112 | 113 | private func showPopover(sender: Any?) { 114 | guard let button = statusItem.button else { return } 115 | if !preferences.keepPopoverPanelOpen { 116 | eventMonitor?.start() 117 | } 118 | 119 | popover.show( 120 | relativeTo: button.bounds, 121 | of: button, 122 | preferredEdge: NSRectEdge.minY 123 | ) 124 | dataProvider.updatePollingMode(.foreground) 125 | } 126 | 127 | private func closePopover(sender: Any?) { 128 | popover.performClose(sender) 129 | eventMonitor?.stop() 130 | dataProvider.updatePollingMode(.background) 131 | 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /PiHoleStats/Controllers/NavigationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 22/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | class NavigationController: ObservableObject { 12 | private var windowController: NSWindowController? 13 | let preferences: UserPreferences 14 | let piholeDataProvider: PiholeDataProvider 15 | 16 | init(preferences: UserPreferences, piholeDataProvider: PiholeDataProvider) { 17 | self.preferences = preferences 18 | self.piholeDataProvider = piholeDataProvider 19 | } 20 | 21 | public func openPreferences() { 22 | NSApp.activate(ignoringOtherApps: true) 23 | 24 | let controller = PreferencesViewController(preferences: preferences, piholeListViewModel: PiholeListViewModel(piholeDataProvider: piholeDataProvider)) 25 | controller.show() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /PiHoleStats/Core/Pihole.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PiHole.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 24/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SwiftHole 11 | import os.log 12 | 13 | class Pihole: Identifiable, Codable, ObservableObject { 14 | private let log = Logger().osLog(describing: Pihole.self) 15 | var address: String 16 | var secure: Bool 17 | var actionError: String? 18 | var pollingError: String? 19 | let id: UUID 20 | private(set) var summary: Summary? { 21 | didSet { 22 | if summary?.status.lowercased() == "enabled" { 23 | active = true 24 | os_log("%@ summary has enabled status", log: self.log, type: .debug, address) 25 | } else { 26 | active = false 27 | os_log("%@ summary has disabled status", log: self.log, type: .debug, address) 28 | } 29 | } 30 | } 31 | private(set) var active = false 32 | 33 | private lazy var keychainToken = APIToken(accountName: self.id.uuidString) 34 | var apiToken: String { 35 | get { 36 | keychainToken.token 37 | } 38 | set { 39 | keychainToken.token = newValue 40 | } 41 | } 42 | 43 | var port: Int? { 44 | getPort(address) 45 | } 46 | 47 | var host: String { 48 | address.components(separatedBy: ":").first ?? "" 49 | } 50 | 51 | private var service: SwiftHole { 52 | SwiftHole(host: host, port: port, apiToken: apiToken, secure: secure) 53 | } 54 | 55 | enum CodingKeys: CodingKey { 56 | case id 57 | case address 58 | case secure 59 | } 60 | 61 | required init(from decoder: Decoder) throws { 62 | let container = try decoder.container(keyedBy: CodingKeys.self) 63 | id = try container.decode(UUID.self, forKey: .id) 64 | address = try container.decode(String.self, forKey: .address) 65 | 66 | //New properties that might break decoded from older versions 67 | do { 68 | secure = try container.decode(Bool.self, forKey: .secure) 69 | } catch { 70 | secure = false 71 | } 72 | } 73 | 74 | func encode(to encoder: Encoder) throws { 75 | var container = encoder.container(keyedBy: CodingKeys.self) 76 | try container.encode(id, forKey: .id) 77 | try container.encode(address, forKey: .address) 78 | try container.encode(secure, forKey: .secure) 79 | } 80 | 81 | public init(address: String, apiToken: String? = nil, piHoleID: UUID? = nil, secure: Bool = false) { 82 | self.address = address 83 | self.secure = secure 84 | 85 | if let piHoleID = piHoleID { 86 | self.id = piHoleID 87 | } else { 88 | self.id = UUID() 89 | } 90 | 91 | if let apiToken = apiToken { 92 | keychainToken.token = apiToken 93 | } 94 | } 95 | 96 | private func getPort(_ address: String) -> Int? { 97 | let split = address.components(separatedBy: ":") 98 | guard let port = split.last else { return nil } 99 | return Int(port) 100 | } 101 | } 102 | 103 | // MARK: Network Methods 104 | 105 | extension Pihole { 106 | public func updateSummary(completion: @escaping (SwiftHoleError?) -> Void) { 107 | service.fetchSummary { result in 108 | switch result { 109 | case .success(let summary): 110 | self.summary = summary 111 | completion(nil) 112 | case .failure(let error): 113 | self.summary = nil 114 | completion(error) 115 | } 116 | } 117 | } 118 | 119 | public func enablePiHole(completion: @escaping (Result) -> Void) { 120 | service.enablePiHole { result in 121 | switch result { 122 | case .success: 123 | self.active = true 124 | os_log("%@ enable request success", log: self.log, type: .debug, self.address) 125 | completion(result) 126 | case .failure: 127 | os_log("%@ enable request failure", log: self.log, type: .debug, self.address) 128 | completion(result) 129 | } 130 | } 131 | } 132 | 133 | public func disablePiHole(seconds: Int = 0, completion: @escaping (Result) -> Void) { 134 | service.disablePiHole(seconds: seconds) { result in 135 | switch result { 136 | case .success: 137 | self.active = false 138 | os_log("%@ disable request success", log: self.log, type: .debug, self.address) 139 | completion(result) 140 | case .failure: 141 | os_log("%@ disable request failure", log: self.log, type: .debug, self.address) 142 | completion(result) 143 | } 144 | } 145 | } 146 | } 147 | 148 | // MARK: I/O Methods 149 | 150 | extension Pihole { 151 | private static let piHoleListKey = "PiHoleStatsPiHoleList" 152 | 153 | public func delete() { 154 | var piholeList = Pihole.restoreAll() 155 | 156 | if let index = piholeList.firstIndex(of: self) { 157 | piholeList.remove(at: index) 158 | } 159 | save(piholeList) 160 | self.keychainToken.delete() 161 | } 162 | 163 | public func save() { 164 | var piholeList = Pihole.restoreAll() 165 | if let index = piholeList.firstIndex(where: { $0.id == self.id }) { 166 | piholeList[index] = self 167 | } else { 168 | piholeList.append(self) 169 | } 170 | save(piholeList) 171 | } 172 | 173 | private func save(_ list: [Pihole]) { 174 | let encoder = JSONEncoder() 175 | if let encoded = try? encoder.encode(list) { 176 | let defaults = UserDefaults.standard 177 | defaults.set(encoded, forKey: Pihole.piHoleListKey) 178 | } 179 | } 180 | 181 | static func restoreAll() -> [Pihole] { 182 | if let piHoleList = UserDefaults.standard.object(forKey: Pihole.piHoleListKey) as? Data { 183 | let decoder = JSONDecoder() 184 | 185 | if let list = try? decoder.decode([Pihole].self, from: piHoleList) { 186 | return list 187 | } else { 188 | return [Pihole]() 189 | } 190 | } else { 191 | return [Pihole]() 192 | } 193 | } 194 | 195 | static func restore(_ uuid: UUID) -> Pihole? { 196 | return Pihole.restoreAll().filter { $0.id == uuid }.first 197 | } 198 | } 199 | 200 | extension Pihole: Hashable { 201 | static func == (lhs: Pihole, rhs: Pihole) -> Bool { 202 | return lhs.id == rhs.id 203 | } 204 | 205 | func hash(into hasher: inout Hasher) { 206 | hasher.combine(id) 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /PiHoleStats/Core/PiholeDataProvider.swift: -------------------------------------------------------------------------------- 1 | // 2 | // piholeservice.swift 3 | // piholestats 4 | // 5 | // Created by Fernando Bunn on 24/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SwiftHole 11 | import SwiftUI 12 | 13 | class PiholeDataProvider: ObservableObject { 14 | enum PiholeStatus { 15 | case allEnabled 16 | case allDisabled 17 | case enabledAndDisabled 18 | } 19 | 20 | enum PollingMode { 21 | case foreground 22 | case background 23 | } 24 | 25 | private(set) var pollingTimeInterval: TimeInterval = 3 26 | private var timer: Timer? 27 | private(set) var piholes: [Pihole] 28 | @Published private(set) var totalQueries = "" 29 | @Published private(set) var queriesBlocked = "" 30 | @Published private(set) var percentBlocked = "" 31 | @Published private(set) var domainsOnBlocklist = "" 32 | @Published private(set) var hasErrorMessages = false 33 | @Published private(set) var status: PiholeStatus = .allDisabled 34 | 35 | var canDisplayEnableDisableButton: Bool { 36 | return !piholes.allSatisfy { 37 | return $0.apiToken.isEmpty == true 38 | } 39 | } 40 | 41 | var changeStatusButtonTitle: String { 42 | if status != .allDisabled { 43 | return UIConstants.Strings.buttonDisable 44 | } else { 45 | return UIConstants.Strings.buttonEnable 46 | } 47 | } 48 | 49 | var statusColor: Color { 50 | if hasErrorMessages { 51 | return UIConstants.Colors.enabledAndDisabled 52 | } 53 | switch status { 54 | case .allDisabled: 55 | return UIConstants.Colors.disabled 56 | case .allEnabled: 57 | return UIConstants.Colors.enabled 58 | case .enabledAndDisabled: 59 | return UIConstants.Colors.enabledAndDisabled 60 | } 61 | } 62 | 63 | var statusText: String { 64 | if hasErrorMessages { 65 | return UIConstants.Strings.statusNeedsAttention 66 | } 67 | switch status { 68 | case .allDisabled: 69 | return UIConstants.Strings.statusDisabled 70 | case .allEnabled: 71 | return UIConstants.Strings.statusEnabled 72 | case .enabledAndDisabled: 73 | return UIConstants.Strings.statusEnabledAndDisabled 74 | } 75 | } 76 | 77 | private lazy var percentageFormatter: NumberFormatter = { 78 | let n = NumberFormatter() 79 | n.numberStyle = .percent 80 | n.minimumFractionDigits = 2 81 | n.maximumFractionDigits = 2 82 | return n 83 | }() 84 | 85 | private lazy var numberFormatter: NumberFormatter = { 86 | let n = NumberFormatter() 87 | n.numberStyle = .decimal 88 | n.maximumFractionDigits = 0 89 | return n 90 | }() 91 | 92 | init(piholes: [Pihole]) { 93 | self.piholes = piholes 94 | } 95 | 96 | func updatePollingMode(_ pollingMode: PollingMode) { 97 | switch pollingMode { 98 | case .background: 99 | pollingTimeInterval = 10 100 | case .foreground: 101 | pollingTimeInterval = 3 102 | } 103 | startPolling() 104 | } 105 | 106 | func startPolling() { 107 | self.fetchSummaryData() 108 | timer?.invalidate() 109 | timer = Timer.scheduledTimer(withTimeInterval: pollingTimeInterval, repeats: true) { _ in 110 | self.fetchSummaryData() 111 | } 112 | } 113 | 114 | func stopPolling() { 115 | timer?.invalidate() 116 | } 117 | 118 | func resetErrorMessage() { 119 | piholes.forEach { pihole in 120 | pihole.actionError = nil 121 | pihole.pollingError = nil 122 | } 123 | updateErrorMessageStatus() 124 | } 125 | 126 | func add(_ pihole: Pihole) { 127 | objectWillChange.send() 128 | piholes.append(pihole) 129 | updateStatus() 130 | updateErrorMessageStatus() 131 | 132 | } 133 | 134 | func remove(_ pihole: Pihole) { 135 | objectWillChange.send() 136 | if let index = piholes.firstIndex(of: pihole) { 137 | piholes.remove(at: index) 138 | } 139 | updateStatus() 140 | updateErrorMessageStatus() 141 | } 142 | 143 | func disablePiHole(seconds: Int = 0) { 144 | piholes.forEach { pihole in 145 | pihole.disablePiHole(seconds: seconds) { result in 146 | DispatchQueue.main.async { 147 | switch result { 148 | case .success: 149 | self.updateStatus() 150 | pihole.actionError = nil 151 | case .failure(let error): 152 | pihole.actionError = self.errorMessage(error) 153 | } 154 | } 155 | } 156 | } 157 | } 158 | 159 | func enablePiHole() { 160 | piholes.forEach { pihole in 161 | pihole.enablePiHole { result in 162 | DispatchQueue.main.async { 163 | switch result { 164 | case .success: 165 | self.updateStatus() 166 | pihole.actionError = nil 167 | case .failure(let error): 168 | pihole.actionError = self.errorMessage(error) 169 | } 170 | } 171 | } 172 | } 173 | } 174 | 175 | private func errorMessage(_ error: SwiftHoleError) -> String { 176 | switch error { 177 | case .malformedURL: 178 | return UIConstants.Strings.Error.invalidURL 179 | case .invalidDecode(let decodeError): 180 | return "\(UIConstants.Strings.Error.decodeResponseError): \(decodeError.localizedDescription)" 181 | case .noAPITokenProvided: 182 | return UIConstants.Strings.Error.noAPITokenProvided 183 | case .sessionError(let sessionError): 184 | return "\(UIConstants.Strings.Error.sessionError): \(sessionError.localizedDescription)" 185 | case .invalidResponseCode(let responseCode): 186 | return "\(UIConstants.Strings.Error.sessionError): \(responseCode)" 187 | case .invalidResponse: 188 | return UIConstants.Strings.Error.invalidResponse 189 | case .invalidAPIToken: 190 | return UIConstants.Strings.Error.invalidAPIToken 191 | case .cantAddNewListItem: 192 | return UIConstants.Strings.Error.cantAddNewItem 193 | } 194 | } 195 | 196 | private func fetchSummaryData() { 197 | piholes.forEach { pihole in 198 | pihole.updateSummary { error in 199 | DispatchQueue.main.async { 200 | if let error = error { 201 | pihole.pollingError = self.errorMessage(error) 202 | } else { 203 | self.updateData() 204 | pihole.pollingError = nil 205 | } 206 | } 207 | } 208 | } 209 | } 210 | 211 | private func updateData() { 212 | let sumDNSQueries = piholes.compactMap { $0.summary }.reduce(0) { value, pihole in value + pihole.dnsQueriesToday } 213 | totalQueries = numberFormatter.string(from: NSNumber(value: sumDNSQueries)) ?? "-" 214 | 215 | let sumQueriesBlocked = piholes.compactMap { $0.summary }.reduce(0) { value, pihole in value + pihole.adsBlockedToday } 216 | queriesBlocked = numberFormatter.string(from: NSNumber(value: sumQueriesBlocked)) ?? "-" 217 | 218 | let sumDomainOnBlocklist = piholes.compactMap { $0.summary }.reduce(0) { value, pihole in value + pihole.domainsBeingBlocked } 219 | domainsOnBlocklist = numberFormatter.string(from: NSNumber(value: sumDomainOnBlocklist)) ?? "-" 220 | 221 | let percentage = Double(sumQueriesBlocked) / Double(sumDNSQueries) 222 | percentBlocked = percentageFormatter.string(from: NSNumber(value: percentage)) ?? "-" 223 | 224 | updateStatus() 225 | updateErrorMessageStatus() 226 | } 227 | 228 | private func updateStatus() { 229 | let allStatus = Set(piholes.map { $0.active }) 230 | if allStatus.count > 1 { 231 | status = .enabledAndDisabled 232 | } else if allStatus.randomElement() == false { 233 | status = .allDisabled 234 | } else { 235 | status = .allEnabled 236 | } 237 | } 238 | 239 | private func updateErrorMessageStatus() { 240 | hasErrorMessages = !piholes.allSatisfy { $0.pollingError == nil && $0.actionError == nil} 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /PiHoleStats/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | $(MARKETING_VERSION) 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | ITSAppUsesNonExemptEncryption 24 | 25 | LSApplicationCategoryType 26 | public.app-category.utilities 27 | LSMinimumSystemVersion 28 | $(MACOSX_DEPLOYMENT_TARGET) 29 | LSUIElement 30 | 31 | NSAppTransportSecurity 32 | 33 | NSAllowsArbitraryLoads 34 | 35 | 36 | NSHumanReadableCopyright 37 | Copyright © 2020 Fernando Bunn. All rights reserved. 38 | NSMainStoryboardFile 39 | Main 40 | NSPrincipalClass 41 | NSApplication 42 | NSSupportsAutomaticTermination 43 | 44 | NSSupportsSuddenTermination 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /PiHoleStats/Model/APIToken.swift: -------------------------------------------------------------------------------- 1 | // 2 | // APIToken.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 16/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct APIToken { 12 | internal init(accountName: String) { 13 | self.accountName = accountName 14 | self.passwordItem = KeychainPasswordItem(service: APIToken.serviceName, account: accountName, accessGroup: nil) 15 | } 16 | 17 | private static let serviceName = "PiHoleStatsService" 18 | let accountName: String 19 | 20 | private let passwordItem: KeychainPasswordItem 21 | 22 | public var token: String { 23 | get { 24 | do { 25 | return try passwordItem.readPassword() 26 | } catch { 27 | return "" 28 | } 29 | } 30 | 31 | set { 32 | /* 33 | It might error out when trying to delete during development because of digital signing changing 34 | which shouldn't be a problem on released version 35 | https://forums.developer.apple.com/thread/69841 36 | */ 37 | try? passwordItem.savePassword(newValue) 38 | if newValue.isEmpty { 39 | delete() 40 | } 41 | } 42 | } 43 | 44 | public func delete() { 45 | do { 46 | try passwordItem.deleteItem() 47 | } catch { 48 | print("Keychain delete error \(error)") 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /PiHoleStats/Model/UserPreferences.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Settings.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 11/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Combine 11 | 12 | private enum PreferencesKey: String { 13 | case keepPopoverPanelOpen = "SettingsKeyKeepPopoverPanelOpen" 14 | case displayDisableTimeOptions = "SettingsDisplayDisableTimeOptions" 15 | case displayStatusColorWhenPiholeIsOffline = "SettingsDisplayStatusColorWhenPiholeIsOffline" 16 | case qrcodeFormat = "SettingsqrcodeFormat" 17 | 18 | } 19 | 20 | class UserPreferences: ObservableObject { 21 | enum QRCodeFormat: Int { 22 | case webInterface 23 | case piStats 24 | } 25 | 26 | var keychainToken = APIToken(accountName: "PiHoleStatsAccount") 27 | private var appURL: URL { Bundle.main.bundleURL } 28 | static let didChangeNotification = Notification.Name("dev.bunn.holestats.PrefsChanged") 29 | @Published private var _launchAtLoginEnabled: Bool = false 30 | 31 | init() { 32 | apiToken = keychainToken.token 33 | } 34 | 35 | @Published var keepPopoverPanelOpen: Bool = UserDefaults.standard.object(forKey: PreferencesKey.keepPopoverPanelOpen.rawValue) as? Bool ?? false { 36 | didSet { 37 | UserDefaults.standard.set(keepPopoverPanelOpen, forKey: PreferencesKey.keepPopoverPanelOpen.rawValue) 38 | } 39 | } 40 | 41 | @Published var displayDisableTimeOptions: Bool = UserDefaults.standard.object(forKey: PreferencesKey.displayDisableTimeOptions.rawValue) as? Bool ?? false { 42 | didSet { 43 | UserDefaults.standard.set(displayDisableTimeOptions, forKey: PreferencesKey.displayDisableTimeOptions.rawValue) 44 | } 45 | } 46 | 47 | @Published var qrcodeFormat: QRCodeFormat = UserDefaults.standard.object(forKey: PreferencesKey.qrcodeFormat.rawValue) as? QRCodeFormat ?? .webInterface { 48 | didSet { 49 | UserDefaults.standard.set(qrcodeFormat.rawValue, forKey: PreferencesKey.qrcodeFormat.rawValue) 50 | } 51 | } 52 | 53 | @Published var displayStatusColorWhenPiholeIsOffline: Bool = UserDefaults.standard.object(forKey: PreferencesKey.displayStatusColorWhenPiholeIsOffline.rawValue) as? Bool ?? false { 54 | didSet { 55 | UserDefaults.standard.set(displayStatusColorWhenPiholeIsOffline, forKey: PreferencesKey.displayStatusColorWhenPiholeIsOffline.rawValue) 56 | } 57 | } 58 | 59 | @Published var apiToken: String { 60 | didSet { 61 | keychainToken.token = apiToken 62 | } 63 | } 64 | 65 | var launchAtLoginEnabled: Bool { 66 | get { 67 | _launchAtLoginEnabled || SharedFileList.sessionLoginItems().containsItem(appURL) 68 | } 69 | set { 70 | _launchAtLoginEnabled = newValue 71 | 72 | if newValue { 73 | SharedFileList.sessionLoginItems().addItem(appURL) 74 | } else { 75 | SharedFileList.sessionLoginItems().removeItem(appURL) 76 | } 77 | 78 | didChange() 79 | } 80 | } 81 | 82 | private func didChange() { 83 | NotificationCenter.default.post(name: Self.didChangeNotification, object: self) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /PiHoleStats/PiHoleStats.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | com.apple.security.network.client 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /PiHoleStats/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /PiHoleStats/Util/DataMigrationManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DataMigrationManager.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 21/06/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import os.log 11 | 12 | struct DataMigrationManager { 13 | private let log = Logger().osLog(describing: DataMigrationManager.self) 14 | 15 | private let oldSettingsKeyHostToken = "SettingsKeyHost" 16 | private var oldPiholeHost: String? { 17 | guard let oldPiHoleHost = UserDefaults.standard.object(forKey: oldSettingsKeyHostToken) as? String else { 18 | return nil 19 | } 20 | if oldPiHoleHost.isEmpty { 21 | return nil 22 | } 23 | return oldPiHoleHost 24 | } 25 | 26 | func migrateIfNecessary() { 27 | if hasDataStoredInSinglePiholeFormat() { 28 | os_log("old pi-hole setup found, starting migration...", log: self.log, type: .debug) 29 | migrateFromSinglePiholeToMultiples() 30 | } 31 | } 32 | 33 | private func hasDataStoredInSinglePiholeFormat() -> Bool { 34 | return oldPiholeHost != nil 35 | } 36 | 37 | private func migrateFromSinglePiholeToMultiples() { 38 | guard let oldPiHoleHost = oldPiholeHost else { return } 39 | os_log("migrating old host %@", log: self.log, type: .debug, oldPiHoleHost) 40 | let pihole = Pihole(address: oldPiHoleHost) 41 | let passwordItem = KeychainPasswordItem(service: "PiHoleStatsService", account: "PiHoleStatsAccount", accessGroup: nil) 42 | if let token = try? passwordItem.readPassword() { 43 | pihole.apiToken = token 44 | } 45 | 46 | try? passwordItem.deleteItem() 47 | UserDefaults.standard.removeObject(forKey: oldSettingsKeyHostToken) 48 | pihole.save() 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /PiHoleStats/Util/EqualFrame.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EqualFrame.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 02/08/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | //Credits to: https://finestructure.co/blog/2020/1/20/swiftui-equal-widths-view-constraints 10 | import SwiftUI 11 | 12 | struct GeometryPreferenceReader where K.Value == V { 13 | let key: K.Type 14 | let value: (GeometryProxy) -> V 15 | } 16 | 17 | extension GeometryPreferenceReader: ViewModifier { 18 | func body(content: Content) -> some View { 19 | content 20 | .background(GeometryReader { 21 | Color.clear.preference(key: self.key, 22 | value: self.value($0)) 23 | }) 24 | } 25 | } 26 | 27 | protocol Preference {} 28 | 29 | struct AppendValue: PreferenceKey { 30 | static var defaultValue: [CGFloat] { [] } 31 | static func reduce(value: inout Value, nextValue: () -> Value) { 32 | value.append(contentsOf: nextValue()) 33 | } 34 | typealias Value = [CGFloat] 35 | } 36 | 37 | extension View { 38 | func assignMaxPreference( 39 | for key: K.Type, 40 | to binding: Binding) -> some View where K.Value == [CGFloat] { 41 | 42 | return self.onPreferenceChange(key.self) { prefs in 43 | let maxPref = prefs.reduce(0, max) 44 | if maxPref > 0 { 45 | // only set value if > 0 to avoid pinning sizes to zero 46 | binding.wrappedValue = maxPref 47 | } 48 | } 49 | } 50 | 51 | func read(_ preference: GeometryPreferenceReader) -> some View { 52 | modifier(preference) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /PiHoleStats/Util/EventMonitor.swift: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2017 Razeware LLC 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish, 15 | * distribute, sublicense, create a derivative work, and/or sell copies of the 16 | * Software in any work that is designed, intended, or marketed for pedagogical or 17 | * instructional purposes related to programming, coding, application development, 18 | * or information technology. Permission for such use, copying, modification, 19 | * merger, publication, distribution, sublicensing, creation of derivative works, 20 | * or sale is expressly withheld. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | * THE SOFTWARE. 29 | */ 30 | 31 | //https://www.raywenderlich.com/450-menus-and-popovers-in-menu-bar-apps-for-macos 32 | 33 | import Cocoa 34 | import os.log 35 | 36 | public class EventMonitor { 37 | private let log = Logger().osLog(describing: EventMonitor.self) 38 | private var monitor: Any? 39 | private let mask: NSEvent.EventTypeMask 40 | private let handler: (NSEvent?) -> Void 41 | 42 | public init(mask: NSEvent.EventTypeMask, handler: @escaping (NSEvent?) -> Void) { 43 | self.mask = mask 44 | self.handler = handler 45 | os_log("Event monitor init", log: self.log, type: .debug) 46 | } 47 | 48 | deinit { 49 | os_log("Event monitor deinit", log: self.log, type: .debug) 50 | stop() 51 | } 52 | 53 | public func start() { 54 | if monitor != nil { 55 | return 56 | } 57 | os_log("Event monitor start", log: self.log, type: .debug) 58 | monitor = NSEvent.addGlobalMonitorForEvents(matching: mask, handler: handler) 59 | } 60 | 61 | public func stop() { 62 | if monitor != nil { 63 | os_log("Event monitor stop", log: self.log, type: .debug) 64 | NSEvent.removeMonitor(monitor!) 65 | monitor = nil 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /PiHoleStats/Util/KeyChainPasswordItem.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2016 Apple Inc. All Rights Reserved. 3 | See LICENSE.txt for this sample’s licensing information 4 | 5 | Abstract: 6 | A struct for accessing generic password keychain items. 7 | */ 8 | 9 | import Foundation 10 | 11 | struct KeychainPasswordItem { 12 | // MARK: Types 13 | 14 | enum KeychainError: Error { 15 | case noPassword 16 | case unexpectedPasswordData 17 | case unexpectedItemData 18 | case unhandledError(status: OSStatus) 19 | } 20 | 21 | // MARK: Properties 22 | 23 | let service: String 24 | 25 | private(set) var account: String 26 | 27 | let accessGroup: String? 28 | 29 | // MARK: Intialization 30 | 31 | init(service: String, account: String, accessGroup: String? = nil) { 32 | self.service = service 33 | self.account = account 34 | self.accessGroup = accessGroup 35 | } 36 | 37 | // MARK: Keychain access 38 | 39 | func readPassword() throws -> String { 40 | /* 41 | Build a query to find the item that matches the service, account and 42 | access group. 43 | */ 44 | var query = KeychainPasswordItem.keychainQuery(withService: service, account: account, accessGroup: accessGroup) 45 | query[kSecMatchLimit as String] = kSecMatchLimitOne 46 | query[kSecReturnAttributes as String] = kCFBooleanTrue 47 | query[kSecReturnData as String] = kCFBooleanTrue 48 | 49 | // Try to fetch the existing keychain item that matches the query. 50 | var queryResult: AnyObject? 51 | let status = withUnsafeMutablePointer(to: &queryResult) { 52 | SecItemCopyMatching(query as CFDictionary, UnsafeMutablePointer($0)) 53 | } 54 | 55 | // Check the return status and throw an error if appropriate. 56 | guard status != errSecItemNotFound else { throw KeychainError.noPassword } 57 | guard status == noErr else { throw KeychainError.unhandledError(status: status) } 58 | 59 | // Parse the password string from the query result. 60 | guard let existingItem = queryResult as? [String: AnyObject], 61 | let passwordData = existingItem[kSecValueData as String] as? Data, 62 | let password = String(data: passwordData, encoding: String.Encoding.utf8) 63 | else { 64 | throw KeychainError.unexpectedPasswordData 65 | } 66 | 67 | return password 68 | } 69 | 70 | func savePassword(_ password: String) throws { 71 | // Encode the password into an Data object. 72 | let encodedPassword = password.data(using: String.Encoding.utf8)! 73 | 74 | do { 75 | // Check for an existing item in the keychain. 76 | try _ = readPassword() 77 | 78 | // Update the existing item with the new password. 79 | var attributesToUpdate = [String: AnyObject]() 80 | attributesToUpdate[kSecValueData as String] = encodedPassword as AnyObject? 81 | 82 | let query = KeychainPasswordItem.keychainQuery(withService: service, account: account, accessGroup: accessGroup) 83 | let status = SecItemUpdate(query as CFDictionary, attributesToUpdate as CFDictionary) 84 | 85 | // Throw an error if an unexpected status was returned. 86 | guard status == noErr else { throw KeychainError.unhandledError(status: status) } 87 | } catch KeychainError.noPassword { 88 | /* 89 | No password was found in the keychain. Create a dictionary to save 90 | as a new keychain item. 91 | */ 92 | var newItem = KeychainPasswordItem.keychainQuery(withService: service, account: account, accessGroup: accessGroup) 93 | newItem[kSecValueData as String] = encodedPassword as AnyObject? 94 | 95 | // Add a the new item to the keychain. 96 | let status = SecItemAdd(newItem as CFDictionary, nil) 97 | 98 | // Throw an error if an unexpected status was returned. 99 | guard status == noErr else { throw KeychainError.unhandledError(status: status) } 100 | } 101 | } 102 | 103 | func deleteItem() throws { 104 | // Delete the existing item from the keychain. 105 | let query = KeychainPasswordItem.keychainQuery(withService: service, account: account, accessGroup: accessGroup) 106 | let status = SecItemDelete(query as CFDictionary) 107 | 108 | // Throw an error if an unexpected status was returned. 109 | guard status == noErr || status == errSecItemNotFound else { throw KeychainError.unhandledError(status: status) } 110 | } 111 | 112 | // MARK: Convenience 113 | 114 | private static func keychainQuery(withService service: String, account: String? = nil, accessGroup: String? = nil) -> [String: AnyObject] { 115 | var query = [String: AnyObject]() 116 | query[kSecClass as String] = kSecClassGenericPassword 117 | query[kSecAttrService as String] = service as AnyObject? 118 | 119 | if let account = account { 120 | query[kSecAttrAccount as String] = account as AnyObject? 121 | } 122 | 123 | if let accessGroup = accessGroup { 124 | query[kSecAttrAccessGroup as String] = accessGroup as AnyObject? 125 | } 126 | 127 | return query 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /PiHoleStats/Util/Logger.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Logger.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 21/06/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import os.log 10 | 11 | struct Logger { 12 | func osLog(category: String) -> OSLog { 13 | return OSLog(subsystem: "PiStats", category: category) 14 | } 15 | 16 | func osLog(describing instance: Subject) -> OSLog { 17 | return osLog(category: String(describing: instance)) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /PiHoleStats/Util/PiHoleStats-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "SharedFileList.h" 6 | -------------------------------------------------------------------------------- /PiHoleStats/Util/QRCodeGenerator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // QRCodeGenerator.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 02/08/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import CoreImage.CIFilterBuiltins 11 | 12 | struct QRCodeGenerator { 13 | let context = CIContext() 14 | let filter = CIFilter.qrCodeGenerator() 15 | 16 | func generateQRCode(from string: String, with size: NSSize) -> NSImage { 17 | let data = Data(string.utf8) 18 | filter.setValue(data, forKey: "inputMessage") 19 | 20 | if let outputImage = filter.outputImage { 21 | if let cgimg = context.createCGImage(outputImage, from: outputImage.extent) { 22 | return NSImage(cgImage: cgimg, size: size) 23 | } 24 | } 25 | return NSImage() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /PiHoleStats/Util/SharedFileList.h: -------------------------------------------------------------------------------- 1 | // 2 | // SharedFileList.h 3 | // NoiseBuddy 4 | // 5 | // Created by Guilherme Rambo on 13/11/19. 6 | // Copyright © 2019 Guilherme Rambo. All rights reserved. 7 | // 8 | 9 | //https://github.com/insidegui/StatusBuddy 10 | 11 | #import 12 | 13 | NS_ASSUME_NONNULL_BEGIN 14 | 15 | @interface SharedFileList : NSObject 16 | 17 | + (instancetype)sessionLoginItems; 18 | 19 | @property (nonatomic, readonly) NSSet *items; 20 | 21 | @property (nonatomic, copy, nullable) void(^changeHandler)(SharedFileList *); 22 | 23 | - (BOOL)containsItem:(NSURL *)url; 24 | - (void)addItem:(NSURL *)url; 25 | - (void)removeItem:(NSURL *)url; 26 | 27 | @end 28 | 29 | NS_ASSUME_NONNULL_END 30 | -------------------------------------------------------------------------------- /PiHoleStats/Util/SharedFileList.m: -------------------------------------------------------------------------------- 1 | // 2 | // SharedFileList.m 3 | // SyzygyKit 4 | // 5 | // Created by Dave DeLong on 9/22/18. 6 | // Copyright © 2018 Syzygy. All rights reserved. 7 | // 8 | 9 | //https://github.com/insidegui/StatusBuddy 10 | 11 | #import "SharedFileList.h" 12 | 13 | #import 14 | 15 | #pragma clang diagnostic push 16 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" 17 | 18 | void sharedFileListDidChange(LSSharedFileListRef inList, void *context); 19 | 20 | @implementation SharedFileList { 21 | LSSharedFileListRef _listRef; 22 | 23 | NSSet *_listSnapshot; 24 | } 25 | 26 | + (BOOL)automaticallyNotifiesObserversOfItems { return NO; } 27 | 28 | + (instancetype)sessionLoginItems { 29 | return [[self alloc] initWithType:kLSSharedFileListSessionLoginItems]; 30 | } 31 | 32 | - (instancetype)initWithType:(CFStringRef)type { 33 | self = [super init]; 34 | if (self) { 35 | _listRef = LSSharedFileListCreate(NULL, type, NULL); 36 | _listSnapshot = [self _snapshot]; 37 | 38 | LSSharedFileListAddObserver(_listRef, 39 | CFRunLoopGetMain(), 40 | (CFStringRef)NSDefaultRunLoopMode, 41 | sharedFileListDidChange, 42 | (voidPtr)CFBridgingRetain(self)); 43 | } 44 | return self; 45 | } 46 | 47 | - (void)dealloc { 48 | LSSharedFileListRemoveObserver(_listRef, 49 | CFRunLoopGetMain(), 50 | (CFStringRef)NSDefaultRunLoopMode, 51 | sharedFileListDidChange, 52 | (__bridge void *)(self)); 53 | CFRelease(_listRef); 54 | } 55 | 56 | - (NSSet *)items { return [_listSnapshot copy]; } 57 | 58 | - (NSSet *)_snapshot { 59 | NSMutableSet *snapshot = [NSMutableSet set]; 60 | 61 | NSArray *listSnapshot = (NSArray *)CFBridgingRelease(LSSharedFileListCopySnapshot(_listRef, NULL)); 62 | for (id itemObject in listSnapshot) { 63 | LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef)itemObject; 64 | UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; 65 | CFURLRef currentItemURL = NULL; 66 | LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, NULL); 67 | NSURL *itemURL = CFBridgingRelease(currentItemURL); 68 | if (itemURL != nil) { 69 | [snapshot addObject:itemURL]; 70 | } 71 | } 72 | 73 | return snapshot; 74 | } 75 | 76 | - (void)_listDidChange { 77 | NSSet *newSnapshot = [self _snapshot]; 78 | 79 | [self willChangeValueForKey:@"items"]; 80 | _listSnapshot = newSnapshot; 81 | [self didChangeValueForKey:@"items"]; 82 | 83 | if (self.changeHandler != nil) { 84 | self.changeHandler(self); 85 | } 86 | } 87 | 88 | - (BOOL)containsItem:(NSURL *)url { return [_listSnapshot containsObject:url]; } 89 | 90 | - (void)addItem:(NSURL *)url { 91 | if ([self containsItem:url] == YES) { return; } 92 | LSSharedFileListInsertItemURL(_listRef, kLSSharedFileListItemLast, NULL, NULL, (__bridge CFURLRef)url, NULL, NULL); 93 | } 94 | 95 | - (void)removeItem:(NSURL *)url { 96 | if ([self containsItem:url] == NO) { return; } 97 | 98 | NSArray *listSnapshot = (NSArray *)CFBridgingRelease(LSSharedFileListCopySnapshot(_listRef, NULL)); 99 | for (id itemObject in listSnapshot) { 100 | LSSharedFileListItemRef item = (__bridge LSSharedFileListItemRef)itemObject; 101 | UInt32 resolutionFlags = kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes; 102 | CFURLRef currentItemURL = NULL; 103 | LSSharedFileListItemResolve(item, resolutionFlags, ¤tItemURL, NULL); 104 | NSURL *itemURL = CFBridgingRelease(currentItemURL); 105 | if ([itemURL isEqual:url]) { 106 | LSSharedFileListItemRemove(_listRef, item); 107 | } 108 | } 109 | } 110 | 111 | @end 112 | 113 | void sharedFileListDidChange(LSSharedFileListRef inList, void *context) { 114 | SharedFileList *list = (__bridge id)context; 115 | [list _listDidChange]; 116 | } 117 | 118 | #pragma clang diagnostic pop 119 | -------------------------------------------------------------------------------- /PiHoleStats/Util/ToolTip.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ToolTip.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 23/08/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct Tooltip: NSViewRepresentable { 12 | let tooltip: String 13 | func makeNSView(context: NSViewRepresentableContext) -> NSView { 14 | let view = NSView() 15 | view.toolTip = tooltip 16 | return view 17 | } 18 | func updateNSView(_ nsView: NSView, context: NSViewRepresentableContext) { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /PiHoleStats/Util/UIConstants.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIConstants.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 11/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SwiftUI 11 | 12 | struct UIConstants { 13 | struct Geometry { 14 | static let circleSize: CGFloat = 10.0 15 | } 16 | struct Colors { 17 | static let disabled = Color("disabled") 18 | static let enabled = Color("enabled") 19 | static let enabledAndDisabled = Color("enabledAndDisabled") 20 | static let totalQuery = Color("totalQuery") 21 | static let domainBlocked = Color("domainBlocked") 22 | static let queryBlocked = Color("queryBlocked") 23 | static let percentBlocked = Color("percentBlocked") 24 | } 25 | 26 | struct NSColors { 27 | static let disabled = NSColor(named: "disabled") 28 | static let enabledAndDisabled = NSColor(named: "enabledAndDisabled") 29 | } 30 | 31 | struct Images { 32 | static let globe = "globe" 33 | static let QRCode = "qrcode" 34 | } 35 | 36 | struct Strings { 37 | 38 | struct Error { 39 | static let invalidAPIToken = "Invalid API Token" 40 | static let invalidResponse = "Invalid Response" 41 | static let invalidURL = "Invalid URL" 42 | static let decodeResponseError = "Can't decode response" 43 | static let noAPITokenProvided = "No API Token Provided" 44 | static let sessionError = "Session Error" 45 | static let cantAddNewItem = "Can't add new item" 46 | } 47 | 48 | static let totalQueries = "Total Queries" 49 | static let queriesBlocked = "Queries Blocked" 50 | static let percentBlocked = "Percent Blocked" 51 | static let domainsOnBlocklist = "Domains on Blocklist" 52 | static let buttonPreferences = "Preferences" 53 | static let buttonOK = "OK" 54 | static let buttonQuit = "Quit" 55 | static let statusEnabled = "Active" 56 | static let statusDisabled = "Offline" 57 | static let statusNeedsAttention = "Needs Attention" 58 | static let statusEnabledAndDisabled = "Partially Active" 59 | static let buttonEnable = "Enable" 60 | static let buttonDisable = "Disable" 61 | static let host = "Host" 62 | static let hostPlaceholder = "0.0.0.0" 63 | static let apiToken = "API Token" 64 | static let preferencesProtocol = "Protocol" 65 | static let preferencesProtocolHTTP = "HTTP" 66 | static let preferencesProtocolHTTPS = "HTTPS" 67 | static let apiTokenPlaceholder = "token" 68 | static let buttonClose = "Close" 69 | static let findAPITokenInfo = "You can find the API Token on /etc/pihole/setupVars.conf under WEBPASSWORD or WebUI - Settings - API - Show API Token" 70 | static let openPreferencesToConfigureFirstPihole = "Open Preferences to configure your Pi-hole" 71 | static let tokenStoredOnKeychainInfo = "Your Pi-hole token is securely stored in your Mac's Keychain" 72 | static let copyright = "Copyright © Fernando Bunn" 73 | static let version = "Version" 74 | static let piStatsName = "Pi Stats" 75 | static let keepPopoverOpenPreference = "Keep popover open when clicking outside" 76 | static let launchAtLogonPreference = "Launch at login" 77 | static let preferencesWindowTitle = "Pi Stats Preferences" 78 | static let disableTimeOptionsTitle = "Display disable time options" 79 | static let displayStatusColorWhenPiholeIsOffline = "Display status color on menu bar icon when pi-hole is offline" 80 | static let disableButtonOptionPermanently = "Permanently" 81 | static let disableButtonOption30Seconds = "For 30 seconds" 82 | static let disableButtonOption1Minute = "For 1 minute" 83 | static let disableButtonOption5Minutes = "For 5 minutes" 84 | static let buttonClearErrorMessages = "Clear" 85 | static let preferencesPiholesTabTitle = "Pi-holes" 86 | static let preferencesPreferencesTabTitle = "Preferences" 87 | static let preferencesAboutTabTitle = "About" 88 | static let addPiholeButton = "Add" 89 | static let removePiholeButton = "Remove" 90 | static let savePiholeButton = "Save" 91 | static let noSelectedPiholeMessage = "Select a pi-hole on the left or click Add to setup a new pi-hole" 92 | static let noAvailablePiholeToSelectMessage = "No pi-holes available, click Add to setup a new pi-hole" 93 | static let warningButton = "⚠️" 94 | static let openProjectWebsiteButton = "Project Website" 95 | static let piStatsForMobileButton = "Pi Stats Mobile" 96 | static let preferencesQRCodeFormat = "QR Code Format:" 97 | static let preferencesQRCodeFormatWebInterface = "Web Interface" 98 | static let preferencesQRCodeFormatPiStats = "Pi Stats" 99 | static let preferencesQRCodeToolTip = "Display Pi-hole Settings as QR Code" 100 | static let preferencesWebToolTip = "Open Pi-hole Web Interface" 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /PiHoleStats/ViewControllers/PreferencesViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PreferencesViewController.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 22/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import Preferences 11 | import SwiftUI 12 | 13 | /* 14 | I've decided to use this third party library (Preferences) 15 | because there's an annoying bug with SwiftUI TabBar + List 16 | that breaks the rendering and state of the selected item 17 | More info here: 18 | https://twitter.com/fcbunn/status/1269301540923363333?s=21 19 | */ 20 | 21 | private enum PaneIdentifier: String { 22 | case piholes 23 | case preferences 24 | case about 25 | } 26 | 27 | class PreferencesViewController { 28 | let piholeListViewModel: PiholeListViewModel 29 | let preferences: UserPreferences 30 | 31 | init(preferences: UserPreferences, piholeListViewModel: PiholeListViewModel) { 32 | self.preferences = preferences 33 | self.piholeListViewModel = piholeListViewModel 34 | } 35 | 36 | lazy var preferencesWindowController = PreferencesWindowController( 37 | panes: [ 38 | Preferences.Pane( 39 | identifier: Preferences.PaneIdentifier(rawValue: PaneIdentifier.piholes.rawValue), 40 | title: UIConstants.Strings.preferencesPiholesTabTitle, 41 | toolbarIcon: NSImage(named: NSImage.userAccountsName)! 42 | ) { 43 | PiholeListConfigView(piholeListViewModel: piholeListViewModel) 44 | .environmentObject(self.preferences) 45 | }, 46 | 47 | Preferences.Pane( 48 | identifier: Preferences.PaneIdentifier(rawValue: PaneIdentifier.preferences.rawValue), 49 | title: UIConstants.Strings.preferencesPreferencesTabTitle, 50 | toolbarIcon: NSImage(named: NSImage.preferencesGeneralName)! 51 | ) { 52 | PreferencesView().environmentObject(self.preferences) 53 | }, 54 | 55 | Preferences.Pane( 56 | identifier: Preferences.PaneIdentifier(rawValue: PaneIdentifier.about.rawValue), 57 | title: UIConstants.Strings.preferencesAboutTabTitle, 58 | toolbarIcon: NSImage(named: NSImage.applicationIconName)! 59 | ) { 60 | AboutView() 61 | } 62 | ], animated: false 63 | ) 64 | 65 | func show() { 66 | preferencesWindowController.show() 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /PiHoleStats/ViewControllers/SummaryViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SummaryViewController.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 10/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | import SwiftUI 11 | 12 | class SummaryViewController: NSViewController { 13 | private let preferences: UserPreferences 14 | private let navigationController: NavigationController 15 | private let piHoleDataProvider: PiholeDataProvider 16 | 17 | init(preferences: UserPreferences, piHoleDataProvider: PiholeDataProvider, navigationController: NavigationController) { 18 | self.preferences = preferences 19 | self.piHoleDataProvider = piHoleDataProvider 20 | self.navigationController = navigationController 21 | super.init(nibName: nil, bundle: nil) 22 | } 23 | 24 | required init?(coder: NSCoder) { 25 | fatalError("init(coder:) has not been implemented") 26 | } 27 | 28 | override func loadView() { 29 | view = NSView() 30 | preferredContentSize = NSSize(width: 320, height: 208) 31 | let contentView = SummaryView() 32 | .environmentObject(navigationController) 33 | .environmentObject(preferences) 34 | .environmentObject(piHoleDataProvider) 35 | 36 | let hostingController = NSHostingController(rootView: contentView) 37 | addChild(hostingController) 38 | hostingController.view.autoresizingMask = [.width, .height] 39 | hostingController.view.frame = view.bounds 40 | view.addSubview(hostingController.view) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /PiHoleStats/ViewModel/PiholeListViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PiholeListViewModel.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 09/06/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class PiholeListViewModel: ObservableObject { 12 | private let piholeDataProvider: PiholeDataProvider 13 | var piholes: [Pihole] { 14 | piholeDataProvider.piholes 15 | } 16 | 17 | init(piholeDataProvider: PiholeDataProvider) { 18 | self.piholeDataProvider = piholeDataProvider 19 | } 20 | 21 | func addStubPihole() -> Pihole { 22 | let pihole = Pihole(address: "127.0.0.1") 23 | piholeDataProvider.add(pihole) 24 | return pihole 25 | } 26 | 27 | func remove(_ pihole: Pihole) { 28 | piholeDataProvider.remove(pihole) 29 | pihole.delete() 30 | } 31 | 32 | func itemViewModel(_ pihole: Pihole) -> PiholeViewModel { 33 | let model = PiholeViewModel(piHole: pihole) 34 | model.delegate = self 35 | return model 36 | } 37 | } 38 | 39 | extension PiholeListViewModel: PiholeViewModelDelegate { 40 | func piholeViewModelDidSave(_ piholeViewModel: PiholeViewModel, address: String, token: String, secure: Bool) { 41 | objectWillChange.send() 42 | if let index = piholeDataProvider.piholes.firstIndex(where: {$0.id == piholeViewModel.piHole.id}) { 43 | piholeDataProvider.piholes[index].address = address 44 | piholeDataProvider.piholes[index].apiToken = token 45 | piholeDataProvider.piholes[index].secure = secure 46 | piholeDataProvider.piholes[index].save() 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /PiHoleStats/ViewModel/PiholeViewModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PiHoleViewModel.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 31/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SwiftUI 11 | 12 | enum SecureTag: Int { 13 | case unsecure 14 | case secure 15 | } 16 | 17 | protocol PiholeViewModelDelegate: AnyObject { 18 | func piholeViewModelDidSave(_ piholeViewModel: PiholeViewModel, address: String, token: String, secure: Bool) 19 | } 20 | 21 | class PiholeViewModel: ObservableObject { 22 | @Published var address: String 23 | @Published var token: String 24 | @Published var secure: Bool 25 | @Published var secureTag: SecureTag { 26 | didSet { 27 | secure = secureTag == SecureTag.secure 28 | } 29 | } 30 | 31 | weak var delegate: PiholeViewModelDelegate? 32 | let piHole: Pihole 33 | 34 | var json: String { 35 | return """ 36 | { 37 | "pihole": { 38 | "host": "\(piHole.address)", 39 | "port": \(piHole.port ?? 80), 40 | "token": "\(piHole.apiToken)", 41 | "secure": \(piHole.secure) 42 | } 43 | } 44 | """ 45 | } 46 | 47 | internal init(piHole: Pihole) { 48 | self.piHole = piHole 49 | self.address = piHole.address 50 | self.token = piHole.apiToken 51 | self.secure = piHole.secure 52 | self.secureTag = piHole.secure ? SecureTag.secure : SecureTag.unsecure 53 | } 54 | 55 | func save() { 56 | delegate?.piholeViewModelDidSave(self, address: address, token: token, secure: secure) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Preferences/AboutView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AboutView.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 22/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Preferences 11 | 12 | struct AboutView: View { 13 | var appVersion: String { 14 | Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" 15 | } 16 | 17 | var body: some View { 18 | Preferences.Container(contentWidth: 300) { 19 | Preferences.Section(title: "") { 20 | Text(UIConstants.Strings.piStatsName) 21 | Text("\(UIConstants.Strings.version) \(self.appVersion)") 22 | 23 | Divider() 24 | 25 | HStack { 26 | Button(action: { 27 | if let url = URL(string: "https://github.com/Bunn/PiStats") { 28 | NSWorkspace.shared.open(url) 29 | } 30 | }, label: { 31 | Text(UIConstants.Strings.openProjectWebsiteButton) 32 | }) 33 | 34 | Button(action: { 35 | if let url = URL(string: "https://apps.apple.com/us/app/id1523024268") { 36 | NSWorkspace.shared.open(url) 37 | } 38 | }, label: { 39 | Text(UIConstants.Strings.piStatsForMobileButton) 40 | }) 41 | } 42 | Text(UIConstants.Strings.copyright) 43 | .font(.caption) 44 | } 45 | } 46 | } 47 | } 48 | 49 | struct AboutView_Previews: PreviewProvider { 50 | static var previews: some View { 51 | AboutView() 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Preferences/PiholeConfigView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 25/04/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct PiholeListConfigView: View { 12 | @State private var selectedItem: Pihole? 13 | @EnvironmentObject var piholeDataProvider: PiholeDataProvider 14 | 15 | var body: some View { 16 | HStack { 17 | VStack(alignment: .leading, spacing: 0) { 18 | List(selection: $selectedItem) { 19 | ForEach(piholeDataProvider.piholes) { pihole in 20 | Text(pihole.address).tag(pihole) 21 | } 22 | } 23 | HStack(spacing: 0) { 24 | Button(action: { 25 | self.addStubPihole() 26 | }, label: { 27 | Text("Add") 28 | }) 29 | 30 | Button(action: { 31 | self.removeSelectedPihole() 32 | }, label: { 33 | Text("Remove") 34 | }).disabled(selectedItem == nil) 35 | } 36 | } 37 | if selectedItem != nil { 38 | PiholeItemConfigView(piholeViewModel: PiholeViewModel(piHole: selectedItem!)) 39 | } else { 40 | Spacer() 41 | VStack { 42 | if piholeDataProvider.piholes.count > 0 { 43 | Text("Select a pi-hole on the left or click Add to setup a new pi-hole.") 44 | .multilineTextAlignment(.center) 45 | } else { 46 | Text("No pi-holes available, click Add to setup a new pi-hole") 47 | .multilineTextAlignment(.center) 48 | } 49 | }.padding() 50 | Spacer() 51 | } 52 | } 53 | .frame(width: 480, height: 250) 54 | .padding() 55 | .onAppear { 56 | self.selectedItem = self.piholeDataProvider.piholes.first 57 | } 58 | } 59 | 60 | private func addStubPihole() { 61 | let pihole = piholeDataProvider.addStubPihole() 62 | selectedItem = pihole 63 | } 64 | 65 | private func removeSelectedPihole() { 66 | if let pihole = self.selectedItem { 67 | remove(pihole) 68 | } 69 | selectedItem = nil 70 | } 71 | 72 | private func remove(_ pihole: Pihole) { 73 | piholeDataProvider.remove(pihole) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Preferences/PiholeItemConfig.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PiHoleItemConfig.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 30/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct PiholeItemConfigView: View { 12 | @EnvironmentObject var piHoleController: PiholeController 13 | @ObservedObject var piholeViewModel: PiholeViewModel 14 | 15 | var body: some View { 16 | VStack { 17 | HStack { 18 | Text(UIConstants.Strings.host) 19 | TextField(UIConstants.Strings.hostPlaceholder, text: $piholeViewModel.address) 20 | } 21 | 22 | HStack { 23 | Text(UIConstants.Strings.apiToken) 24 | SecureField(UIConstants.Strings.apiTokenPlaceholder, text: $piholeViewModel.address) 25 | } 26 | 27 | Button(action: { 28 | self.save() 29 | }, label: { 30 | Text("Save") 31 | }) 32 | 33 | Divider() 34 | 35 | Text(UIConstants.Strings.findAPITokenInfo) 36 | .font(.caption) 37 | .multilineTextAlignment(.center) 38 | .layoutPriority(1) 39 | 40 | Spacer() 41 | 42 | Text(UIConstants.Strings.tokenStoredOnKeychainInfo) 43 | .font(.footnote) 44 | .multilineTextAlignment(.center) 45 | .minimumScaleFactor(0.8) 46 | .foregroundColor(.secondary) 47 | } 48 | } 49 | 50 | private func save() { 51 | self.piHoleController.objectWillChange.send() 52 | self.piholeViewModel.save() 53 | } 54 | } 55 | 56 | //struct PiHoleItemConfig_Previews: PreviewProvider { 57 | // static var previews: some View { 58 | // PiHoleItemConfig() 59 | // } 60 | //} 61 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Preferences/PiholeItemConfigView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PiHoleItemConfig.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 30/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct PiholeItemConfigView: View { 12 | @ObservedObject var piholeViewModel: PiholeViewModel 13 | @EnvironmentObject var preferences: UserPreferences 14 | @State private var width: CGFloat? 15 | @State private var presentingQRCodePopOver = false 16 | private let qrcodeSize: CGFloat = 300 17 | 18 | private var qrcodeValue: String { 19 | switch preferences.qrcodeFormat { 20 | case .piStats: 21 | return piholeViewModel.json 22 | case .webInterface: 23 | return piholeViewModel.token 24 | } 25 | } 26 | 27 | private var selectedQRCodeFormatLabel: String { 28 | switch preferences.qrcodeFormat { 29 | case .webInterface: 30 | return UIConstants.Strings.preferencesQRCodeFormatWebInterface 31 | case .piStats: 32 | return UIConstants.Strings.preferencesQRCodeFormatPiStats 33 | } 34 | } 35 | 36 | enum LabelWidth: Preference {} 37 | let labelWidth = GeometryPreferenceReader( 38 | key: AppendValue.self, 39 | value: { [$0.size.width] } 40 | ) 41 | 42 | var body: some View { 43 | VStack(alignment: .trailing) { 44 | HStack { 45 | Text(UIConstants.Strings.host) 46 | .read(labelWidth) 47 | .frame(width: width, alignment: .leading) 48 | TextField(UIConstants.Strings.hostPlaceholder, text: $piholeViewModel.address) 49 | } 50 | 51 | HStack { 52 | Text(UIConstants.Strings.apiToken) 53 | .read(labelWidth) 54 | .frame(width: width, alignment: .leading) 55 | SecureField(UIConstants.Strings.apiTokenPlaceholder, text: $piholeViewModel.token) 56 | } 57 | 58 | HStack { 59 | Text(UIConstants.Strings.preferencesProtocol) 60 | .read(labelWidth) 61 | 62 | Picker(selection: $piholeViewModel.secureTag, label: Text("")) { 63 | Text(UIConstants.Strings.preferencesProtocolHTTP).tag(SecureTag.unsecure) 64 | Text(UIConstants.Strings.preferencesProtocolHTTPS).tag(SecureTag.secure) 65 | } 66 | } 67 | 68 | HStack { 69 | 70 | Button(action: { 71 | if let url = URL(string: "http://\(self.piholeViewModel.address)/admin/") { 72 | NSWorkspace.shared.open(url) } 73 | }, label: { 74 | HStack { 75 | Image(UIConstants.Images.globe) 76 | .resizable().aspectRatio(contentMode: .fit) 77 | .frame(width: 15) 78 | } 79 | }) 80 | .overlay(Tooltip(tooltip: UIConstants.Strings.preferencesWebToolTip)) 81 | 82 | Button(action: { 83 | self.presentingQRCodePopOver.toggle() 84 | }, label: { 85 | HStack { 86 | Image(UIConstants.Images.QRCode) 87 | .resizable().aspectRatio(contentMode: .fit) 88 | .frame(width: 13) 89 | } 90 | }) 91 | .overlay(Tooltip(tooltip: UIConstants.Strings.preferencesQRCodeToolTip)) 92 | .popover(isPresented: $presentingQRCodePopOver) { 93 | VStack { 94 | Image(nsImage: QRCodeGenerator().generateQRCode(from: self.qrcodeValue, with: NSSize(width: self.qrcodeSize, height: self.qrcodeSize))) 95 | .interpolation(.none) 96 | .padding() 97 | 98 | HStack { 99 | Text(UIConstants.Strings.preferencesQRCodeFormat) 100 | MenuButton(label: Text(self.selectedQRCodeFormatLabel)) { 101 | Button(action: { 102 | self.preferences.qrcodeFormat = .webInterface 103 | }, label: { Text(UIConstants.Strings.preferencesQRCodeFormatWebInterface) }) 104 | Button(action: { 105 | self.preferences.qrcodeFormat = .piStats 106 | }, label: { Text(UIConstants.Strings.preferencesQRCodeFormatPiStats) }) 107 | } 108 | } 109 | .padding(.bottom) 110 | .padding(.horizontal) 111 | } 112 | } 113 | 114 | Button(action: { 115 | self.piholeViewModel.save() 116 | }, label: { 117 | Text(UIConstants.Strings.savePiholeButton) 118 | }) 119 | } 120 | 121 | Divider() 122 | 123 | Text(UIConstants.Strings.findAPITokenInfo) 124 | .font(.caption) 125 | .multilineTextAlignment(.center) 126 | .layoutPriority(1) 127 | Divider() 128 | Text(UIConstants.Strings.tokenStoredOnKeychainInfo) 129 | .font(.footnote) 130 | .multilineTextAlignment(.center) 131 | .minimumScaleFactor(0.8) 132 | .foregroundColor(.secondary) 133 | } .assignMaxPreference(for: labelWidth.key, to: $width) 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Preferences/PiholeListConfigView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 25/04/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct PiholeListConfigView: View { 12 | @State private var selectedItem: Pihole? 13 | @ObservedObject var piholeListViewModel: PiholeListViewModel 14 | 15 | var body: some View { 16 | HStack { 17 | VStack(alignment: .leading, spacing: 0) { 18 | List(selection: $selectedItem) { 19 | ForEach(piholeListViewModel.piholes) { pihole in 20 | Text(pihole.address).tag(pihole) 21 | } 22 | } 23 | HStack(spacing: 0) { 24 | Button(action: { 25 | self.addStubPihole() 26 | }, label: { 27 | Text(UIConstants.Strings.addPiholeButton) 28 | }) 29 | 30 | Button(action: { 31 | self.removeSelectedPihole() 32 | }, label: { 33 | Text(UIConstants.Strings.removePiholeButton) 34 | }).disabled(selectedItem == nil) 35 | } 36 | } 37 | if selectedItem != nil { 38 | PiholeItemConfigView(piholeViewModel: piholeListViewModel.itemViewModel(selectedItem!)) 39 | } else { 40 | Spacer() 41 | VStack { 42 | if piholeListViewModel.piholes.count > 0 { 43 | Text(UIConstants.Strings.noSelectedPiholeMessage) 44 | .multilineTextAlignment(.center) 45 | } else { 46 | Text(UIConstants.Strings.noAvailablePiholeToSelectMessage) 47 | .multilineTextAlignment(.center) 48 | } 49 | }.padding() 50 | Spacer() 51 | } 52 | } 53 | .frame(width: 480, height: 250) 54 | .padding() 55 | .onAppear { 56 | self.selectedItem = self.piholeListViewModel.piholes.first 57 | } 58 | } 59 | 60 | private func addStubPihole() { 61 | let pihole = piholeListViewModel.addStubPihole() 62 | selectedItem = pihole 63 | } 64 | 65 | private func removeSelectedPihole() { 66 | if let pihole = self.selectedItem { 67 | remove(pihole) 68 | } 69 | selectedItem = nil 70 | } 71 | 72 | private func remove(_ pihole: Pihole) { 73 | piholeListViewModel.remove(pihole) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Preferences/PreferencesView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PreferencesView.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 23/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | import Preferences 11 | 12 | struct PreferencesView: View { 13 | @EnvironmentObject var preferences: UserPreferences 14 | 15 | var body: some View { 16 | Preferences.Container(contentWidth: 300) { 17 | Preferences.Section(title: "") { 18 | Toggle(isOn: self.$preferences.keepPopoverPanelOpen) { 19 | Text(UIConstants.Strings.keepPopoverOpenPreference) 20 | } 21 | Toggle(isOn: self.$preferences.launchAtLoginEnabled) { 22 | Text(UIConstants.Strings.launchAtLogonPreference) 23 | } 24 | Toggle(isOn: self.$preferences.displayDisableTimeOptions) { 25 | Text(UIConstants.Strings.disableTimeOptionsTitle) 26 | } 27 | Toggle(isOn: self.$preferences.displayStatusColorWhenPiholeIsOffline) { 28 | Text(UIConstants.Strings.displayStatusColorWhenPiholeIsOffline) 29 | } 30 | } 31 | 32 | } 33 | } 34 | } 35 | 36 | struct PreferencesView_Previews: PreviewProvider { 37 | static var previews: some View { 38 | PreferencesView() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Summary/SummaryItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SummaryItem.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 12/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | struct SummaryItem: View { 12 | var value: String 13 | var type: SummaryItemType 14 | 15 | enum SummaryItemType { 16 | case totalQuery 17 | case queryBlocked 18 | case percentBlocked 19 | case domainsOnBlocklist 20 | } 21 | 22 | private var circleColor: Color { 23 | switch type { 24 | case .domainsOnBlocklist: 25 | return UIConstants.Colors.domainBlocked 26 | case .percentBlocked: 27 | return UIConstants.Colors.percentBlocked 28 | case .queryBlocked: 29 | return UIConstants.Colors.queryBlocked 30 | case .totalQuery: 31 | return UIConstants.Colors.totalQuery 32 | } 33 | } 34 | 35 | private var text: String { 36 | switch type { 37 | case .domainsOnBlocklist: 38 | return UIConstants.Strings.domainsOnBlocklist 39 | case .percentBlocked: 40 | return UIConstants.Strings.percentBlocked 41 | case .queryBlocked: 42 | return UIConstants.Strings.queriesBlocked 43 | case .totalQuery: 44 | return UIConstants.Strings.totalQueries 45 | } 46 | } 47 | 48 | var body: some View { 49 | HStack { 50 | Circle() 51 | .fill(circleColor) 52 | .frame(width: UIConstants.Geometry.circleSize, height: UIConstants.Geometry.circleSize) 53 | Text(text) 54 | Spacer() 55 | Text(value) 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PiHoleStats/Views/Summary/SummaryView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SummaryView.swift 3 | // PiHoleStats 4 | // 5 | // Created by Fernando Bunn on 10/05/2020. 6 | // Copyright © 2020 Fernando Bunn. All rights reserved. 7 | // 8 | 9 | import SwiftUI 10 | 11 | private struct DisableButtonOption { 12 | let seconds: Int 13 | let text: String 14 | let id = UUID() 15 | } 16 | 17 | struct SummaryView: View { 18 | @EnvironmentObject var navigationController: NavigationController 19 | @EnvironmentObject var dataProvider: PiholeDataProvider 20 | @EnvironmentObject var preferences: UserPreferences 21 | @State private var isErrorMessagePresented = false 22 | @State private var isStatusAlertPresented = false 23 | 24 | private var disableButtonOptions: [DisableButtonOption] { 25 | [DisableButtonOption(seconds: 30, text: UIConstants.Strings.disableButtonOption30Seconds), 26 | DisableButtonOption(seconds: 60, text: UIConstants.Strings.disableButtonOption1Minute), 27 | DisableButtonOption(seconds: 300, text: UIConstants.Strings.disableButtonOption5Minutes)] 28 | } 29 | 30 | var body: some View { 31 | VStack { 32 | if dataProvider.piholes.count > 0 { 33 | HStack { 34 | Circle() 35 | .fill(self.dataProvider.statusColor) 36 | .frame(width: UIConstants.Geometry.circleSize, height: UIConstants.Geometry.circleSize) 37 | Text(self.dataProvider.statusText) 38 | 39 | conditionalAlertMessageButton() 40 | Spacer() 41 | conditionalEnableDisableButtons() 42 | } 43 | Divider() 44 | 45 | summaryItems() 46 | } else { 47 | Text(UIConstants.Strings.openPreferencesToConfigureFirstPihole) 48 | .multilineTextAlignment(.center) 49 | } 50 | 51 | Divider() 52 | 53 | HStack { 54 | Button(action: { 55 | NSApplication.shared.terminate(self) 56 | }, label: { 57 | Text(UIConstants.Strings.buttonQuit) 58 | }) 59 | 60 | Spacer() 61 | 62 | Button(action: { 63 | self.navigationController.openPreferences() 64 | }, label: { 65 | Text(UIConstants.Strings.buttonPreferences) 66 | }) 67 | } 68 | 69 | }.padding() 70 | } 71 | 72 | // MARK: - UI Components 73 | 74 | private func summaryItems() -> some View { 75 | Group { 76 | SummaryItem(value: self.dataProvider.totalQueries, type: .totalQuery) 77 | SummaryItem(value: self.dataProvider.queriesBlocked, type: .queryBlocked) 78 | SummaryItem(value: self.dataProvider.percentBlocked, type: .percentBlocked) 79 | SummaryItem(value: self.dataProvider.domainsOnBlocklist, type: .domainsOnBlocklist) 80 | } 81 | } 82 | 83 | private func conditionalEnableDisableButtons() -> some View { 84 | Group { 85 | if self.dataProvider.canDisplayEnableDisableButton { 86 | if preferences.displayDisableTimeOptions && self.dataProvider.status != .allDisabled { 87 | enableDisableMenuButton() 88 | } else { 89 | enableDisableButton() 90 | } 91 | } 92 | } 93 | } 94 | 95 | private func enableDisableMenuButton() -> some View { 96 | MenuButton(label: Text(self.dataProvider.changeStatusButtonTitle)) { 97 | Button(action: { 98 | self.dataProvider.disablePiHole() 99 | }, label: { Text(UIConstants.Strings.disableButtonOptionPermanently) }) 100 | 101 | VStack { 102 | Divider() 103 | } 104 | 105 | ForEach(disableButtonOptions, id: \.id) { option in 106 | Button(action: { 107 | self.dataProvider.disablePiHole(seconds: option.seconds) 108 | }, label: { Text(option.text) }) 109 | } 110 | }.frame(maxWidth: 80) 111 | } 112 | 113 | private func enableDisableButton() -> some View { 114 | Button(action: { 115 | self.dataProvider.status != .allDisabled ? self.dataProvider.disablePiHole() : self.dataProvider.enablePiHole() 116 | }, label: { 117 | Text(self.dataProvider.changeStatusButtonTitle) 118 | }) 119 | } 120 | 121 | private func conditionalAlertMessageButton() -> some View { 122 | Group { 123 | if self.dataProvider.hasErrorMessages { 124 | errorMessageButton() 125 | } else if self.dataProvider.status == .enabledAndDisabled { 126 | statusListWarningButton() 127 | } 128 | } 129 | } 130 | 131 | private func statusListWarningButton() -> some View { 132 | Button(action: { 133 | self.isStatusAlertPresented.toggle() 134 | }, label: { 135 | Text(UIConstants.Strings.warningButton) 136 | }).popover(isPresented: $isStatusAlertPresented) { 137 | VStack(alignment: .leading) { 138 | ForEach(self.dataProvider.piholes) {pihole in 139 | HStack { 140 | Circle() 141 | .fill(pihole.active ? UIConstants.Colors.enabled : UIConstants.Colors.disabled) 142 | .frame(width: UIConstants.Geometry.circleSize, height: UIConstants.Geometry.circleSize) 143 | Text(pihole.address) 144 | } 145 | } 146 | }.padding() 147 | } 148 | } 149 | 150 | private func errorMessageButton() -> some View { 151 | Button(action: { 152 | self.isErrorMessagePresented.toggle() 153 | }, label: { 154 | Text(UIConstants.Strings.warningButton) 155 | }).popover(isPresented: $isErrorMessagePresented) { 156 | VStack { 157 | ForEach(self.dataProvider.piholes) {pihole in 158 | if pihole.pollingError != nil { 159 | Text("\(pihole.address): \(pihole.pollingError!)") 160 | } 161 | if pihole.actionError != nil { 162 | Text("\(pihole.address): \(pihole.actionError!)") 163 | } 164 | } 165 | HStack { 166 | Button(action: { 167 | self.dataProvider.resetErrorMessage() 168 | self.isErrorMessagePresented.toggle() 169 | }, label: { 170 | Text(UIConstants.Strings.buttonClearErrorMessages) 171 | }) 172 | } 173 | }.padding() 174 | } 175 | } 176 | 177 | } 178 | 179 | struct SummaryView_Previews: PreviewProvider { 180 | static var previews: some View { 181 | SummaryView() 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /PrivacyPolicy.md: -------------------------------------------------------------------------------- 1 | # Privacy Policy 2 | 3 | ## What we collect 4 | This app doesn't log any kind of data from you. 5 | 6 | It doesn't have analytics or crash reporting tools. 7 | 8 | Your host address is stored as plain text and your API Token is securely stored in your Mac's keychain. 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | 6 | # Pi Stats 7 | 8 | Follow up and manage the status of your [Pi-hole(s)](https://github.com/pi-hole/pi-hole) with this simple macOS app that lives in your menu bar. 9 | 10 | ## Authentication Token 11 | In order to use the "enable/disable" button you need to add your Authentication Token in the Settings screen. 12 | 13 | There are two different ways to get your authentication token: 14 | 15 | - /etc/pihole/setupVars.conf under WEBPASSWORD 16 | - WebUI -> Settings -> API -> Show API Token 17 | 18 | 19 | ## Screenshots 20 | 21 | 22 | 23 | ## Requirement 24 | This project uses SwiftUI which requires macOS Catalina. 25 | 26 | Tested with Pi-hole 4.4 and 5.0 27 | 28 | ## Mobile 29 | If you want to run Pi Stats on your iPhone or iPad you can download [Pi Stats for iOS](https://apps.apple.com/us/app/id1523024268) which is [100% open source](https://github.com/Bunn/PiStatsMobile) as well :) 30 | 31 | ## Download 32 | Pi Stats (and [SwiftHole](https://github.com/Bunn/SwiftHole)) is a free and open source hobby project of mine. If you want to support its development you can either pay whatever you want on [Gumroad](https://gum.co/iqhwv) or buy it on the [App Store](https://apps.apple.com/us/app/pi-stats/id1514075262?ls=1) for those nice automatic updates :) 33 | 34 |

35 | 36 |

37 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TEAM_ID_FILE=PiHoleStats/Config/TeamID.xcconfig 4 | 5 | function print_team_ids() { 6 | echo "" 7 | echo "FYI, here are the team IDs found in your Xcode preferences:" 8 | echo "" 9 | 10 | XCODEPREFS="$HOME/Library/Preferences/com.apple.dt.Xcode.plist" 11 | TEAM_KEYS=(`/usr/libexec/PlistBuddy -c "Print :IDEProvisioningTeams" "$XCODEPREFS" | perl -lne 'print $1 if /^ (\S*) =/'`) 12 | 13 | for KEY in $TEAM_KEYS 14 | do 15 | i=0 16 | while true ; do 17 | NAME=$(/usr/libexec/PlistBuddy -c "Print :IDEProvisioningTeams:$KEY:$i:teamName" "$XCODEPREFS" 2>/dev/null) 18 | TEAMID=$(/usr/libexec/PlistBuddy -c "Print :IDEProvisioningTeams:$KEY:$i:teamID" "$XCODEPREFS" 2>/dev/null) 19 | 20 | if [ $? -ne 0 ]; then 21 | break 22 | fi 23 | 24 | echo "$TEAMID - $NAME" 25 | 26 | i=$(($i + 1)) 27 | done 28 | done 29 | } 30 | 31 | if [ -z "$1" ]; then 32 | print_team_ids 33 | echo "" 34 | echo "> What is your Apple Developer Team ID? (looks like 1A23BDCD)" 35 | read TEAM_ID 36 | else 37 | TEAM_ID=$1 38 | fi 39 | 40 | if [ -z "$TEAM_ID" ]; then 41 | echo "You must enter a team id" 42 | print_team_ids 43 | exit 1 44 | fi 45 | 46 | echo "Setting team ID to $TEAM_ID" 47 | 48 | echo "// This file was automatically generated, do not edit directly." > $TEAM_ID_FILE 49 | echo "" >> $TEAM_ID_FILE 50 | echo "DEVELOPMENT_TEAM=$TEAM_ID" >> $TEAM_ID_FILE 51 | 52 | echo "" 53 | echo "Successfully generated configuration at $TEAM_ID_FILE, you may now build the app using the \"PiStats\" target" 54 | echo "You may need to close and re-open the project in Xcode if it's already open" 55 | echo "" -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/images/icon.png -------------------------------------------------------------------------------- /images/macstadium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/images/macstadium.png -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bunn/PiStats/44f00143eeaf6f44f2a3c5a82bc36b3250b2efc8/images/screenshot.png --------------------------------------------------------------------------------