Initialize Tun Interface based on platform

This commit is contained in:
Jett Chen 2023-12-12 15:48:38 +08:00
parent c346ec5b39
commit 54ec260fe3
6 changed files with 24 additions and 14 deletions

View file

@ -28,7 +28,7 @@ struct BurrowStartRequest: Codable {
let name: String?
let no_pi: Bool
let tun_excl: Bool
let seek_utun: Int?
let tun_retrieve: Bool
let address: String?
}
struct StartOptions: Codable{
@ -37,8 +37,8 @@ struct BurrowStartRequest: Codable {
let Start: StartOptions
}
func start_req_fd(id: UInt, fd: Int) -> BurrowRequest<BurrowStartRequest> {
return BurrowRequest(id: id, command: BurrowStartRequest(Start: BurrowStartRequest.StartOptions(tun: BurrowStartRequest.TunOptions(name: nil, no_pi: false, tun_excl: false, seek_utun: fd, address: nil))))
func start_req_fd(id: UInt) -> BurrowRequest<BurrowStartRequest> {
return BurrowRequest(id: id, command: BurrowStartRequest(Start: BurrowStartRequest.StartOptions(tun: BurrowStartRequest.TunOptions(name: nil, no_pi: false, tun_excl: false, tun_retrieve: true, address: nil))))
}
struct Response<T>: Decodable where T: Decodable {

View file

@ -34,7 +34,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
// 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)
let start_command = start_req_fd(id: 1)
guard let data = try await client?.request(start_command, type: Response<BurrowResult<String>>.self)
else {
throw BurrowError.cantParseResult