checkpoint

This commit is contained in:
Jett Chen 2023-12-10 03:44:31 +08:00
parent ede0d13bca
commit db1750a045
39 changed files with 514 additions and 359 deletions

View file

@ -17,7 +17,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
logger.info("Started server")
Task {
do {
let command = BurrowRequest(id: 0, command: "ServerConfig")
let command = BurrowSingleCommand(id: 0, command: "ServerConfig")
guard let data = try await client?.request(command, type: Response<BurrowResult<ServerConfigData>>.self)
else {
throw BurrowError.cantParseResult
@ -32,6 +32,16 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
}
try await self.setTunnelNetworkSettings(tunNs)
self.logger.info("Set remote tunnel address to \(tunNs.tunnelRemoteAddress)")
// let tunFd = self.packetFlow.value(forKeyPath: "socket.fileDescriptor") as! Int;
// self.logger.info("Found File Descriptor: \(tunFd)")
let start_command = start_req_fd(id: 1, fd: 0)
guard let data = try await client?.request(start_command, type: Response<BurrowResult<String>>.self)
else {
throw BurrowError.cantParseResult
}
let encoded_startres = try JSONEncoder().encode(data.result)
self.logger.log("Received start server response: \(String(decoding: encoded_startres, as: UTF8.self))")
completionHandler(nil)
} catch {
self.logger.error("An error occurred: \(error)")