A
A
Alexander2015-04-29 12:29:43
Java
Alexander, 2015-04-29 12:29:43

How to connect OpenVPN client on Android 4.1.2 to UbuntuServer?

There is a configured UbuntuServer with openVPN, I used the Windows client to check, the client connected everything went well (I used the key files and certificates issued by the server).
I want to write a client on Android, on the Internet it all comes down to example ToyVpnService also found an article Android VPN Service Explained with Packet Bypass E... I
use AndroidStudio, I use "class ToyVpnService extends VpnService" from "ToyVpnService"
the client hangs in a loop:

InetSocketAddress server = new InetSocketAddress(mServerAddress, Integer.parseInt(mServerPort));
            for (int attempt = 0; attempt < 10; ++attempt) {
                mHandler.sendEmptyMessage(R.string.connecting);
                if (run(server)) {//Сброс счетчика, если мы были связаны.
                    attempt = 0;
                    Log.i(TAG, "соединение установлено");
                }
                Thread.sleep(3000);//Спать на некоторое время. Это также проверяет, если мы получили прерывается.
            }
            Log.i(TAG, "Giving up");

10 times the message "R.string.connecting" appears - Connecting ... in the AndroidStudio logs it is written 10 times:
04-29 08:46:09.097 1003-1023/en.example.vpn E/PROG﹕ Got java.lang.IllegalStateException: Timed out

another log, it turns out he is trying to connect:
04-29 09:48:30.217 1143-1160/en.example.vpn I/PROG﹕ run 1
04-29 09:48:30.217 1143-1160/en.example.vpn I/PROG﹕ run Create a DatagramChannel as the VPN tunnel.
04-29 09:48:30.257 1143-1160/en.example.vpn I/PROG﹕ run Protect the tunnel before connecting to avoid loopback.
04-29 09:48:30.257 1143-1160/en.example.vpn I/PROG﹕ run Connect to the server.
04-29 09:48:30.257 1143-1160/en.example.vpn I/PROG﹕ run For simplicity, we use the same thread for both reading and writing. Here we put the tunnel into non-blocking mode.
04-29 09:48:30.257 1143-1160/en.example.vpn I/PROG﹕ run Authenticate and configure the virtual network interface.
04-29 09:48:30.267 1143-1160/en.example.vpn I/PROG﹕ handshake build a secured tunnel
04-29 09:48:30.267 1143-1160/en.example.vpn I/PROG﹕ handshake Control messages always start with zero.
04-29 09:48:30.267 1143-1160/en.example.vpn I/PROG﹕ handshake Send the secret several times in case of packet loss.
04-29 09:48:30.267 1143-1160/en.example.vpn I/PROG﹕ handshake Wait for the parameters within a limited time.
04-29 09:48:30.367 1143-1160/en.example.vpn I/PROG﹕ handshake Normally we should not receive random packets. (repeat 50 times)
04-29 09:48:35.407 1143-1160/en.example.vpn E/PROG﹕ Got java.lang.IllegalStateException: Timed out

How to connect? Where to use the files issued by the server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
adruzh, 2015-05-07
@adruzh

ToyVpn requires a connection to the ToyVpn server: https://android.googlesource.com/platform/developm...
For OpenVPN, you need to use https://github.com/schwabe/ics-openvpn
It can be cut to your liking or used as is. It even has an API for third-party applications.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question