Hello everyone
This library enables you to connect to proxy servers using Android's VpnService.
*Please use the latest library version 2.0
It will work globally meaning it will work in the background of the user's phone and not just in your application.
How to use :
1- Copy the Jar & Xml files to your internal library folder
2- In your manifest file add the following :
*You can change the VPN sticky notification service name by changing the following :
To what whatever you would like.
3- In the Globals sub Add:
4- Initialize the service :
5- Then Create the service (it will prepare the VPN to create a profile in the system settings) :
6- Set the Proxy server IP & Port :
Example :
*If the user is running your application for the first time then he/she will be prompted with the VPN permission dialog to accept the creation of the Proxy VPN profile, once accepted the service will start automatically
-----
7- To Stop the service :
8- To Start the service : You Should only call this method if the service is stopped, or this is not the first time the user started the service.
Complete Example :
Update Version 1.5:
You can now add DNS servers to your proxy connection without any root
Example :
Update Version 2.0:
You can now use the DNS Changer without the need to establish a proxy connection, simple download the library version 2.0, below is the use case example :
After testing and reports, it seems that the DNS service will not run without setting up the proxy connection first.
So you have to set up a proxy connection first then you are able to change the DNS.
Example :
Thank you,
Saif
This library enables you to connect to proxy servers using Android's VpnService.
*Please use the latest library version 2.0
It will work globally meaning it will work in the background of the user's phone and not just in your application.
How to use :
1- Copy the Jar & Xml files to your internal library folder
2- In your manifest file add the following :
B4X:
AddPermission(android.permission.ACCESS_WIFI_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.BIND_VPN_SERVICE)
AddApplicationText(
<service android:name="com.b4xcode.proxyclient.LocalVpnService"
android:label="B4XCode Proxy Service"
android:permission="android.permission.BIND_VPN_SERVICE">
<intent-filter>
<action android:name="android.net.VpnService" />
</intent-filter>
</service>)
SetApplicationAttribute(android:usesCleartextTraffic, "true")
*You can change the VPN sticky notification service name by changing the following :
B4X:
android:label="B4XCode Proxy Service"
3- In the Globals sub Add:
Globals:
Sub Globals
Dim b4xpc As B4XCodeProxyConnector
End Sub
4- Initialize the service :
B4X:
b4xpc.Initialize
5- Then Create the service (it will prepare the VPN to create a profile in the system settings) :
B4X:
b4xpc.CreateService
6- Set the Proxy server IP & Port :
B4X:
b4xpc.SetProxyServer("Proxy Server IP",Proxy Server Port)
B4X:
b4xpc.SetProxyServer("5.44.54.16",8080)
*If the user is running your application for the first time then he/she will be prompted with the VPN permission dialog to accept the creation of the Proxy VPN profile, once accepted the service will start automatically
-----
7- To Stop the service :
B4X:
b4xpc.StopProxyService
8- To Start the service : You Should only call this method if the service is stopped, or this is not the first time the user started the service.
B4X:
b4xpc.StartProxyService
Complete Example :
Example:
Sub Globals
Dim b4xpc As B4XCodeProxyConnector
End Sub
Sub Activity_Create(FirstTime As Boolean)
b4xpc.Initialize
b4xpc.CreateService
b4xpc.SetProxyServer("5.44.54.16",8080)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
b4xpc.StopProxyService
End If
End Sub
Update Version 1.5:
You can now add DNS servers to your proxy connection without any root
Example :
DNS Routing:
Sub Globals
Dim b4xpc As B4XCodeProxyConnector
End Sub
Sub Activity_Create(FirstTime As Boolean)
b4xpc.Initialize
b4xpc.AddDNSRoute("195.46.39.39")
b4xpc.AddDNSRoute("208.67.220.220")
b4xpc.CreateService
b4xpc.SetProxyServer("94.127.212.200",5900)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
b4xpc.StopProxyService
End If
End Sub
Update Version 2.0:
After testing and reports, it seems that the DNS service will not run without setting up the proxy connection first.
So you have to set up a proxy connection first then you are able to change the DNS.
Example :
DNS Routing:
Sub Globals
Dim b4xpc As B4XCodeProxyConnector
End Sub
Sub Activity_Create(FirstTime As Boolean)
b4xpc.Initialize
b4xpc.AddDNSRoute("195.46.39.39")
b4xpc.AddDNSRoute("208.67.220.220")
b4xpc.CreateService
b4xpc.SetProxyServer("94.127.212.200",5900)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
b4xpc.StopProxyService
End If
End Sub
Thank you,
Saif
Attachments
Last edited: