Skip to content

Commit

Permalink
Initial Library Release
Browse files Browse the repository at this point in the history
  • Loading branch information
consuelita committed Apr 27, 2022
1 parent 78535a4 commit cae1a1a
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 21 deletions.
3 changes: 1 addition & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.test.ext:junit-ktx:1.1.3'
implementation 'com.github.OperatorFoundation:FlowerAndroid:1.0.17'
implementation 'com.github.OperatorFoundation:TransmissionAndroid:1.0.16'
implementation project(path: ':moonbounceVPNService')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
16 changes: 11 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.operatorfoundation.moonbounceAndroidKotlin">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MoonbounceAndroidKotlin">

<activity
android:name=".MainActivity"
android:exported="true">
Expand All @@ -18,17 +23,18 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service
android:name="org.operatorfoundation.moonbounceAndroidKotlin.MBAKVpnService"
android:name="org.operatorfoundation.moonbouncevpnservice.MBAKVpnService"
android:enabled="true"
android:permission="android.permission.BIND_VPN_SERVICE"
android:stopWithTask="false"
android:exported="true">

<intent-filter>
<action android:name="android.net.VpnService"/>
</intent-filter>
</service>
</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import android.widget.EditText
import android.widget.TextView
import androidx.activity.result.contract.ActivityResultContracts
import java.lang.Exception

val SERVER_PORT = "ServerPort"
val SERVER_IP = "ServerIP"
import org.operatorfoundation.moonbouncevpnservice.*

class MainActivity : AppCompatActivity()
{
var ipAddress = ""
var serverPort = 0
lateinit var resultText: TextView

// BroadcastReceiver to show VPN status updates

var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult())
{
result ->
Expand Down Expand Up @@ -113,7 +113,7 @@ class MainActivity : AppCompatActivity()
else // The user has already given permission, and the VPN Service is already prepared
{
// Start the VPN Service
val vpnServiceIntent = Intent(this, MBAKVpnService::class.java)
val vpnServiceIntent = Intent(this, org.operatorfoundation.moonbouncevpnservice.MBAKVpnService::class.java)
vpnServiceIntent.putExtra(SERVER_IP, ipAddress)
vpnServiceIntent.putExtra(SERVER_PORT, serverPort)
startService(vpnServiceIntent)
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:gravity="center_horizontal"
android:hint="Enter Server IP Address "
android:hint="Enter The Server IP Address "
android:inputType="phone"
android:minHeight="48dp"
android:text="0.0.0.0"
android:text=""
android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -29,7 +29,7 @@
android:layout_marginTop="24dp"
android:layout_marginBottom="8dp"
android:gravity="center_horizontal"
android:hint="Enter Server Port Number"
android:hint="Enter The Server Port Number"
android:imeOptions="actionDone"
android:inputType="number"
android:maxLength="5"
Expand Down Expand Up @@ -59,7 +59,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:text="Connect to VPN Service!"
android:text="Connect to VPN"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">MoonbounceAndroidKotlin</string>
<string name="app_name">MoonbounceAndroid</string>
</resources>
1 change: 1 addition & 0 deletions moonbounceVPNService/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
42 changes: 42 additions & 0 deletions moonbounceVPNService/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdk 31

defaultConfig {
minSdk 16
targetSdk 31

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'com.github.OperatorFoundation:FlowerAndroid:1.0.17'
implementation 'com.github.OperatorFoundation:TransmissionAndroid:1.0.16'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Empty file.
21 changes: 21 additions & 0 deletions moonbounceVPNService/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.operatorfoundation.moonbouncevpnservice

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("org.operatorfoundation.moonbouncevpnservice.test", appContext.packageName)
}
}
6 changes: 6 additions & 0 deletions moonbounceVPNService/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.operatorfoundation.moonbouncevpnservice">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package org.operatorfoundation.moonbounceAndroidKotlin
package org.operatorfoundation.moonbouncevpnservice

import android.content.Intent
import android.net.VpnService
import android.os.ParcelFileDescriptor
import org.operatorfoundation.moonbounceAndroidKotlin.NetworkTests
import org.operatorfoundation.flower.*
import org.operatorfoundation.transmission.*
import java.io.FileInputStream
import java.io.FileOutputStream
import kotlin.concurrent.thread

val SERVER_PORT = "ServerPort"
val SERVER_IP = "ServerIP"

class MBAKVpnService: VpnService()
{
private var builder: Builder = Builder()
val networkTests = NetworkTests()
var transportServerIP = ""
var transportServerPort = 1234
val dnsServerIP = "8.8.8.8"
Expand Down Expand Up @@ -57,8 +60,6 @@ class MBAKVpnService: VpnService()
runServerToVPN(flowerConnection, inputStream, outputStream)
}

val networkTests = NetworkTests()

println("🌙 MBAKVpnService: Launching UDP Test")
thread(start = true) {
// FIXME: Use a valid server IP and port
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.operatorfoundation.moonbounceAndroidKotlin
package org.operatorfoundation.moonbouncevpnservice

import org.operatorfoundation.transmission.ConnectionType
import org.operatorfoundation.transmission.TransmissionConnection
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.operatorfoundation.moonbouncevpnservice

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dependencyResolutionManagement {
}
rootProject.name = "MoonbounceAndroidKotlin"
include ':app'
include ':moonbounceVPNService'

0 comments on commit cae1a1a

Please sign in to comment.