├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── stop.png │ │ │ │ ├── start.png │ │ │ │ └── settings.jpg │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── arrays.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── fragment_capture.xml │ │ │ │ ├── activity_packet_detail.xml │ │ │ │ ├── fragment_firewall.xml │ │ │ │ ├── item_package.xml │ │ │ │ ├── activity_package_list.xml │ │ │ │ ├── activity_main.xml │ │ │ │ └── item_packet.xml │ │ │ ├── menu │ │ │ │ └── toolbar.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── mingxiangChen │ │ │ │ └── droidnet │ │ │ │ ├── dialog │ │ │ │ ├── TableChanged.java │ │ │ │ └── BaseDialog.java │ │ │ │ ├── fragment │ │ │ │ ├── PacketCapturedListener.java │ │ │ │ ├── BaseFragment.java │ │ │ │ ├── ToastFirewallHandler.java │ │ │ │ ├── AddPacketHandler.java │ │ │ │ ├── CaptureFragment.java │ │ │ │ └── PacketShowInfo.java │ │ │ │ ├── SwitcherListener.java │ │ │ │ ├── activity │ │ │ │ ├── PacketDetailActivity.java │ │ │ │ ├── PackageListActivity.java │ │ │ │ └── PackageShowInfoAdapter.java │ │ │ │ ├── interceptor │ │ │ │ ├── FirewallInterceptorFactory.java │ │ │ │ ├── CaptureRawInterceptorFactory.java │ │ │ │ ├── HttpUrlPrintInterceptor.java │ │ │ │ └── RawTcpPrintInterceptor.java │ │ │ │ ├── util │ │ │ │ └── ThreadProxy.java │ │ │ │ ├── gateway │ │ │ │ ├── RawTcpVirtualGatewayFactory.java │ │ │ │ ├── FirewallVirtualGatewayFactory.java │ │ │ │ ├── FirewallVirtualGateway.java │ │ │ │ ├── RawTcpVirtualGateway.java │ │ │ │ └── DroidNetVirtualGatewayFactory.java │ │ │ │ ├── table │ │ │ │ └── InterceptRules.java │ │ │ │ └── AppService.java │ │ ├── AndroidManifest.xml │ │ └── assets │ │ │ └── litepal.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── mingxiangChen │ │ │ └── droidnet │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── mingxiangChen │ │ └── droidnet │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── netbare-core ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── megatronking │ │ │ └── netbare │ │ │ ├── net │ │ │ ├── UidProvider.java │ │ │ ├── DumpCallback.java │ │ │ ├── Net.java │ │ │ └── Session.java │ │ │ ├── http2 │ │ │ ├── Http2Updater.java │ │ │ ├── EncodeCallback.java │ │ │ ├── Http2Stream.java │ │ │ ├── DecodeCallback.java │ │ │ ├── Http2.java │ │ │ └── ErrorCode.java │ │ │ ├── http │ │ │ ├── HttpIndexedInterceptor.java │ │ │ ├── HttpPendingIndexedInterceptor.java │ │ │ ├── HttpId.java │ │ │ ├── HttpInterceptorsFactory.java │ │ │ ├── HttpInterceptor.java │ │ │ ├── HttpInterceptorFactory.java │ │ │ ├── HttpSessionFactory.java │ │ │ ├── HttpSession.java │ │ │ ├── HttpSSLRefluxInterceptor.java │ │ │ ├── HttpRequestChain.java │ │ │ └── HttpResponseChain.java │ │ │ ├── tunnel │ │ │ ├── Tunnel.java │ │ │ ├── ConnectionShutdownException.java │ │ │ ├── VirtualGatewayTunnel.java │ │ │ ├── NioCallback.java │ │ │ ├── UdpTunnel.java │ │ │ ├── TcpProxyTunnel.java │ │ │ ├── UdpRemoteTunnel.java │ │ │ ├── TcpTunnel.java │ │ │ └── TcpRemoteTunnel.java │ │ │ ├── gateway │ │ │ ├── TunnelFlow.java │ │ │ ├── VirtualGatewayFactory.java │ │ │ ├── InterceptorFactory.java │ │ │ ├── Response.java │ │ │ ├── Request.java │ │ │ ├── AbstractRequestChain.java │ │ │ ├── AbstractResponseChain.java │ │ │ ├── RequestChain.java │ │ │ ├── ResponseChain.java │ │ │ ├── DefaultVirtualGatewayFactory.java │ │ │ └── DefaultVirtualGateway.java │ │ │ ├── ssl │ │ │ ├── SSLRefluxCallback.java │ │ │ ├── SSLKeyManagerProvider.java │ │ │ ├── SSLTrustManagerProvider.java │ │ │ └── SSLRequestCodec.java │ │ │ ├── NetBareListener.java │ │ │ ├── proxy │ │ │ ├── ProxyServerForwarder.java │ │ │ ├── IcmpProxyServerForwarder.java │ │ │ ├── ProxyServer.java │ │ │ └── BaseProxyServer.java │ │ │ ├── tcp │ │ │ └── TcpVirtualGateway.java │ │ │ ├── udp │ │ │ └── UdpVirtualGateway.java │ │ │ ├── ip │ │ │ ├── Protocol.java │ │ │ ├── IpAddress.java │ │ │ └── Header.java │ │ │ └── ws │ │ │ └── WebSocketCallback.java │ │ └── res │ │ └── values │ │ └── styles.xml └── build.gradle ├── netbare-injector ├── .gitignore ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── github │ │ └── megatronking │ │ └── netbare │ │ ├── http │ │ ├── HttpBody.java │ │ ├── HttpRawBody.java │ │ ├── HttpResponseInjectorCallback.java │ │ └── HttpRequestInjectorCallback.java │ │ ├── stream │ │ ├── Stream.java │ │ ├── StringStream.java │ │ ├── BufferStream.java │ │ ├── ByteStream.java │ │ └── TinyFileStream.java │ │ ├── injector │ │ ├── InjectorCallback.java │ │ └── BlockedHttpInjector.java │ │ └── io │ │ ├── HttpBodyInputStream.java │ │ └── ByteBufferInputStream.java └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── encodings.xml ├── vcs.xml ├── misc.xml ├── runConfigurations.xml └── gradle.xml ├── .gitignore ├── gradle.properties └── gradlew.bat /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /netbare-core/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /netbare-injector/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':netbare-core', ':netbare-injector' 2 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/drawable/stop.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/drawable/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/drawable/start.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/settings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/drawable/settings.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RSencoder/DroidNet/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /netbare-injector/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 抓包 5 | 防火墙 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Apr 21 13:53:04 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/mingxiangChen/droidnet/dialog/TableChanged.java: -------------------------------------------------------------------------------- 1 | package com.mingxiangChen.droidnet.dialog; 2 | 3 | /** 4 | * A interface invoked when dialog operates the table 5 | * {@link com.mingxiangChen.droidnet.table.InterceptRules}. SmartTable calls the interface method to 6 | * update UI data. 7 | * 8 | * @author RSmxchen 9 | * @since 2019-05-09 16:40 10 | */ 11 | public interface TableChanged { 12 | void onTableChanged(); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/test/java/com/mingxiangChen/droidnet/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.mingxiangChen.droidnet; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_capture.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/java/com/mingxiangChen/droidnet/fragment/PacketCapturedListener.java: -------------------------------------------------------------------------------- 1 | package com.mingxiangChen.droidnet.fragment; 2 | 3 | /** 4 | * A callback which invoked when {@link com.mingxiangChen.droidnet.interceptor.CaptureRawInterceptor} 5 | * intercept() method captures a packet. Let the {@link CaptureFragment} know to refresh the recyclerView. 6 | * So the adapter of the recyclerView should implement this interface. 7 | * 8 | * @author RSmxchen 9 | * @since 2019-05-13 00:35 10 | */ 11 | public interface PacketCapturedListener { 12 | void onPacketCaptured(PacketShowInfo info); 13 | } 14 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /netbare-core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /netbare-core/src/main/java/com/github/megatronking/netbare/net/UidProvider.java: -------------------------------------------------------------------------------- 1 | package com.github.megatronking.netbare.net; 2 | 3 | /** 4 | * This interface provides a known uid for a session. 5 | * 6 | * @author Megatron King 7 | * @since 2019/1/27 21:31 8 | */ 9 | public interface UidProvider { 10 | 11 | int UID_UNKNOWN = -1; 12 | 13 | /** 14 | * Returns a known uid for this session, if the uid is unknown should return {@link #UID_UNKNOWN}. 15 | * 16 | * @param session Network session. 17 | * @return A known uid or {@link #UID_UNKNOWN}. 18 | */ 19 | int uid(Session session); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /netbare-injector/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | minSdkVersion 21 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | 20 | } 21 | 22 | dependencies { 23 | implementation project(':netbare-core') 24 | implementation 'com.android.support:appcompat-v7:28.0.0' 25 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_packet_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /netbare-core/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | minSdkVersion 21 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | } 12 | 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | 25 | implementation 'com.android.support:appcompat-v7:28.0.0' 26 | 27 | implementation 'org.bouncycastle:bcpkix-jdk15on:1.56' 28 | implementation 'org.bouncycastle:bcprov-jdk15on:1.56' 29 | implementation 'com.google.guava:guava:19.0' 30 | } 31 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/mingxiangChen/droidnet/fragment/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.mingxiangChen.droidnet.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | /** 11 | * I don't know how to explain now...just imitates the NetworkPacketCapture project. 12 | * 13 | * @author RSmxchen 14 | * @since 2019-05-04 13:49 15 | */ 16 | public abstract class BaseFragment extends Fragment { 17 | @Nullable 18 | @Override 19 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { 20 | return inflater.inflate(getLayout(), container, false); 21 | } 22 | 23 | abstract int getLayout(); 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/menu/toolbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/mingxiangChen/droidnet/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.mingxiangChen.droidnet; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.mingxiangChen.droidnet", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/mingxiangChen/droidnet/SwitcherListener.java: -------------------------------------------------------------------------------- 1 | package com.mingxiangChen.droidnet; 2 | 3 | /** 4 | * Interface definition for a {@link com.github.megatronking.netbare.gateway.VirtualGateway} that 5 | * monitors user operations on DroidNet. 6 | * 7 | * @author RSmxchen 8 | * @since 2019-05-01 15:41 9 | */ 10 | public interface SwitcherListener { 11 | 12 | /** 13 | * Callback method to be invoked when the user clicks capture start button. 14 | */ 15 | void captureOn(); 16 | 17 | /** 18 | * Callback method to be invoked when the user clicks capture stop button. 19 | */ 20 | void captureOff(); 21 | 22 | /** 23 | * Callback method to be invoked when the user clicks firewall start button. 24 | */ 25 | void firewallOn(); 26 | 27 | /** 28 | * Callback method to be invoked when the user clicks firewall stop button. 29 | */ 30 | void firewallOff(); 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/mingxiangChen/droidnet/fragment/ToastFirewallHandler.java: -------------------------------------------------------------------------------- 1 | package com.mingxiangChen.droidnet.fragment; 2 | 3 | import android.content.Context; 4 | import android.os.Handler; 5 | import android.os.Message; 6 | import android.widget.Toast; 7 | 8 | /** 9 | * A {@link Handler} designed for {@link com.mingxiangChen.droidnet.interceptor.FirewallInterceptor}, 10 | * which lets FirewallInterceptor show a interception toast in proxy server thread. 11 | * 12 | * @author RSmxchen 13 | * @since 2019-06-03 18:00 14 | */ 15 | public class ToastFirewallHandler extends Handler { 16 | 17 | private Context mContext; 18 | 19 | public void setContext(Context mContext) { 20 | this.mContext = mContext; 21 | } 22 | 23 | @Override 24 | public void handleMessage(Message msg) { 25 | String toastString = (String) msg.obj; 26 | Toast.makeText(mContext, toastString, Toast.LENGTH_SHORT).show(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_firewall.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 12 | 13 | 18 | 19 |