I'm developing an Android application and want it to connect to an OpenVPN Server.
Since Android 4.0 there is a VPNService class. This class however needs to intercept all the network packets(and require special permissions) because it is apperently running on the Internet Protocol. However as far as I understand, OpenVPN is running on-top of TCP or UDP(my server is configured to use UDP). I only need to tunnel the traffic from my own application through the VPN tunnel.
Shouldn't it theoretically be possible to avoid this(because I don't need to intercept all the traffic, but only the UDP-OpenVPN packets targeting my application)?
Do you know of a library for Android that fulfills my needs?
If not, would it be possible to implement the OpenVPN protocol in Android on-top of UDP without the need of the VPNService class?
I found the follwing project: ics-openvpn. However it also uses the VPNService class and intercepts all the packages.
Sure, you can theoretically do UDP/OpenVPN in userspace/inside your app. But you would need to implement the whole TCP/IP inside your app since you need to emulate the whole VPN stack.
For a one app VPN like solution you are probably much better of using a SOCKS/HTTP proxy etc. library.
You need to use VpnService for creating an application of OpenVPN which takes ovpn file as input for configuration on client side like OpenVPN Connect. So any person can change configuration according to their need. Also, you have to configure the server for OpenVPN. Take server of AWS EC2 or any other. While in configuring VPN on server side follow this link.
Related
I am trying to route my traffic with custom IP routes within a VPN. I have already had a similar issue with a windows VPN client and I was able to just write a batch file that runs when launching the client and it just runs route add commands.
The problem is it seems that this is impossible to do for Android. I am aware that there is the adb approach, but it gives me permissions errors when attempting to custom add routes. Upon further research it seemed in order to change the routing rules for the IP tables I would have to root my device, this is not an option in my case.
I have looked at the VPN service on the Android Developer page, but I didn't see any way to start adding custom routes to a VPN. I also saw no libraries readily available that provide a method for additionally routing traffic. Perhaps I am missing a piece of the puzzle.
I am still learning about Android Development and this is an issue that I would like to have some input on as I will not be able to run my application through the default VPN without adding my custom rules, and I do not have the ability to change the VPN subnets around to get rid of this issue at the moment.
I had a similar problem.
Android SDK has addRoute API to add a route policy through VPN.
But there is no remove route API in the public document.
Here is the addRoute documents:
Add a network route to the VPN interface. Both IPv4 and IPv6 routes are supported. Adding a route implicitly allows traffic from that address family (i.e., IPv4 or IPv6) to be routed over the VPN.
I want to build a sniffer in Android and one of the approaches that was proposed was a loop-back VPN.
The issue with this approach is that all the communication with the outside world will be done through a protected socket and in Java I still cannot sniff low level TCP information from that socket.
For example, I cannot find out when exactly an ACK was received for data that was sent from the phone. Am I missing something or is this approach simply not suitable for a proper sniffer?
You won't be able to get ack information and other low level info using an Android VPN as this data won't be exposed through Java sockets.
An alternative is to utilize a native sniffer (TCPdump is one example, and an Android port already exists), execute it as root from your Java app and then retrieve its output in your app
I am very new to jxfs things. I have a requirement to call jxfs server which is in cloud server from the jxfs client which is in ATM environment.. How can i call?.. I need to call this one through the Jxfs RMI concept. It would be appreciated one if any example code is available. If atleast you are having code for calling from jxfs server to jxfs client, please post it.
Thanks in advance guys.
One of the interesting things about J/XFS and remote device access (based on RMI) is that it is just matter of configuration.
You need to configure a J/XFS repository in order to handle a remote device (basically set 'remoteAccess' to true).
Then accessing these devices from the programming point of view is just the same as they were local devices.
Architecture is explained here: ftp://ftp.cencenelec.eu/CWA/CEN/WS-J-XFS/cwa14923/cwa14923-01-2004-May.pdf
Details, when programming may differ depending on the J/XFS implementation you are using.
Trying to answer your question below:
Whenever you want to access a device remotely in J/XFS, RMI is used. You need to make the following setup:
On a server (should be accessible) you need to start a JxfsServer. The JxfsServer will use a Read.repository
whith all the ATM's and devices configured on them as workstations, with the right IP addresses.
On the ATM, you need to install:
J/XFS libs
J/XFS device services for the devices on the ATM
Setup the DSstarter:
Will use the SpecificDeviceManagerRMI connecting to the JxfsServer you started before.
On your server (cloud) wherever you are going to use the J/XFS client you can get the remote controls by performing
the J/XFS initialization as follows:
jxfsDM_ = JxfsDeviceManager.getReference();
jxfsDM_.initialize("com.jxfs.forum.communication.rmi.SpecificDeviceManagerRMI,<atmWorkstation>,AppTest,2006;<jxfsserverhostname>,");
Then you can get the remote device controls with getDevice(...), and start using them as if they were local devices.
Please, note that handling RMI ports can be tricky, specially in a secured environment as ATM network. Make sure all the ports you need are open.
I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.
Is there any way to create a connection to a virtual private network using the BlackBerry APIs?
My understanding is that to connect to a VPN on BlackBerry you need to use bes, create a vpn profile, and so on. I am looking for a pure app-driven alternative.
Is it possible to do this by using something from the BBOS 5.0 packages or something else?
Here is the answer in case someone needs it:
There is no API which allows you to create/configure VPN profile. AFAIK if you are in the BES infrastructure it is possible profiles to be created on the server side from administrator and then pushed to clients via Blackberry Push Services. I haven't tried it though!
However you can also configure a VPN profile on your blackberry device and set it to a wi-fi connection. Then the Wi-Fi connection automatically goes into VPN as well as all the data you transfer in your app(make sure not to forget to add ;interface=wifi when you call Connector#open())