diff --git a/Apple/.DS_Store b/Apple/.DS_Store index b41887a..6bf97d7 100644 Binary files a/Apple/.DS_Store and b/Apple/.DS_Store differ diff --git a/Apple/App/App-iOS.entitlements b/Apple/App/App-iOS.entitlements index d9849a8..02ee960 100644 --- a/Apple/App/App-iOS.entitlements +++ b/Apple/App/App-iOS.entitlements @@ -2,6 +2,10 @@ + com.apple.developer.networking.networkextension + + packet-tunnel-provider + com.apple.security.application-groups $(APP_GROUP_IDENTIFIER) diff --git a/Apple/App/App-macOS.entitlements b/Apple/App/App-macOS.entitlements index a0ec729..7395b5c 100644 --- a/Apple/App/App-macOS.entitlements +++ b/Apple/App/App-macOS.entitlements @@ -2,6 +2,10 @@ + com.apple.developer.networking.networkextension + + packet-tunnel-provider + com.apple.security.application-groups $(APP_GROUP_IDENTIFIER) diff --git a/Apple/App/AppDelegate.swift b/Apple/App/AppDelegate.swift new file mode 100644 index 0000000..25c9baf --- /dev/null +++ b/Apple/App/AppDelegate.swift @@ -0,0 +1,14 @@ +#if os(macOS) +import AppKit +import FluidMenuBarExtra + +class AppDelegate: NSObject, NSApplicationDelegate { + private var menuBarExtra: FluidMenuBarExtra? + + func applicationDidFinishLaunching(_ notification: Notification) { + self.menuBarExtra = FluidMenuBarExtra(title: "Burrow", systemImage: "network.badge.shield.half.filled") { + ContentView() + } + } +} +#endif diff --git a/Apple/App/Assets.xcassets/sampleNetworkIcon.imageset/Contents.json b/Apple/App/Assets.xcassets/hackClubLogo.imageset/Contents.json similarity index 86% rename from Apple/App/Assets.xcassets/sampleNetworkIcon.imageset/Contents.json rename to Apple/App/Assets.xcassets/hackClubLogo.imageset/Contents.json index 828f857..76da2cb 100644 --- a/Apple/App/Assets.xcassets/sampleNetworkIcon.imageset/Contents.json +++ b/Apple/App/Assets.xcassets/hackClubLogo.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "sampleNetworkIcon.png", + "filename" : "hackClubLogo.png", "idiom" : "universal", "scale" : "1x" }, diff --git a/Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png b/Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png new file mode 100644 index 0000000..6823ccf Binary files /dev/null and b/Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png differ diff --git a/Apple/App/Assets.xcassets/sampleNetworkIcon.imageset/sampleNetworkIcon.png b/Apple/App/Assets.xcassets/sampleNetworkIcon.imageset/sampleNetworkIcon.png deleted file mode 100644 index f5caa26..0000000 Binary files a/Apple/App/Assets.xcassets/sampleNetworkIcon.imageset/sampleNetworkIcon.png and /dev/null differ diff --git a/Apple/App/BurrowApp.swift b/Apple/App/BurrowApp.swift index 00542b8..3725480 100644 --- a/Apple/App/BurrowApp.swift +++ b/Apple/App/BurrowApp.swift @@ -6,24 +6,32 @@ // import SwiftUI -import FluidMenuBarExtra +import NetworkExtension @main struct burrowBarApp: App { + #if os(macOS) @NSApplicationDelegateAdaptor private var appDelegate: AppDelegate + #endif var body: some Scene { - Settings { - Text("Burrow") + WindowGroup { + PermissionView() } } } -class AppDelegate: NSObject, NSApplicationDelegate { - private var menuBarExtra: FluidMenuBarExtra? + +struct PermissionView: View { + @ObservedObject + var configuration = NetworkConfiguration() - func applicationDidFinishLaunching(_ notification: Notification) { - self.menuBarExtra = FluidMenuBarExtra(title: "Burrow", systemImage: "network.badge.shield.half.filled") { - ContentView() + + var body: some View { + VStack { + Text(verbatim: "Status is \(configuration.status)") + } + .onAppear { + configuration.update() } } } diff --git a/Apple/App/ContentView.swift b/Apple/App/ContentView.swift index 916aac7..757665c 100644 --- a/Apple/App/ContentView.swift +++ b/Apple/App/ContentView.swift @@ -1,39 +1,41 @@ import SwiftUI struct ContentView: View { + @State private var connectedHackClubNetwork = false + var body: some View { VStack(alignment: .leading) { HStack { - - Text("Networks") .font(.title3) Spacer() Image(systemName: "badge.plus.radiowaves.forward") .symbolRenderingMode(.palette) .foregroundStyle(.blue, .black) + .opacity(0.4) .imageScale(.large) } Divider() VStack(alignment: .leading) { - Text("Your Burrows") + Text("Burrows") .padding(.top, 2) - .font(.subheadline) - .fontWeight(.bold) + .font(.subheadline.weight(.bold)) HStack { - Image("sampleNetworkIcon") + Image("hackClubLogo") .resizable() .frame(width: 32, height: 32) .cornerRadius(100) VStack(alignment: .leading) { - Text("Penguin Pair Burrow") + Text("Hack Club Network") .fontWeight(.medium) Text("􁠲 Recently Validated Certificate") .font(.caption2) .foregroundColor(.blue) + }.onTapGesture { + connectedHackClubNetwork = true } } } diff --git a/Apple/App/NetworkConfiguration.swift b/Apple/App/NetworkConfiguration.swift new file mode 100644 index 0000000..9bf9390 --- /dev/null +++ b/Apple/App/NetworkConfiguration.swift @@ -0,0 +1,81 @@ +import SwiftUI +import NetworkExtension + +@MainActor +class NetworkConfiguration: ObservableObject { + enum Status: CustomStringConvertible { + case unknown + case blank + case valid + case error + + var description: String { + switch self { + case .unknown: + return "Unknown" + case .blank: + return "Blank" + case .valid: + return "Valid" + default: + return "Default" + } + } + } + + @Published + var status: Status = .unknown + + init() { + update() + + + } + + func update() { + Task { + do { + let configurations = try await NETunnelProviderManager.loadAll() + + await MainActor.run { + self.status = configurations.isEmpty ? .blank : .valid + print(self.status) + self.objectWillChange.send() + } + } catch { + await MainActor.run { + self.status = .error + self.objectWillChange.send() + + } + } + } + } + + func request() { + let configuration = NETunnelProviderProtocol() + configuration.providerBundleIdentifier = "" + configuration.serverAddress = "Hack Club" + + let manager = NETunnelProviderManager() + manager.protocolConfiguration = configuration + manager.localizedDescription = "Hack Club Burrow" + manager.saveToPreferences { error in + print(error) + } + } +} + +extension NETunnelProviderManager { + static func loadAll() async throws -> [NETunnelProviderManager] { + try await withUnsafeThrowingContinuation { continuation in + NETunnelProviderManager.loadAllFromPreferences { managers, error in + if let error = error { + continuation.resume(throwing: error) + } else { + continuation.resume(returning: managers ?? []) + } + } + } + } +} diff --git a/Apple/Burrow.xcodeproj/project.pbxproj b/Apple/Burrow.xcodeproj/project.pbxproj index 6d763d1..57298cf 100644 --- a/Apple/Burrow.xcodeproj/project.pbxproj +++ b/Apple/Burrow.xcodeproj/project.pbxproj @@ -7,7 +7,9 @@ objects = { /* Begin PBXBuildFile section */ - 43E50D6D29FA050600BD2280 /* FluidMenuBarExtra in Frameworks */ = {isa = PBXBuildFile; productRef = 43E50D6C29FA050600BD2280 /* FluidMenuBarExtra */; }; + 43E50D6D29FA050600BD2280 /* FluidMenuBarExtra in Frameworks */ = {isa = PBXBuildFile; platformFilters = (macos, ); productRef = 43E50D6C29FA050600BD2280 /* FluidMenuBarExtra */; }; + 43EBDB2B29FD7557005D8CFF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EBDB2A29FD754A005D8CFF /* AppDelegate.swift */; }; + 43EBDB2D29FD759E005D8CFF /* NetworkConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EBDB2C29FD759E005D8CFF /* NetworkConfiguration.swift */; }; D020F65829E4A697002790F6 /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = D020F65729E4A697002790F6 /* PacketTunnelProvider.swift */; }; D020F65D29E4A697002790F6 /* BurrowNetworkExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = D020F65329E4A697002790F6 /* BurrowNetworkExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; D05B9F7629E39EEC008CB1F9 /* BurrowApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */; }; @@ -40,6 +42,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 43EBDB2A29FD754A005D8CFF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 43EBDB2C29FD759E005D8CFF /* NetworkConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkConfiguration.swift; sourceTree = ""; }; D020F63D29E4A1FF002790F6 /* Identity.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Identity.xcconfig; sourceTree = ""; }; D020F64029E4A1FF002790F6 /* Compiler.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Compiler.xcconfig; sourceTree = ""; }; D020F64229E4A1FF002790F6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -126,7 +130,9 @@ isa = PBXGroup; children = ( D05B9F7529E39EEC008CB1F9 /* BurrowApp.swift */, + 43EBDB2A29FD754A005D8CFF /* AppDelegate.swift */, D05B9F7729E39EEC008CB1F9 /* ContentView.swift */, + 43EBDB2C29FD759E005D8CFF /* NetworkConfiguration.swift */, D05B9F7929E39EED008CB1F9 /* Assets.xcassets */, D020F66829E4AA74002790F6 /* App-iOS.entitlements */, D020F66929E4AA74002790F6 /* App-macOS.entitlements */, @@ -248,8 +254,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 43EBDB2B29FD7557005D8CFF /* AppDelegate.swift in Sources */, D05B9F7829E39EEC008CB1F9 /* ContentView.swift in Sources */, D05B9F7629E39EEC008CB1F9 /* BurrowApp.swift in Sources */, + 43EBDB2D29FD759E005D8CFF /* NetworkConfiguration.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Apple/Configuration/Identity.xcconfig b/Apple/Configuration/Identity.xcconfig index e4ef90e..6ff2392 100644 --- a/Apple/Configuration/Identity.xcconfig +++ b/Apple/Configuration/Identity.xcconfig @@ -1,2 +1,2 @@ -DEVELOPMENT_TEAM = 87PW93R2ZR -APP_BUNDLE_IDENTIFIER = com.hackclub.burrow +DEVELOPMENT_TEAM = 2H4LMN3ZLG +APP_BUNDLE_IDENTIFIER = com.ThomasStubblefield.burrow