Simulator works but device does not
Fonta1n3 opened this issue · 17 comments
Using Xcode v10.2.1
Making HTTP post request to my V3 hidden service works great in the simulator.
The same code is not working on the device though and I get an error The Internet connection appears to be offline
. However when making a request to an https site it works fine. My App Transport Security allows arbitrary loads in my Info.plist.
Any suggestions would be greatly appreciated and thank you very much for the awesome framework.
Heres is the TorClient code:
import Tor
class TorClient {
private var config: TorConfiguration = TorConfiguration()
private var thread: TorThread!
private var controller: TorController!
// Client status?
private(set) var isOperational: Bool = false
private var isConnected: Bool {
return self.controller.isConnected
}
// The tor url session configuration.
// Start with default config as fallback.
private var sessionConfiguration: URLSessionConfiguration = .default
// The tor client url session including the tor configuration.
var session: URLSession {
return URLSession(configuration: sessionConfiguration)
}
private func setupThread() {
config.options = [
"DNSPort": "12345",
"AutomapHostsOnResolve": "1",
"AvoidDiskWrites": "1"
]
config.cookieAuthentication = true
config.dataDirectory = URL(fileURLWithPath: self.createTorDirectory())
config.controlSocket = config.dataDirectory?.appendingPathComponent("cp")
config.arguments = [
"--allow-missing-torrc",
"--ignore-missing-torrc",
"--clientonly", "1",
"--socksport", "39050",
"--controlport", "127.0.0.1:39060",
]
thread = TorThread(configuration: config)
}
// Start the tor client.
func start(completion: @escaping () -> Void) {
// If already operational don't start a new client.
if isOperational || turnedOff() {
return completion()
}
// Make sure we don't have a thread already.
if thread == nil {
setupThread()
}
// Initiate the controller.
controller = TorController(socketURL: config.controlSocket!)
// Start a tor thread.
if thread.isExecuting == false {
thread.start()
//NotificationCenter.default.post(name: .didStartTorThread, object: self)
print("tor thread started")
}
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
// Connect Tor controller.
self.connectController(completion: completion)
}
}
// Resign the tor client.
func restart() {
resign()
if !isOperational {
return
}
while controller.isConnected {
print("Disconnecting Tor...")
}
//NotificationCenter.default.post(name: .didResignTorConnection, object: self)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.start {
//NotificationCenter.default.post(name: .didConnectTorController, object: self)
print("tor controller connected")
}
}
}
func resign() {
if !isOperational {
return
}
self.controller.disconnect()
self.isOperational = false
self.thread = nil
self.sessionConfiguration = .default
//NotificationCenter.default.post(name: .didTurnOffTor, object: self)
}
private func connectController(completion: @escaping () -> Void) {
do {
if !self.controller.isConnected {
try self.controller?.connect()
//NotificationCenter.default.post(name: .didConnectTorController, object: self)
print("tor controller connected")
}
try self.authenticateController {
print("Tor tunnel started! 🤩")
//NotificationCenter.default.post(name: .didEstablishTorConnection, object: self)
completion()
}
} catch {
//NotificationCenter.default.post(name: .errorDuringTorConnection, object: error)
print("error connecting tor controller")
completion()
}
}
private func authenticateController(completion: @escaping () -> Void) throws -> Void {
let cookie = try Data(
contentsOf: config.dataDirectory!.appendingPathComponent("control_auth_cookie"),
options: NSData.ReadingOptions(rawValue: 0)
)
self.controller?.authenticate(with: cookie) { success, error in
if let error = error {
return print(error.localizedDescription)
}
var observer: Any? = nil
observer = self.controller?.addObserver(forCircuitEstablished: { established in
guard established else {
return
}
self.controller?.getSessionConfiguration() { sessionConfig in
self.sessionConfiguration = sessionConfig!
self.isOperational = true
completion()
}
self.controller?.removeObserver(observer)
})
}
}
private func createTorDirectory() -> String {
let torPath = self.getTorPath()
do {
try FileManager.default.createDirectory(atPath: torPath, withIntermediateDirectories: true, attributes: [
FileAttributeKey.posixPermissions: 0o700
])
} catch {
print("Directory previously created. 🤷♀️")
}
return torPath
}
private func getTorPath() -> String {
var torDirectory = ""
#if targetEnvironment(simulator)
print("is simulator")
let path = NSSearchPathForDirectoriesInDomains(.applicationDirectory, .userDomainMask, true).first ?? ""
torDirectory = "\(path.split(separator: Character("/"))[0..<2].joined(separator: "/"))/.tor_tmp"
#else
print("is device")
torDirectory = "\(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first ?? "")/t"
#endif
return torDirectory
}
func turnedOff() -> Bool {
return false//!self.applicationRepository.useTor
}
}
The only difference between the simulator calling it and the device calling it is:
private func getTorPath() -> String {
var torDirectory = ""
#if targetEnvironment(simulator)
print("is simulator")
let path = NSSearchPathForDirectoriesInDomains(.applicationDirectory, .userDomainMask, true).first ?? ""
torDirectory = "\(path.split(separator: Character("/"))[0..<2].joined(separator: "/"))/.tor_tmp"
#else
print("is device")
torDirectory = "\(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first ?? "")/t"
#endif
return torDirectory
}
But considering it works on the device for HTTPS requests it rules out that it is the code? It is really frustrating because obviously all onion sites are HTTP. I am able to get data from the V3 service on another computer running tor, so it seems to be an issue with the framework. Again any suggestions would be greatly appreciated.
Sorry, I don't have an immediate answer to that. However, 2 things which may help you:
-
If you haven't done so, use
TORInstallTorLogging()
andTORInstallEventLogging()
of Tor/TORLogging.h to get more debug info. -
Obviously, the difference between the Simulator and the real device in your code is the directory usage. Eliminate that one source of error. It's unnecessary to run Tor. You should be able to use a common directory. In OnionBrowser, we use
.cachesDirectory
in.userDomainMask
.
Appreciate the feedback. I used .cachesDirectory
and .userDomainMask
but getting same error. Normal websites work, onion does not.
I have ruled out it has anything to do with my hidden service by accessing it from other devices on different networks.
I am able to get a response from my V3 in Onion Browser, is it using NSURL Session?
Is there any chance you could skim my log and see if anything obvious pops out to you? I have pasted the initial log from TORInstallTorLogging()
below:
2019-06-15 08:00:31.910568+0800 BitSense[1320:343987] [net] conn_read_callback: socket 17 wants to read.
2019-06-15 08:00:31.910746+0800 BitSense[1320:343987] [net] connection_buf_read_from_socket: 17: starting, inbuf_datalen 0 (0 pending in tls object). at_most 16448.
2019-06-15 08:00:31.911363+0800 BitSense[1320:343987] [general] connection_buf_read_from_socket: After TLS read of 514: 543 read, 0 written
2019-06-15 08:00:31.911506+0800 BitSense[1320:343987] [or] connection_or_process_cells_from_inbuf: 17: starting, inbuf_datalen 514 (0 pending in tls object).
2019-06-15 08:00:31.911678+0800 BitSense[1320:343987] [channel] channel_process_cell: Processing incoming cell_t 0x16f4de158 for channel 0x108e9e690 (global ID 6)
2019-06-15 08:00:31.911803+0800 BitSense[1320:343987] [circ] circuit_get_by_circid_channel_impl: circuit_get_by_circid_channel_impl() returning circuit 0x108fd5d80 for circ_id 3910615577, channel ID 6 (0x108e9e690)
2019-06-15 08:00:31.911930+0800 BitSense[1320:343987] [or] circuit_receive_relay_cell: Sending to origin.
2019-06-15 08:00:31.912044+0800 BitSense[1320:343987] [app] connection_edge_process_relay_cell: Now seen 5100 relay cells here (command 15, stream 0).
2019-06-15 08:00:31.912137+0800 BitSense[1320:343987] [app] connection_edge_process_relay_cell: Got an extended cell! Yay.
2019-06-15 08:00:31.912655+0800 BitSense[1320:343987] [circ] entry_guard_inc_circ_attempt_count: Got success count 1.000000/3.000000 for guard 0s1nt0 ($60275B52E810407658FD4278EDB1749C75F956F9)
2019-06-15 08:00:31.915733+0800 BitSense[1320:343987] [circ] circuit_finish_handshake: Finished building circuit hop:
2019-06-15 08:00:31.915875+0800 BitSense[1320:343987] [circ] internal (high-uptime) circ (length 3, last hop ellenatfims): $60275B52E810407658FD4278EDB1749C75F956F9(open) $3A1327AFECA8A974143DB38B533C6DA3CF21326E(open) $C65749CE3C33020D55E2500076A8B0A2A0616D21(closed)
2019-06-15 08:00:31.915987+0800 BitSense[1320:343987] [circ] circuit_send_intermediate_onion_skin: starting to send subsequent skin.
2019-06-15 08:00:31.916436+0800 BitSense[1320:343987] [circ] circuit_send_intermediate_onion_skin: Sending extend relay cell.
2019-06-15 08:00:31.916560+0800 BitSense[1320:343987] [or] relay_send_command_from_edge_: delivering 14 cell forward.
2019-06-15 08:00:31.916657+0800 BitSense[1320:343987] [or] relay_send_command_from_edge_: Sending a RELAY_EARLY cell; 5 remaining.
2019-06-15 08:00:31.917109+0800 BitSense[1320:343987] [or] relay_encrypt_cell_outbound: encrypting a layer of the relay cell.
2019-06-15 08:00:31.917349+0800 BitSense[1320:343987] [or] relay_encrypt_cell_outbound: encrypting a layer of the relay cell.
2019-06-15 08:00:31.917472+0800 BitSense[1320:343987] [general] append_cell_to_circuit_queue: Made a circuit active.
2019-06-15 08:00:31.917590+0800 BitSense[1320:343987] [sched] scheduler_set_channel_state: chan 6 changed from scheduler state WAITING_FOR_CELLS to PENDING
2019-06-15 08:00:31.917700+0800 BitSense[1320:343987] [or] connection_or_process_cells_from_inbuf: 17: starting, inbuf_datalen 0 (0 pending in tls object).
2019-06-15 08:00:31.917804+0800 BitSense[1320:343987] [sched] scheduler_evt_callback: Scheduler event callback called
2019-06-15 08:00:31.917904+0800 BitSense[1320:343987] [sched] update_socket_info: chan=6 updated socket info, limit: 34752, cwnd: 0, unacked: 0, notsent: 0, mss: 0
2019-06-15 08:00:31.918167+0800 BitSense[1320:343987] [sched] kist_scheduler_run: Running the scheduler. 1 channels pending
2019-06-15 08:00:31.918261+0800 BitSense[1320:343987] [sched] outbuf_table_add: scheduler init outbuf info for chan=6
2019-06-15 08:00:31.918367+0800 BitSense[1320:343987] [channel] channel_write_packed_cell: Writing 0x108fd67c0 to channel 0x108e9e690 with global ID 6
2019-06-15 08:00:31.918487+0800 BitSense[1320:343987] [general] channel_flush_from_first_active_circuit: Made a circuit inactive.
2019-06-15 08:00:31.918586+0800 BitSense[1320:343987] [sched] update_socket_written: chan=6 wrote 543 bytes, old was 0
2019-06-15 08:00:31.918971+0800 BitSense[1320:343987] [sched] scheduler_set_channel_state: chan 6 changed from scheduler state PENDING to WAITING_FOR_CELLS
2019-06-15 08:00:31.919218+0800 BitSense[1320:343987] [sched] channel_write_to_kernel: Writing 514 bytes to kernel for chan 6
2019-06-15 08:00:31.919788+0800 BitSense[1320:343987] [net] flush_chunk_tls: flushed 514 bytes, 0 ready to flush, 0 remain.
2019-06-15 08:00:31.920177+0800 BitSense[1320:343987] [general] connection_handle_write_impl: After TLS write of 514: 0 read, 543 written
2019-06-15 08:00:31.920297+0800 BitSense[1320:343987] [sched] free_outbuf_info_by_ent: Freeing outbuf table entry from chan=6
2019-06-15 08:00:31.920397+0800 BitSense[1320:343987] [sched] kist_scheduler_run: len pending=0, len to_readd=-1
2019-06-15 08:00:32.089197+0800 BitSense[1320:343987] [circ] circuit_remove_handled_ports: Port 443 is already being handled; removing.
2019-06-15 08:00:32.089292+0800 BitSense[1320:343987] [circ] circuit_predict_and_launch_new: Have 3 clean circs (1 uptime-internal, 1 internal), need another hidden service circ.
2019-06-15 08:00:32.094074+0800 BitSense[1320:343987] [circ] new_route_len: Chosen route length 3 (6535/6535 routers suitable).
2019-06-15 08:00:32.098868+0800 BitSense[1320:343987] [circ] router_choose_random_node: We found 4891 running nodes.
2019-06-15 08:00:32.098951+0800 BitSense[1320:343987] [circ] router_choose_random_node: We removed 0 excludednodes, leaving 4891 nodes.
2019-06-15 08:00:32.099918+0800 BitSense[1320:343987] [circ] compute_weighted_bandwidths: Generated weighted bandwidths for rule weight as middle node based on weights Wg=0.411600 Wm=1.000000 We=0.000000 Wd=0.000000 with total bw 21307238751.200001
2019-06-15 08:00:32.101452+0800 BitSense[1320:343987] [circ] extend_info_from_node: using 199.115.114.70:443 for Endgame
2019-06-15 08:00:32.101498+0800 BitSense[1320:343987] [circ] extend_info_from_node: Including Ed25519 ID for $026DD786689D26A4C1B96ABDE3797CF01941D276~Endgame at 199.115.114.70
2019-06-15 08:00:32.101562+0800 BitSense[1320:343987] [circ] onion_extend_cpath: Path is 0 long; we want 3
2019-06-15 08:00:32.101718+0800 BitSense[1320:343987] [guard] select_primary_guard_for_circuit: Selected primary guard 0s1nt0 ($60275B52E810407658FD4278EDB1749C75F956F9) for circuit.
2019-06-15 08:00:32.102168+0800 BitSense[1320:343987] [circ] extend_info_from_node: using 176.9.53.58:8443 for 0s1nt0
2019-06-15 08:00:32.102210+0800 BitSense[1320:343987] [circ] extend_info_from_node: Including Ed25519 ID for $60275B52E810407658FD4278EDB1749C75F956F9~0s1nt0 at 176.9.53.58
2019-06-15 08:00:32.102261+0800 BitSense[1320:343987] [circ] onion_extend_cpath: Chose router $60275B52E810407658FD4278EDB1749C75F956F9~0s1nt0 at 176.9.53.58 for hop #1 (exit is Endgame)
2019-06-15 08:00:32.102299+0800 BitSense[1320:343987] [circ] onion_extend_cpath: Path is 1 long; we want 3
2019-06-15 08:00:32.102332+0800 BitSense[1320:343987] [circ] choose_good_middle_server: Contemplating intermediate hop #2: random choice.
2019-06-15 08:00:32.109581+0800 BitSense[1320:343987] [circ] router_choose_random_node: We found 4891 running nodes.
2019-06-15 08:00:32.109642+0800 BitSense[1320:343987] [circ] router_choose_random_node: We removed 0 excludednodes, leaving 4891 nodes.
2019-06-15 08:00:32.110167+0800 BitSense[1320:343987] [circ] router_choose_random_node: We removed 32 excludedsmartlist, leaving 4864 nodes.
2019-06-15 08:00:32.111113+0800 BitSense[1320:343987] [circ] compute_weighted_bandwidths: Generated weighted bandwidths for rule weight as middle node based on weights Wg=0.411600 Wm=1.000000 We=0.000000 Wd=0.000000 with total bw 20930801059.200001
2019-06-15 08:00:32.111412+0800 BitSense[1320:343987] [circ] extend_info_from_node: using 212.8.243.229:9001 for theWOPR
2019-06-15 08:00:32.111453+0800 BitSense[1320:343987] [circ] extend_info_from_node: Including Ed25519 ID for $645C3F0545E0975A49F69EC272C0C3EA28586825~theWOPR at 212.8.243.229
2019-06-15 08:00:32.111496+0800 BitSense[1320:343987] [circ] onion_extend_cpath: Chose router $645C3F0545E0975A49F69EC272C0C3EA28586825~theWOPR at 212.8.243.229 for hop #2 (exit is Endgame)
2019-06-15 08:00:32.111562+0800 BitSense[1320:343987] [circ] onion_extend_cpath: Path is 2 long; we want 3
2019-06-15 08:00:32.111585+0800 BitSense[1320:343987] [circ] onion_extend_cpath: Chose router $026DD786689D26A4C1B96ABDE3797CF01941D276~Endgame at 199.115.114.70 for hop #3 (exit is Endgame)
2019-06-15 08:00:32.111606+0800 BitSense[1320:343987] [circ] onion_extend_cpath: Path is complete: 3 steps long
2019-06-15 08:00:32.111628+0800 BitSense[1320:343987] [circ] circuit_handle_first_hop: Looking for firsthop '176.9.53.58:8443'
2019-06-15 08:00:32.111712+0800 BitSense[1320:343987] [circ] circuit_handle_first_hop: Conn open. Delivering first onion skin.
2019-06-15 08:00:32.111732+0800 BitSense[1320:343987] [circ] circuit_send_first_onion_skin: First skin; sending create cell.
2019-06-15 08:00:32.112007+0800 BitSense[1320:343987] [circ] circuit_get_by_circid_channel_impl: circuit_get_by_circid_channel_impl() found nothing for circ_id 3226910719, channel ID 6 (0x108e9e690)
2019-06-15 08:00:32.112048+0800 BitSense[1320:343987] [circ] circuit_deliver_create_cell: Chosen circID 3226910719.
2019-06-15 08:00:32.112075+0800 BitSense[1320:343987] [circ] circuitmux_attach_circuit: Attaching circuit 3226910719 on channel 6 to cmux 0x282615c70
2019-06-15 08:00:32.112110+0800 BitSense[1320:343987] [general] append_cell_to_circuit_queue: Made a circuit active.
2019-06-15 08:00:32.112132+0800 BitSense[1320:343987] [sched] scheduler_set_channel_state: chan 6 changed from scheduler state WAITING_FOR_CELLS to PENDING
2019-06-15 08:00:32.112216+0800 BitSense[1320:343987] [circ] circuit_send_first_onion_skin: First hop: finished sending CREATE cell to '$60275B52E810407658FD4278EDB1749C75F956F9~0s1nt0 at 176.9.53.58'
2019-06-15 08:00:32.112306+0800 BitSense[1320:343987] [sched] scheduler_evt_callback: Scheduler event callback called
2019-06-15 08:00:32.112330+0800 BitSense[1320:343987] [sched] update_socket_info: chan=6 updated socket info, limit: 34752, cwnd: 0, unacked: 0, notsent: 0, mss: 0
2019-06-15 08:00:32.112350+0800 BitSense[1320:343987] [sched] kist_scheduler_run: Running the scheduler. 1 channels pending
2019-06-15 08:00:32.112369+0800 BitSense[1320:343987] [sched] outbuf_table_add: scheduler init outbuf info for chan=6
2019-06-15 08:00:32.112393+0800 BitSense[1320:343987] [channel] channel_write_packed_cell: Writing 0x108fd67c0 to channel 0x108e9e690 with global ID 6
2019-06-15 08:00:32.112425+0800 BitSense[1320:343987] [general] channel_flush_from_first_active_circuit: Made a circuit inactive.
2019-06-15 08:00:32.112445+0800 BitSense[1320:343987] [sched] update_socket_written: chan=6 wrote 543 bytes, old was 0
2019-06-15 08:00:32.112645+0800 BitSense[1320:343987] [sched] scheduler_set_channel_state: chan 6 changed from scheduler state PENDING to WAITING_FOR_CELLS
2019-06-15 08:00:32.112666+0800 BitSense[1320:343987] [sched] channel_write_to_kernel: Writing 514 bytes to kernel for chan 6
2019-06-15 08:00:32.112993+0800 BitSense[1320:343987] [net] flush_chunk_tls: flushed 514 bytes, 0 ready to flush, 0 remain.
2019-06-15 08:00:32.113021+0800 BitSense[1320:343987] [general] connection_handle_write_impl: After TLS write of 514: 0 read, 543 written
2019-06-15 08:00:32.113055+0800 BitSense[1320:343987] [sched] free_outbuf_info_by_ent: Freeing outbuf table entry from chan=6
2019-06-15 08:00:32.113078+0800 BitSense[1320:343987] [sched] kist_scheduler_run: len pending=0, len to_readd=-1
2019-06-15 08:00:32.420011+0800 BitSense[1320:343987] [net] conn_read_callback: socket 17 wants to read.
2019-06-15 08:00:32.420191+0800 BitSense[1320:343987] [net] connection_buf_read_from_socket: 17: starting, inbuf_datalen 0 (0 pending in tls object). at_most 16448.
2019-06-15 08:00:32.420794+0800 BitSense[1320:343987] [general] connection_buf_read_from_socket: After TLS read of 514: 543 read, 0 written
2019-06-15 08:00:32.421218+0800 BitSense[1320:343987] [or] connection_or_process_cells_from_inbuf: 17: starting, inbuf_datalen 514 (0 pending in tls object).
2019-06-15 08:00:32.421698+0800 BitSense[1320:343987] [channel] channel_process_cell: Processing incoming cell_t 0x16f4de158 for channel 0x108e9e690 (global ID 6)
2019-06-15 08:00:32.421924+0800 BitSense[1320:343987] [circ] circuit_get_by_circid_channel_impl: circuit_get_by_circid_channel_impl() returning circuit 0x108fd5d80 for circ_id 3910615577, channel ID 6 (0x108e9e690)
2019-06-15 08:00:32.422062+0800 BitSense[1320:343987] [or] circuit_receive_relay_cell: Sending to origin.
2019-06-15 08:00:32.422157+0800 BitSense[1320:343987] [app] connection_edge_process_relay_cell: Now seen 5101 relay cells here (command 15, stream 0).
2019-06-15 08:00:32.422248+0800 BitSense[1320:343987] [app] connection_edge_process_relay_cell: Got an extended cell! Yay.
2019-06-15 08:00:32.425218+0800 BitSense[1320:343987] [circ] circuit_finish_handshake: Finished building circuit hop:
2019-06-15 08:00:32.425355+0800 BitSense[1320:343987] [circ] internal (high-uptime) circ (length 3, last hop ellenatfims): $60275B52E810407658FD4278EDB1749C75F956F9(open) $3A1327AFECA8A974143DB38B533C6DA3CF21326E(open) $C65749CE3C33020D55E2500076A8B0A2A0616D21(open)
2019-06-15 08:00:32.425468+0800 BitSense[1320:343987] [circ] circuit_build_times_add_time: Adding circuit build time 1323
2019-06-15 08:00:32.425582+0800 BitSense[1320:343987] [guard] entry_guards_note_guard_success: Recorded success for primary confirmed guard 0s1nt0 ($60275B52E810407658FD4278EDB1749C75F956F9)
2019-06-15 08:00:32.425965+0800 BitSense[1320:343987] [circ] circuit_build_no_more_hops: circuit built!
2019-06-15 08:00:32.426242+0800 BitSense[1320:343987] [circ] pathbias_count_build_success: Got success count 2.000000/3.000000 for guard 0s1nt0 ($60275B52E810407658FD4278EDB1749C75F956F9)
2019-06-15 08:00:32.426364+0800 BitSense[1320:343987] [or] connection_or_process_cells_from_inbuf: 17: starting, inbuf_datalen 0 (0 pending in tls object).
2019-06-15 08:00:32.522407+0800 BitSense[1320:343987] [net] conn_read_callback: socket 17 wants to read.
2019-06-15 08:00:32.522578+0800 BitSense[1320:343987] [net] connection_buf_read_from_socket: 17: starting, inbuf_datalen 0 (0 pending in tls object). at_most 16448.
2019-06-15 08:00:32.523190+0800 BitSense[1320:343987] [general] connection_buf_read_from_socket: After TLS read of 514: 543 read, 0 written
2019-06-15 08:00:32.523720+0800 BitSense[1320:343987] [or] connection_or_process_cells_from_inbuf: 17: starting, inbuf_datalen 514 (0 pending in tls object).
2019-06-15 08:00:32.523879+0800 BitSense[1320:343987] [channel] channel_process_cell: Processing incoming cell_t 0x16f4de158 for channel 0x108e9e690 (global ID 6)
2019-06-15 08:00:32.523984+0800 BitSense[1320:343987] [circ] circuit_get_by_circid_channel_impl: circuit_get_by_circid_channel_impl() returning circuit 0x108ea0860 for circ_id 3226910719, channel ID 6 (0x108e9e690)
2019-06-15 08:00:32.524082+0800 BitSense[1320:343987] [or] command_process_created_cell: at OP. Finishing handshake.
2019-06-15 08:00:32.526949+0800 BitSense[1320:343987] [circ] circuit_finish_handshake: Finished building circuit hop:
2019-06-15 08:00:32.527221+0800 BitSense[1320:343987] [circ] internal (high-uptime) circ (length 3, last hop Endgame): $60275B52E810407658FD4278EDB1749C75F956F9(open) $645C3F0545E0975A49F69EC272C0C3EA28586825(closed) $026DD786689D26A4C1B96ABDE3797CF01941D276(closed)
2019-06-15 08:00:32.527323+0800 BitSense[1320:343987] [or] command_process_created_cell: Moving to next skin.
2019-06-15 08:00:32.527430+0800 BitSense[1320:343987] [circ] circuit_send_intermediate_onion_skin: starting to send subsequent skin.
2019-06-15 08:00:32.527885+0800 BitSense[1320:343987] [circ] circuit_send_intermediate_onion_skin: Sending extend relay cell.
2019-06-15 08:00:32.528011+0800 BitSense[1320:343987] [or] relay_send_command_from_edge_: delivering 14 cell forward.
2019-06-15 08:00:32.528104+0800 BitSense[1320:343987] [or] relay_send_command_from_edge_: Sending a RELAY_EARLY cell; 6 remaining.
2019-06-15 08:00:32.528249+0800 BitSense[1320:343987] [or] relay_encrypt_cell_outbound: encrypting a layer of the relay cell.
2019-06-15 08:00:32.528839+0800 BitSense[1320:343987] [general] append_cell_to_circuit_queue: Made a circuit active.
2019-06-15 08:00:32.528948+0800 BitSense[1320:343987] [sched] scheduler_set_channel_state: chan 6 changed from scheduler state WAITING_FOR_CELLS to PENDING
2019-06-15 08:00:32.529194+0800 BitSense[1320:343987] [or] connection_or_process_cells_from_inbuf: 17: starting, inbuf_datalen 0 (0 pending in tls object).
2019-06-15 08:00:32.529509+0800 BitSense[1320:343987] [sched] scheduler_evt_callback: Scheduler event callback called
2019-06-15 08:00:32.529619+0800 BitSense[1320:343987] [sched] update_socket_info: chan=6 updated socket info, limit: 34752, cwnd: 0, unacked: 0, notsent: 0, mss: 0
2019-06-15 08:00:32.529712+0800 BitSense[1320:343987] [sched] kist_scheduler_run: Running the scheduler. 1 channels pending
2019-06-15 08:00:32.529803+0800 BitSense[1320:343987] [sched] outbuf_table_add: scheduler init outbuf info for chan=6
2019-06-15 08:00:32.530076+0800 BitSense[1320:343987] [channel] channel_write_packed_cell: Writing 0x108ea0b20 to channel 0x108e9e690 with global ID 6
2019-06-15 08:00:32.530201+0800 BitSense[1320:343987] [general] channel_flush_from_first_active_circuit: Made a circuit inactive.
2019-06-15 08:00:32.530294+0800 BitSense[1320:343987] [sched] update_socket_written: chan=6 wrote 543 bytes, old was 0
2019-06-15 08:00:32.530390+0800 BitSense[1320:343987] [sched] scheduler_set_channel_state: chan 6 changed from scheduler state PENDING to WAITING_FOR_CELLS
2019-06-15 08:00:32.530484+0800 BitSense[1320:343987] [sched] channel_write_to_kernel: Writing 514 bytes to kernel for chan 6
2019-06-15 08:00:32.531398+0800 BitSense[1320:343987] [net] flush_chunk_tls: flushed 514 bytes, 0 ready to flush, 0 remain.
2019-06-15 08:00:32.531457+0800 BitSense[1320:343987] [general] connection_handle_write_impl: After TLS write of 514: 0 read, 543 written
2019-06-15 08:00:32.531588+0800 BitSense[1320:343987] [sched] free_outbuf_info_by_ent: Freeing outbuf table entry from chan=6
2019-06-15 08:00:32.531739+0800 BitSense[1320:343987] [sched] kist_scheduler_run: len pending=0, len to_readd=-1
2019-06-15 08:00:32.726718+0800 BitSense[1320:343987] [net] conn_read_callback: socket 17 wants to read.
2019-06-15 08:00:32.726898+0800 BitSense[1320:343987] [net] connection_buf_read_from_socket: 17: starting, inbuf_datalen 0 (0 pending in tls object). at_most 16448.
2019-06-15 08:00:32.727379+0800 BitSense[1320:343987] [general] connection_buf_read_from_socket: After TLS read of 514: 543 read, 0 written
2019-06-15 08:00:32.727500+0800 BitSense[1320:343987] [or] connection_or_process_cells_from_inbuf: 17: starting, inbuf_datalen 514 (0 pending in tls object).
2019-06-15 08:00:32.727646+0800 BitSense[1320:343987] [channel] channel_process_cell: Processing incoming cell_t 0x16f4de158 for channel 0x108e9e690 (global ID 6)
2019-06-15 08:00:32.727748+0800 BitSense[1320:343987] [circ] circuit_get_by_circid_channel_impl: circuit_get_by_circid_channel_impl() returning circuit 0x108fd4ac0 for circ_id 3805280659, channel ID 6 (0x108e9e690)
Sorry, to me that log looks rather inocuous.
Did you compare logs from simulator and real device? What differences does it have?
I am able to get a response from my V3 in Onion Browser, is it using NSURL Session?
I'll try to answer that in the issue you created there: OnionBrowser/OnionBrowser#199
Not sure if it helps but I can also make http requests to .com sites perfectly fine on device so it seems its only an issue with onion urls.
Not sure if it helps but I can also make http requests to .com sites perfectly fine on device so it seems its only an issue with onion urls.
Well, in that case, I'd assume, you're not connecting via Tor. For some reason, the network connection isn't rerouted to the Tor service running.
Do you run Tor on your MacOS where the simulator runs? That might explain, why it works on the simulator but not on a real device. That would mean, you don't reroute the app traffic to the Tor thread, but a Tor outside the simulator catches it.
Try this site: https://check.torproject.org
I can confirm with certainty that I do not have Tor running on my mac, it is only running via the app and Tor.framework. I have tried troubleshooting this in many ways but am stuck here...
Sorry to read that. Unfortunately, I can't help further without looking at code.
I'm happy to provide professional support, which - in this case - I recommend hiring via the Guardian Project because this is work I do under their regime, so it's ust fair to loop them in.
Ok that would be great, I need to finish up a major refactor I am doing now and will then see if I can pay for your services via the linked project. Thank you
Just FYI I opened a ticket with them (Ticket#942860), look forward to hearing back.
Hi Benjamin, I am really keen to solve this issue and still have not heard back from Guardian Project. Do you recommend a specific way to contact them? Thank you in advanced.
@Fonta1n3 when you say "opened a ticket" where do you mean exactly? Did you email our help desk or some other address?
Hi @n8fr8,
I went to the link provided for Guardian Project, clicked contact, and emailed the support email helpdesk@guardianproject.info
Please let me know how to best go about this?
Many Thanks
@Fonta1n3 no worries, I clarified with GP. Will contact you via mail.
Fixed with 3048010
Interesting case: The session config returned by TORController
contained 127.0.0.1
as proxy server address. When replaced with localhost
, everything works just fine.
It seems, that DNS queries on devices were bypassing Tor, so .onion addresses couldn't be resolved. Otherwise Tor worked just fine. (Use https://check.torproject.org/ to test this!)
Added a workaround to replace 127.0.0.1
with localhost
.
will there be a binary github release for this fix? would be super helpful ❤️
@ottosuess There sure will be in the near future, together with an updated Tor.
In the meantime, you can help yourself easily if you just create the session config yourself like this:
// What you defined as "--socksport" in "TorConfiguration.arguments" or as "SocksPort" in "TorConfiguration.options":
NSInteger socksProxyPort = 12345;
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
config.connectionProxyDictionary = @{
(NSString *)kCFProxyTypeKey: (NSString *)kCFProxyTypeSOCKS,
(NSString *)kCFStreamPropertySOCKSProxyHost: @"localhost",
(NSString *)kCFStreamPropertySOCKSProxyPort: [NSNumber numberWithInteger: socksProxyPort]
};