Android - ToyVPN Is it possible to "fake" VPN connection? - android

I'm working on an app and I've figured out I need to setup a VPN service and everything for it to work for what I need it to. However, I don't have VPN server and I don't need one. I just need app to think it's connected to the VPN.
Purpose of this is to block or allow network for other apps. Apps that are allowed through VPN won't get any network, as VPN is not actually working.
I've managed to setup ToyVPN from android developers as an example, but not sure what I need to do next in order to make it think it's connected to VPN, while having just a dummy connection or nothing at all.
Thanks for responses in advance!

Related

Route all the internet traffic from my android voip app to my own vpn server

We have set up our own VPN Server and want to route all the traffic from our VOIP android app through this server.
But all the solutions I have seen thus far use the vpn service class http://developer.android.com/reference/android/net/VpnService.html, which creates a vpn tunnel for the whole device and not just my application. I want the other apps running on the phone to use the internet as normal while the traffic from our app is routed through our VPN server.
Is there anyway to do this? I am very grateful for any suggestions. Thanks
VpnService does not need to apply to the whole device. See: VpnService.Builder.addAllowedApplication (available with API 21 - 5.0):
Adds an application that's allowed to access the VPN connection. If this method is called at least once, only applications added through this method (and no others) are allowed access. Else (if this method is never called), all applications are allowed by default. If some applications are added, other, un-added applications will use networking as if the VPN wasn't running.

How to send notification from one android device to another android device in same wifi network

I want to send notification from one android device (android tv without bluetooth, telephony) to another android device (phone/tablet). Both are on same wifi network. Through the notification, I want to launch an app or open a page in phone/tablet browser.
I went through GCM messaging and also saw some options where we can have a kind of http server on the phone running but could not understand implementation.
Can someone help with idea and if possible, some piece of code as well.
As I need it for demo, so even any hack solution is fine for me :-)
Thanks for any help or reading.
Your best bet as a hacky solution is to do simple Socket connection between two devices. Since they are on same Wifi, it will be simpler and won't have any firewall restrictions.
Avoid GCM, it requires setting up a GCM Server and then complex registration. It also makes your solution dependent upon Internet connectivity & Google ofcourse.
See an example here:
http://android-er.blogspot.in/2014/02/android-sercerclient-example-client.html
Basically one device such as TV can be a socket listener. The phone/tablet can connect to that socket and then you can initiate a notification on either device based on your requirements and data exchange.

How to make only traffic from some APPs go through VPN in Android?

I want to build a VPN APP on Android basing VPN service. one special requirement of this VPN APP is it has a white list, only traffic come from APPs in this list will go to VPN server. All rest traffic go to what they used to go.
For example, I have a VPN server in USA, and I am in China. I want Facebook goes through VPN. but Youku goes to Youku's server directly.
My first problem here is how can determine some traffic come from which APP?
I know it's possible, because there an APP called no root firewall can block traffic per APP, which is also basing Android VPN service.
https://play.google.com/store/apps/details?id=app.greyshirts.firewall
I'm new to Android, can anybody tell me how to do this?
Thanks in advance!
Have a look at the addAllowedApplication() method, it accepts the packageName who's traffic should be allowed to go through VpnService.

Network Device Discovery

For my Android app, users need to connect to a server that will be hosted somewhere on the same LAN. There can be multiple servers hosted on the same LAN. To make it easy for the user, I was going to scan the current LAN that the Android device is connected to and then list all of the network devices that have the server running on it, rather than having the user input the IP to the computer manually.
I'm fairly new to networking, and after some searching I found out that I would have to use a multi-cast DNS search or UDP broadcast to detect the other devices. I also found a nice library called jmDNS, although I've found very few documentation and sample code on it. Could somebody point me in the right direction for what I'm trying to do to save me wasted time (mostly if I'm on the right track)? I'm assuming that I'll have to modify my server a bit to broadcast it's there? It works completely as intended if I input the IP manually into the configuration page on my app. Also, this only needs to discover Windows computers, not sure if that matters. Thanks in advance.
Well, jmDNS is a complete Java library that you could use for your setup. It can be used to braodcast your services which other clients can search for.
Bounjour service on windows is a bit tricky, although it's definitely possible. The easier way, I would say is to use jmDNS for broadcast and discovery for both your servers and clients.
You would run the jDMs or other service on your local area network as a background service or a dameon.

Programmatically start / launch VPN connection

I am developing Enterprise applications that need to connect to
servers behind the firewall. Can my app start VPN connection
programmatically?
On 2.0+ platforms, VPN is supported by the platform. Assuming user
has already setup VPN parameters, can my app start the VPN
connection? Suppose user has not setup any VPN parameters, can my app
supply those parameters? and start VPN connection?
We're facing this problem at our shop. For now our best shot is trying to use Android internal API to connect to the VPN the same way that the system preferences app does.
First, you need to set up an environment that allows you to access internal API: http://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/
Then we can implement something like this http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.4.4_r1/com/android/settings/vpn2/VpnSettings.java#258
I don't know if we will have any permission issues with this, but IMHO this is the best option we have right now
EDIT: this need root privileges in order to avoid java.lang.SecurityException: Unauthorized Caller errors.
Suppose user has not setup any VPN parameters, can my app supply those parameters? and start VPN connection?
yes, I think it's possible with VpnService class as in this example
Assuming user has already setup VPN parameters, can my app start the VPN connection?
I'm looking for it also. I'm not sure, but I think maybe it can be done with android.net.vpn. See this
AnyConnect by Cisco has private API: http://www.cisco.com/c/en/us/td/docs/security/vpn_client/anyconnect/anyconnect30/administration/guide/anyconnectadmin30/acmobiledevices.html#71308
Yes you can start a VPN connection.what version of android are you using? this link should be useful . give details for better understanding.

Categories

Resources