{
+ val clientSocket = Socket("localhost", PORT)
+ val outToServer = DataOutputStream(clientSocket.getOutputStream())
+ val inFromServer = BufferedReader(InputStreamReader(clientSocket.getInputStream()))
+ val data = TCPData(action, message)
+ outToServer.writeBytes(data.toJson() + '\n')
+ val result = inFromServer.readLine()
+ clientSocket.close()
+ "onReceived: $result".print()
+ it.onNext(result ?: "")
+ }.onErrorResumeNext {
+ it.printStackTrace()
+ Observable.just("")
+ }.subscribeOn(Schedulers.io())
+ }
+
+ data class TCPData(
+ @SerializedName("action")
+ var action: String?,
+ @SerializedName("data")
+ var data: String?
+ )
+}
\ No newline at end of file
diff --git a/ipc/src/test/java/com/wrbug/developerhelper/ipc/ExampleUnitTest.java b/ipc/src/test/java/com/wrbug/developerhelper/ipc/ExampleUnitTest.java
deleted file mode 100644
index 753cad4..0000000
--- a/ipc/src/test/java/com/wrbug/developerhelper/ipc/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.wrbug.developerhelper.ipc;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/mmkv/build.gradle b/mmkv/build.gradle
index 1f89e36..5c77bb5 100644
--- a/mmkv/build.gradle
+++ b/mmkv/build.gradle
@@ -1,21 +1,26 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
+apply from: "${rootDir}/common.gradle"
android {
- compileSdkVersion 28
-
-
+ namespace "com.wrbug.developerhelper.mmkv"
+ compileSdk 34
defaultConfig {
- minSdkVersion 21
- targetSdkVersion 28
+ minSdkVersion 23
+ targetSdkVersion 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
+ compileOptions {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
+ }
+ kotlinOptions { jvmTarget = "17" }
buildTypes {
release {
minifyEnabled false
@@ -27,14 +32,7 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'com.tencent:mmkv:1.0.14'
- implementation 'androidx.appcompat:appcompat:1.0.2'
- testImplementation 'junit:junit:4.12'
- androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
- implementation 'com.google.code.gson:gson:2.8.5'
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
-}
-repositories {
- mavenCentral()
+ implementation 'com.tencent:mmkv:1.3.9'
+ implementation 'androidx.appcompat:appcompat:1.7.0'
+ implementation 'com.google.code.gson:gson:2.10'
}
diff --git a/mmkv/src/androidTest/java/com/wrbug/developerhelper/mmkv/ExampleInstrumentedTest.java b/mmkv/src/androidTest/java/com/wrbug/developerhelper/mmkv/ExampleInstrumentedTest.java
deleted file mode 100644
index 161e03c..0000000
--- a/mmkv/src/androidTest/java/com/wrbug/developerhelper/mmkv/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.wrbug.developerhelper.mmkv;
-
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.wrbug.developerhelper.mmkv.test", appContext.getPackageName());
- }
-}
diff --git a/mmkv/src/test/java/com/wrbug/developerhelper/mmkv/ExampleUnitTest.java b/mmkv/src/test/java/com/wrbug/developerhelper/mmkv/ExampleUnitTest.java
deleted file mode 100644
index 9b42f39..0000000
--- a/mmkv/src/test/java/com/wrbug/developerhelper/mmkv/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.wrbug.developerhelper.mmkv;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/netbare-core/.gitignore b/netbare-core/.gitignore
deleted file mode 100644
index 796b96d..0000000
--- a/netbare-core/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/netbare-core/build.gradle b/netbare-core/build.gradle
deleted file mode 100644
index 1784f6e..0000000
--- a/netbare-core/build.gradle
+++ /dev/null
@@ -1,30 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 28
-
- defaultConfig {
- minSdkVersion 21
- targetSdkVersion 28
- versionCode 1
- versionName "1.0"
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
-
- implementation 'com.android.support:appcompat-v7:28.0.0'
-
- implementation 'org.bouncycastle:bcpkix-jdk15on:1.56'
- implementation 'org.bouncycastle:bcprov-jdk15on:1.56'
- implementation 'com.google.guava:guava:19.0'
-}
diff --git a/netbare-core/src/main/AndroidManifest.xml b/netbare-core/src/main/AndroidManifest.xml
deleted file mode 100644
index b4a5f13..0000000
--- a/netbare-core/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/netbare-core/src/main/java/com/github/megatronking/netbare/NetBare.java b/netbare-core/src/main/java/com/github/megatronking/netbare/NetBare.java
deleted file mode 100644
index e1b51cd..0000000
--- a/netbare-core/src/main/java/com/github/megatronking/netbare/NetBare.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/* NetBare - An android network capture and injection library.
- * Copyright (C) 2018-2019 Megatron King
- * Copyright (C) 2018-2019 GuoShi
- *
- * NetBare is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
- *
- * NetBare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with NetBare.
- * If not, see .
- */
-package com.github.megatronking.netbare;
-
-import android.app.Activity;
-import android.app.Application;
-import android.content.Intent;
-import android.net.VpnService;
-import android.os.Handler;
-import android.os.Looper;
-import androidx.annotation.NonNull;
-
-import androidx.core.content.ContextCompat;
-import com.github.megatronking.netbare.gateway.DefaultVirtualGatewayFactory;
-import com.github.megatronking.netbare.gateway.VirtualGatewayFactory;
-import com.github.megatronking.netbare.ssl.JKS;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-/**
- * NetBare is a single instance, we can use this class to config and manage the NetBare service.
- * The NetBare service is an implement class of {@link VpnService}, before starting this service,
- * should call {@link #prepare()} to check the vpn state.
- *
- * Start and stop the NetBare service:
- *
- *
- * NetBare.get().start(config);
- * NetBare.get().stop();
- *
- *
- *
- * @author Megatron King
- * @since 2018年10月07日 09:28
- */
-public final class NetBare {
-
- private static class Holder {
-
- private static final NetBare INSTANCE = new NetBare();
-
- }
-
- private final Set mListeners;
- private final Handler mMainThreadHandler;
-
- private Application mApp;
- private NetBareConfig mNetBareConfig;
-
- private boolean mAlive;
-
- public static NetBare get() {
- return Holder.INSTANCE;
- }
-
- private NetBare() {
- mListeners = new LinkedHashSet();
- mMainThreadHandler = new Handler(Looper.getMainLooper());
- }
-
- /**
- * Attach an application instance to NetBare. We recommend you to call this method in your
- * {@link Application} class.
- *
- * @param application The application instance.
- * @param debug Should print logs in console.
- * @return The single instance of NetBare.
- */
- public NetBare attachApplication(@NonNull Application application, boolean debug) {
- JKS.init(application);
- mApp = application;
- NetBareLog.setDebug(debug);
- return this;
- }
-
- /**
- * Prepare to establish a VPN connection. This method returns {@code null} if the VPN
- * application is already prepared or if the user has previously consented to the VPN
- * application. Otherwise, it returns an {@link Intent} to a system activity. The application
- * should launch the activity using {@link Activity#startActivityForResult} to get itself
- * prepared.
- *
- * @return The intent to call using {@link Activity#startActivityForResult}.
- */
- public Intent prepare() {
- return VpnService.prepare(mApp);
- }
-
- /**
- * Start the NetBare service with your specific configuration. If the service is started,
- * {@link NetBareListener#onServiceStarted()} will be invoked.
- *
- * @param config The configuration for NetBare service.
- */
- public void start(@NonNull NetBareConfig config) {
- if (config.mtu <= 0) { - throw new RuntimeException("Must set mtu in NetBareConfig"); - } - if (config.address == null) { - throw new RuntimeException("Must set address in NetBareConfig"); - } - mNetBareConfig = config; - Intent intent = new Intent(NetBareService.ACTION_START); - intent.setPackage(mApp.getPackageName()); - ContextCompat.startForegroundService(mApp, intent); - } - - /** - * Stop the NetBare service. If the service is started, - * {@link NetBareListener#onServiceStopped()} will be invoked. - */ - public void stop() { - Intent intent = new Intent(NetBareService.ACTION_STOP); - intent.setPackage(mApp.getPackageName()); - mApp.startService(intent); - } - - /** - * Whether the NetBare service is alive or not. - * - * @return True if the service is alive, false otherwise. - */ - public boolean isActive() { - return mAlive; - } - - /** - * Register a callback to be invoked when the service state changes. - * - * @param listener The callback to register. - */ - public void registerNetBareListener(NetBareListener listener) { - mListeners.add(listener); - } - - /** - * Remove a previously installed service state callback. - * - * @param listener The callback to remove. - */ - public void unregisterNetBareListener(NetBareListener listener) { - mListeners.remove(listener); - } - - /* package */ NetBareConfig getConfig() { - return mNetBareConfig; - } - - /* package */ VirtualGatewayFactory getGatewayFactory() { - // Make sure the virtual gateway not be null. - return mNetBareConfig.gatewayFactory == null ? DefaultVirtualGatewayFactory.create() : - mNetBareConfig.gatewayFactory; - } - - /* package */ void notifyServiceStarted() { - mAlive = true; - mMainThreadHandler.post(new Runnable() { - @Override - public void run() { - for (NetBareListener listener : mListeners) { - listener.onServiceStarted(); - } - } - }); - } - - /* package */ void notifyServiceStopped() { - mAlive = false; - mMainThreadHandler.post(new Runnable() { - @Override - public void run() { - for (NetBareListener listener : mListeners) { - listener.onServiceStopped(); - } - } - }); - } - -} diff --git a/netbare-core/src/main/java/com/github/megatronking/netbare/NetBareConfig.java b/netbare-core/src/main/java/com/github/megatronking/netbare/NetBareConfig.java deleted file mode 100644 index c690a03..0000000 --- a/netbare-core/src/main/java/com/github/megatronking/netbare/NetBareConfig.java +++ /dev/null @@ -1,307 +0,0 @@ -/* NetBare - An android network capture and injection library. - * Copyright (C) 2018-2019 Megatron King - * Copyright (C) 2018-2019 GuoShi - * - * NetBare is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * NetBare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with NetBare. - * If not, see .
- */
-package com.github.megatronking.netbare;
-
-import android.app.PendingIntent;
-import androidx.annotation.NonNull;
-
-import com.github.megatronking.netbare.gateway.VirtualGatewayFactory;
-import com.github.megatronking.netbare.http.HttpInterceptorFactory;
-import com.github.megatronking.netbare.http.HttpVirtualGatewayFactory;
-import com.github.megatronking.netbare.ip.IpAddress;
-import com.github.megatronking.netbare.net.Session;
-import com.github.megatronking.netbare.net.UidProvider;
-import com.github.megatronking.netbare.ssl.JKS;
-
-import java.net.InetAddress;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * The configuration class for NetBare. Use {@link Builder} to construct an instance.
- *
- * @author Megatron King
- * @since 2018年10月07日 11:20
- */
-public final class NetBareConfig {
-
- String session;
- PendingIntent configureIntent;
- int mtu;
- IpAddress address;
- Set routes;
- Set dnsServers;
- Set allowedApplications;
- Set disallowedApplications;
- Set allowedHosts;
- Set