diff --git a/app/src/main/java/anonvpn/anon_next/android/AndroidVpnService.java b/app/src/main/java/anonvpn/anon_next/android/AndroidVpnService.java index 7d03f19e47a39dba7871aa97d6a5de05c0bf7496..863b7a7af34684b080a1c123d4a95c55a9db5c5f 100644 --- a/app/src/main/java/anonvpn/anon_next/android/AndroidVpnService.java +++ b/app/src/main/java/anonvpn/anon_next/android/AndroidVpnService.java @@ -197,208 +197,3 @@ public class AndroidVpnService extends VpnService shutdown(); } }; - -/* - public void startAnonVPN(final boolean bUseMixes) - { - if (!mStarted) - { - final AnonVpnService anonVPNService = this; - - mThread = new Thread(new Runnable() - { - @Override - public void run() - { - VPNServiceUpstreamTunnelCreator upstreamTunnel = null; - try - { - Socket socketToProtect = null; - - final InputStream tunnelIn; - - final int mtu; - if (bUseMixes) - { - AnonClient anon = new AnonClient(null); //create AN.ON client - - //--> set to your cascde here!! - MixCascade mixCascade = new MixCascade(null, null, mServerAddress, mServerPort); //manually select mix cascade - mixCascade.setAccessControlPreSharedSecret(mCascadeAccessControlCredential); - - SignatureVerifier.getInstance().setCheckSignatures(false); //insecure, of course - but necessary for this simple manually added mix-cascade - - //initialize the client --> establish the connection - anon.initialize(mixCascade, new SimpleMixCascadeContainer(mixCascade), null, true); - - - //create a communication channel (like a connected socket) - AnonChannel c = anon.createChannel(AnonChannel.VPN); - m_iOutputBlockSize = c.getOutputBlockSize(); - mtu = m_iOutputBlockSize * 50; - tunnelIn = c.getInputStream(); - m_tunnelOut = c.getOutputStream(); - IStreamConnection con = anon.getConnectionToMixCascade().getUnderlyingIStreamConnection(); - SocketConnection scon = (SocketConnection) con; - socketToProtect = scon.getUnderlyingSocket(); - } - else //direct connection to VPN Server - { - InetSocketAddress isa = new InetSocketAddress(mServerAddress, mServerPort); - SocketChannel sc = SocketChannel.open(); - sc.connect(isa); - sc.configureBlocking(true); - m_tunnelOut = sc.socket().getOutputStream(); - tunnelIn = sc.socket().getInputStream(); - socketToProtect = sc.socket(); - m_iOutputBlockSize = 0x00FFFF; - mtu = 1400; - } - - if (!protect(socketToProtect)) - { - throw new IllegalStateException("Cannot protect the tunnel"); - } - //set a random IP address and start off - String response = handshake(mtu); - mStarted = true; - Message msg = Message.obtain(m_IncomingMessagesHandler,MESSAGE_IP); - //Transparancy, telling the user which IP is broadcasting when browsing - msg.obj = "VPN Connected, your new IP: " + response; - msg.sendToTarget(); - - upstreamTunnel = new VPNServiceUpstreamTunnelCreator(mInterface, anonVPNService); - - FileOutputStream out = new FileOutputStream(mInterface.getFileDescriptor()); - //ByteBuffer packetIn=ByteBuffer.allocate(32767); - byte[] arPacketIn = new byte[0x00FFFF]; - - //packetIn.position(0); - //packetIn.limit(4); - int lengthIn = 0, tcpudpdataHeaderlength = 0; - int posIn = 0; - int remaining = 4; - while (m_bRun) - { - // Read the incoming packet from the tunnel. - if (remaining > 0) - { - int l = tunnelIn.read(arPacketIn, posIn, remaining); - remaining -= l; - posIn += l; - } - if (posIn == 4 && lengthIn == 0) - { - //AnonIpHeaderWrapper ipheader = new AnonIpHeaderWrapper(arPacketIn); - lengthIn = ((arPacketIn[2] & 0xFF) << 8) | (arPacketIn[3] & 0xFF); - remaining = lengthIn - 4; - int l = tunnelIn.read(arPacketIn, posIn, remaining); - remaining -= l; - posIn += l; - } - if (lengthIn > 0) - { - if (remaining > 0) - { - int l = tunnelIn.read(arPacketIn, posIn, remaining); - remaining -= l; - posIn += l; - } - else - { - out.write(arPacketIn, 0, lengthIn); - posIn = 0; - remaining = 4; - lengthIn = 0; - } - } - - } - - } - catch (Exception e) - { - // Catch any exception - e.printStackTrace(); - } - finally - { - try - { - if (mInterface != null) - { - mInterface.close(); - mInterface = null; - mbroadcastReceiver.unregister(); - } - if (upstreamTunnel != null) - { - upstreamTunnel.stop(); - } - //sc.close(); - mStarted = false; - if(m_OutgoingMessenger!=null) - { - Message msg = Message.obtain(null,MESSAGE_ANON_SERVICE_STOPPED); - m_OutgoingMessenger.send(msg); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } - - }, "ANONdroid service - Receiving"); - //start the service - Log.i("CHECK", "VPN started"); - m_bRun = true; - mThread.start(); - - } - } - */ - -/* - @Override - public boolean handleMessage(Message message) - { - if (message != null) - { - if(message.what==AnonVpnService.MESSAGE_IP) - { - Toast.makeText(this, (String) message.obj, Toast.LENGTH_LONG).show(); - } - else if(message.what==AnonVpnService.MESSAGE_REGISTER) - { - m_OutgoingMessenger=message.replyTo; - } - } - return true; - } -*/ -/* - public void sendPacket(byte[] arPacket, int length) - { - int index = 0; - while (length > 0) - { - int i = Math.min(this.m_iOutputBlockSize, length); - try - { - m_tunnelOut.write(arPacket, index, i); - } - catch (IOException e) - { - e.printStackTrace(); - return; - } - index += i; - length -= i; - } - - } - - ; -*/