interceptor - Android VpnService: Reading from Tun device hangs -
my app using vpnservice traffic interception.
what does:
1.reads tun device in loop:
while (started && tundevice.valid()) { final byte[] bytes = tundevice.read(); ippacket packet = packetfactory.createpacket(bytes); if (packet == null) { thread.yield(); } else { proxyservice.handlepacket(packet); } }
tundevice.read:
@override public byte[] read() throws ioexception { if (!valid()) { log.warn("tun: file descriptor not valid more"); return null; } int length = tuninputstream.read(readbuffer); log.debug("tun: received packet length={}", length); if (length < 0) { throw new ioexception("tun device closed"); } if (length == 0) { return null; } return arrays.copyofrange(readbuffer, 0, length); }
2.proxifies data protected socket.
the problem after time stops reading tun device. read method hangs , waits time (like 3-5 minutes).
using netstat see new connections in syn_sent state , can understand why - cannot receive ack code because cannot receive these syn packets.
the question is: be? when tun device behave this?
in our case problem in our tcp implementation. have written more data tcp receive (advertised window).
Comments
Post a Comment