Compare commits

..

No commits in common. "2998514533f23792fc4acccf68f4e6d30ae7d9f1" and "213addcc4a6c87550ae78a59135b016a1de56eb9" have entirely different histories.

5 changed files with 6 additions and 16 deletions

2
dmg.sh
View File

@ -1,3 +1,3 @@
#! /bin/sh #! /bin/sh
create-dmg --volname "punchnet" --window-pos 200 120 --window-size 800 400 --icon "punchnet.app" 200 190 --hide-extension "punchnet.app" --app-drop-link 600 185 ~/Desktop/punchnet.dmg /Users/anlicheng/Desktop/punchnet_v1 create-dmg --volname "punchnet" --window-pos 200 120 --window-size 800 400 --icon "punchnet.app" 200 190 --hide-extension "punchnet.app" --app-drop-link 600 185 ~/Desktop/punchnet.dmg /Users/anlicheng/Desktop/sdlan_v1

View File

@ -7,12 +7,12 @@
<key>Tun.xcscheme_^#shared#^_</key> <key>Tun.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>1</integer> <integer>0</integer>
</dict> </dict>
<key>punchnet.xcscheme_^#shared#^_</key> <key>punchnet.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>0</integer> <integer>1</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>

View File

@ -75,11 +75,7 @@ struct ContentView: View {
.cornerRadius(5.0) .cornerRadius(5.0)
.onTapGesture { .onTapGesture {
Task { Task {
do {
try await self.clickSwitchButton() try await self.clickSwitchButton()
} catch let err {
NSLog("start vpn get error: \(err)")
}
} }
} }

View File

@ -6,21 +6,15 @@
// //
import Foundation import Foundation
enum PunchnetError: Error {
case dnsUnreachable
}
struct PunchnetConfig { struct PunchnetConfig {
static let server = "punchnet.aioe.tech" static let server = "punchnet.aioe.tech"
static let port = 18083 static let port = 18083
static func getOptions() throws -> [String:NSObject] { static func getOptions() -> [String:NSObject] {
var options: [String: NSObject] = [:] var options: [String: NSObject] = [:]
if let ip = DNSResolver.resolveAddrInfos(PunchnetConfig.server).first { if let ip = DNSResolver.resolveAddrInfos(PunchnetConfig.server).first {
options["super_ip"] = ip as NSObject options["super_ip"] = ip as NSObject
} else {
throw PunchnetError.dnsUnreachable
} }
return options return options

View File

@ -32,7 +32,7 @@ class VPNManager: ObservableObject {
try await manager.loadFromPreferences() try await manager.loadFromPreferences()
self.addVPNStatusObserver(manager) self.addVPNStatusObserver(manager)
var configOptions = try PunchnetConfig.getOptions() var configOptions = PunchnetConfig.getOptions()
configOptions.merge(options, uniquingKeysWith: {$1}) configOptions.merge(options, uniquingKeysWith: {$1})
try manager.connection.startVPNTunnel(options: configOptions) try manager.connection.startVPNTunnel(options: configOptions)