Skip to content

Commit

Permalink
Update function linking and add error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
JettChenT committed Aug 6, 2023
1 parent efae7cc commit 1a1cecc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions Apple/NetworkExtension/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import libburrow
import NetworkExtension
import OSLog
import libburrow

class PacketTunnelProvider: NEPacketTunnelProvider {
let logger = Logger(subsystem: "com.hackclub.burrow", category: "General")
override func startTunnel(options: [String: NSObject]?, completionHandler: @escaping (Error?) -> Void) {
let fild = libburrow.start()
let fild = libburrow.retrieve()
if fild == -1 {
// Not sure if this is the right way to return an error
logger.error("Failed to retrieve file descriptor for burrow.")
let err = NSError(
domain: "com.hackclub.burrow",
code: 1_010,
userInfo: [NSLocalizedDescriptionKey: "Failed to find TunInterface"]
)
completionHandler(err)
}
logger.info("fd: \(fild)")
completionHandler(nil)
}
Expand Down
2 changes: 1 addition & 1 deletion Apple/NetworkExtension/libburrow/libburrow.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
int start();
int retrieve();

0 comments on commit 1a1cecc

Please sign in to comment.