tladesignz / IPtProxy

Obfs4proxy and Snowflake Pluggable Transports for iOS
MIT License
54 stars 12 forks source link

calling IPtProxy.startObfs4Proxy crashes app #33

Closed uniqx closed 1 year ago

uniqx commented 1 year ago

I gave IPtProxy a try on Android. Here's the relevant snippet I came up with:

val bridgeline = "obfs4 87.123.123.123:123 0B6892C2DCD1FE8C1E7CBEA202BCEBECBDE47ECB cert=dZaWyaKA2a26abHSMqPKaE8aPGmeid4FUHGYJMzs9onWMjUuZKotKRYlMIRStVdqKBdOVw iat-mode=0"
val obfs4dir = File(context?.cacheDir, "obfs4dir")
obfs4dir.mkdirs()
IPtProxy.setStateLocation(obfs4dir.toString())
IPtProxy.startObfs4Proxy("DEBUG", true, false, bridgeline)

When I execute it, the app crashes. The error message doesn't contain any hint on what's going wrong. (I get the same behavior when I neglect to call setStateLocation) Here's the logs from when I run this snippet of code in Android emulator (API 31):

2022-12-06 00:54:12.982 0-0/? I/logd: logdr: UID=2000 GID=2000 PID=5120 b tail=0 logMask=99 pid=0 start=0ns deadline=0ns
2022-12-06 00:54:13.935 457-457/? W/adbd: timeout expired while flushing socket, closing
2022-12-06 00:54:17.205 5070-5093/info.guardianproject.sample D/EGL_emulation: app_time_stats: avg=8.18ms min=2.04ms max=32.10ms count=31
2022-12-06 00:54:18.002 0-0/? I/binder: undelivered transaction 1081587, process died.

    --------- beginning of system
2022-12-06 00:54:17.950 569-2110/system_process I/WindowManager: WIN DEATH: Window{6dab931 u0 info.guardianproject.sample/info.guardianproject.sample.SampleActivity}
2022-12-06 00:54:17.955 569-625/system_process I/libprocessgroup: Successfully killed process cgroup uid 10105 pid 5070 in 0ms
2022-12-06 00:54:17.955 369-369/? I/Zygote: Process 5070 exited cleanly (1)
2022-12-06 00:54:17.955 569-2110/system_process W/InputManager-JNI: Input channel object '6dab931 info.guardianproject.sample/info.guardianproject.sample.SampleActivity (client)' was disposed without first being removed with the input manager!
2022-12-06 00:54:17.956 569-4307/system_process I/ActivityManager: Process info.guardianproject.sample (pid 5070) has died: fg  TOP 
2022-12-06 00:54:17.959 413-413/? E/TransactionCallbackInvoker: cannot add callback because linkToDeath failed, err: -32
2022-12-06 00:54:17.960 413-413/? E/ClientCache: failed to get buffer, invalid process token
2022-12-06 00:54:17.960 413-413/? E/ClientCache: failed to get buffer, could not retrieve buffer
2022-12-06 00:54:17.960 413-413/? E/TransactionCallbackInvoker: could not find transaction stats
2022-12-06 00:54:17.960 413-413/? E/TransactionCallbackInvoker: cannot find transaction stats
2022-12-06 00:54:17.960 413-413/? E/ClientCache: failed to get buffer, invalid process token
2022-12-06 00:54:17.960 413-413/? W/TransactionCallbackInvoker: cannot find listener in mPendingTransactions
2022-12-06 00:54:17.960 413-413/? E/TransactionCallbackInvoker: could not find transaction stats
2022-12-06 00:54:17.960 413-413/? E/TransactionCallbackInvoker: could not add callback handle
2022-12-06 00:54:17.961 413-413/? E/BpTransactionCompletedListener: Failed to transact (-32)
2022-12-06 00:54:17.966 569-4307/system_process W/ActivityTaskManager: Force removing ActivityRecord{863be51 u0 info.guardianproject.sample/.SampleActivity t32}: app died, no saved state
2022-12-06 00:54:17.974 569-4307/system_process W/ActivityTaskManager: Can't find TaskDisplayArea to determine support for multi window. Task id=32 attached=false
2022-12-06 00:54:17.974 569-4307/system_process W/ActivityTaskManager: Can't find TaskDisplayArea to determine support for multi window. Task id=32 attached=false
2022-12-06 00:54:17.976 569-615/system_process W/ActivityManager: setHasOverlayUi called on unknown pid: 5070
2022-12-06 00:54:17.982 826-988/com.android.systemui D/EGL_emulation: app_time_stats: avg=17925.45ms min=17925.45ms max=17925.45ms count=1
2022-12-06 00:54:18.000 384-428/? D/goldfish-address-space: claimShared: Ask to claim region [0x3f12ca000 0x3f1c2f000]
2022-12-06 00:54:18.003 384-428/? D/goldfish-address-space: claimShared: Ask to claim region [0x3f1c2f000 0x3f2594000]
2022-12-06 00:54:18.004 384-384/? D/goldfish-address-space: claimShared: Ask to claim region [0x3f2594000 0x3f2ef9000]
2022-12-06 00:54:18.033 1115-2376/com.android.launcher3 I/OpenGLRenderer: Davey! duration=544588ms; Flags=1, FrameTimelineVsyncId=129912, IntendedVsync=27962404648548, Vsync=27962404648548, InputEventId=0, HandleInputStart=27962404928807, AnimationStart=27962404930425, PerformTraversalsStart=27962404931658, DrawStart=27962414291352, FrameDeadline=27962437981880, FrameInterval=27962404921422, FrameStartTime=16666666, SyncQueued=27962416898960, SyncStart=27962417194249, IssueDrawCommandsStart=27962417386380, SwapBuffers=27962418238652, FrameCompleted=28506993551592, DequeueBufferDuration=9995, QueueBufferDuration=741346, GpuCompleted=28506993551592, SwapBuffersCompleted=27962419658863, DisplayPresentTime=241704769535, 
2022-12-06 00:54:20.998 569-2008/system_process E/TaskPersister: File error accessing recents directory (directory doesn't exist?).
tladesignz commented 1 year ago

Read the docs, Luke!

https://github.com/tladesignz/IPtProxy/blob/master/IPtProxy.go/IPtProxy.go#L135-L207

The proxy argument is for an upstream proxy behind Obfs4proxy.

IPtProxy.startObfs4Proxy("DEBUG", true, false, null)

The bridge line goes into the Tor configuration:

tor --UseBridges 1 --ClientTransportPlugin "obfs4 socks5 127.0.0.1:[IPtProxy.obfs4Port()]" --Bridge "obfs4 87.123.123.123:123 0B6892C2DCD1FE8C1E7CBEA202BCEBECBDE47ECB cert=dZaWyaKA2a26abHSMqPKaE8aPGmeid4FUHGYJMzs9onWMjUuZKotKRYlMIRStVdqKBdOVw iat-mode=0"