Compare commits
2 Commits
213addcc4a
...
2998514533
| Author | SHA1 | Date | |
|---|---|---|---|
| 2998514533 | |||
| d8644bd366 |
2
dmg.sh
2
dmg.sh
@ -1,3 +1,3 @@
|
||||
#! /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/sdlan_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/punchnet_v1
|
||||
|
||||
@ -7,12 +7,12 @@
|
||||
<key>Tun.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>punchnet.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
||||
@ -75,7 +75,11 @@ struct ContentView: View {
|
||||
.cornerRadius(5.0)
|
||||
.onTapGesture {
|
||||
Task {
|
||||
do {
|
||||
try await self.clickSwitchButton()
|
||||
} catch let err {
|
||||
NSLog("start vpn get error: \(err)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,15 +6,21 @@
|
||||
//
|
||||
import Foundation
|
||||
|
||||
enum PunchnetError: Error {
|
||||
case dnsUnreachable
|
||||
}
|
||||
|
||||
struct PunchnetConfig {
|
||||
static let server = "punchnet.aioe.tech"
|
||||
static let port = 18083
|
||||
|
||||
static func getOptions() -> [String:NSObject] {
|
||||
static func getOptions() throws -> [String:NSObject] {
|
||||
var options: [String: NSObject] = [:]
|
||||
|
||||
if let ip = DNSResolver.resolveAddrInfos(PunchnetConfig.server).first {
|
||||
options["super_ip"] = ip as NSObject
|
||||
} else {
|
||||
throw PunchnetError.dnsUnreachable
|
||||
}
|
||||
|
||||
return options
|
||||
|
||||
@ -32,7 +32,7 @@ class VPNManager: ObservableObject {
|
||||
try await manager.loadFromPreferences()
|
||||
self.addVPNStatusObserver(manager)
|
||||
|
||||
var configOptions = PunchnetConfig.getOptions()
|
||||
var configOptions = try PunchnetConfig.getOptions()
|
||||
configOptions.merge(options, uniquingKeysWith: {$1})
|
||||
|
||||
try manager.connection.startVPNTunnel(options: configOptions)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user