-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5964573
commit 5d02888
Showing
3 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...eVPNService/src/main/java/org/operatorfoundation/moonbouncevpnservice/MoonbounceJava.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.operatorfoundation.moonbouncevpnservice; | ||
|
||
import android.content.Context; | ||
|
||
public class MoonbounceJava | ||
{ | ||
MoonbounceKotlin moonbounceKotlin; | ||
|
||
public MoonbounceJava(Context context, String serverIP, Integer serverPort, String disallowedApp, String excludeIP) | ||
{ | ||
moonbounceKotlin = new MoonbounceKotlin(context, serverIP, serverPort, disallowedApp, excludeIP); | ||
} | ||
public void startVPN() | ||
{ | ||
moonbounceKotlin.startVPN(); | ||
} | ||
|
||
public void stopVPN() | ||
{ | ||
moonbounceKotlin.stopVPN(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...eVPNService/src/main/java/org/operatorfoundation/moonbouncevpnservice/MoonbounceKotlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.operatorfoundation.moonbouncevpnservice | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
|
||
class MoonbounceKotlin(val context: Context, var ipAddress: String, var serverPort: Int, var disallowedApp: String? = null, var excludeRoute: String? = null) | ||
{ | ||
var vpnServiceIntent: Intent? = null | ||
|
||
fun startVPN() | ||
{ | ||
if (vpnServiceIntent == null) | ||
{ | ||
vpnServiceIntent = Intent(context, MBAKVpnService::class.java) | ||
} | ||
|
||
println("MainActivity Server IP Address: $ipAddress") | ||
println("MainActivity Server Port: $serverPort") | ||
println("MainActivity Disallowed App: $disallowedApp") | ||
println("MainActivity Exclude Route: $excludeRoute") | ||
|
||
vpnServiceIntent!!.putExtra(SERVER_IP, ipAddress) | ||
vpnServiceIntent!!.putExtra(SERVER_PORT, serverPort) | ||
|
||
if (!disallowedApp.isNullOrEmpty()) | ||
{ | ||
vpnServiceIntent!!.putExtra(DISALLOWED_APP, disallowedApp) | ||
} | ||
|
||
if (!excludeRoute.isNullOrEmpty()) | ||
{ | ||
vpnServiceIntent!!.putExtra(EXCLUDE_ROUTE, excludeRoute) | ||
} | ||
|
||
// Start the VPN Service | ||
context.startService(vpnServiceIntent) | ||
} | ||
|
||
fun stopVPN() | ||
{ | ||
context.stopService(vpnServiceIntent) | ||
} | ||
} |