started setting up the VPN status & checking for permissions
This commit is contained in:
parent
5ae3d37243
commit
42590eaf00
12 changed files with 140 additions and 19 deletions
BIN
Apple/.DS_Store
vendored
BIN
Apple/.DS_Store
vendored
Binary file not shown.
|
|
@ -2,6 +2,10 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.networking.networkextension</key>
|
||||
<array>
|
||||
<string>packet-tunnel-provider</string>
|
||||
</array>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>$(APP_GROUP_IDENTIFIER)</string>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.networking.networkextension</key>
|
||||
<array>
|
||||
<string>packet-tunnel-provider</string>
|
||||
</array>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>$(APP_GROUP_IDENTIFIER)</string>
|
||||
|
|
|
|||
14
Apple/App/AppDelegate.swift
Normal file
14
Apple/App/AppDelegate.swift
Normal file
|
|
@ -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
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "sampleNetworkIcon.png",
|
||||
"filename" : "hackClubLogo.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
BIN
Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png
vendored
Normal file
BIN
Apple/App/Assets.xcassets/hackClubLogo.imageset/hackClubLogo.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 209 KiB |
|
|
@ -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?
|
||||
|
||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||
self.menuBarExtra = FluidMenuBarExtra(title: "Burrow", systemImage: "network.badge.shield.half.filled") {
|
||||
ContentView()
|
||||
struct PermissionView: View {
|
||||
@ObservedObject
|
||||
var configuration = NetworkConfiguration()
|
||||
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text(verbatim: "Status is \(configuration.status)")
|
||||
}
|
||||
.onAppear {
|
||||
configuration.update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
81
Apple/App/NetworkConfiguration.swift
Normal file
81
Apple/App/NetworkConfiguration.swift
Normal file
|
|
@ -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 ?? [])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 = "<group>"; };
|
||||
43EBDB2C29FD759E005D8CFF /* NetworkConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkConfiguration.swift; sourceTree = "<group>"; };
|
||||
D020F63D29E4A1FF002790F6 /* Identity.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Identity.xcconfig; sourceTree = "<group>"; };
|
||||
D020F64029E4A1FF002790F6 /* Compiler.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Compiler.xcconfig; sourceTree = "<group>"; };
|
||||
D020F64229E4A1FF002790F6 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
DEVELOPMENT_TEAM = 87PW93R2ZR
|
||||
APP_BUNDLE_IDENTIFIER = com.hackclub.burrow
|
||||
DEVELOPMENT_TEAM = 2H4LMN3ZLG
|
||||
APP_BUNDLE_IDENTIFIER = com.ThomasStubblefield.burrow
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue