Calling Libcore.newTun2ray(config) will cause the tun to get killed after a delay and not getting initialized as expected.
A Thread.sleep(2000) after calling newTun2ray will make it initialized and everything getting work very well.
I have created a new project and implemented everything from scratch, so i'm pretty sure the newTun2ray will get killed without a sleep after it (you can try it yourself)
I have also read the sagernet android app's source code and there are loops (sleeps) after this method which make it work (not getting killed).
I think should be a callback from the newTun2ray to be able to wait from kotlin side for tun to get initialized
Calling Libcore.newTun2ray(config) will cause the tun to get killed after a delay and not getting initialized as expected.
A Thread.sleep(2000) after calling newTun2ray will make it initialized and everything getting work very well.
I have created a new project and implemented everything from scratch, so i'm pretty sure the newTun2ray will get killed without a sleep after it (you can try it yourself)
I have also read the sagernet android app's source code and there are loops (sleeps) after this method which make it work (not getting killed).
I think should be a callback from the newTun2ray to be able to wait from kotlin side for tun to get initialized