mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-30 11:21:21 +00:00
Switch from Gradle experimental to cmake
This commit is contained in:
parent
fd28060e9e
commit
38e8c5698e
19 changed files with 297 additions and 438 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea
|
||||
|
@ -7,3 +8,4 @@
|
|||
/build
|
||||
/captures
|
||||
/tools/config.sh
|
||||
app/.externalNativeBuild
|
||||
|
|
23
app/CMakeLists.txt
Normal file
23
app/CMakeLists.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
|
||||
add_library( netguard
|
||||
SHARED
|
||||
src/main/jni/netguard/netguard.c
|
||||
src/main/jni/netguard/session.c
|
||||
src/main/jni/netguard/ip.c
|
||||
src/main/jni/netguard/tcp.c
|
||||
src/main/jni/netguard/udp.c
|
||||
src/main/jni/netguard/icmp.c
|
||||
src/main/jni/netguard/dns.c
|
||||
src/main/jni/netguard/dhcp.c
|
||||
src/main/jni/netguard/pcap.c
|
||||
src/main/jni/netguard/util.c )
|
||||
|
||||
include_directories( src/main/jni/netguard/ )
|
||||
|
||||
find_library( log-lib
|
||||
log )
|
||||
|
||||
target_link_libraries( netguard
|
||||
${log-lib} )
|
204
app/app.iml
204
app/app.iml
|
@ -8,11 +8,11 @@
|
|||
</facet>
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="allDebug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleAllDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileAllDebugSources" />
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
|
||||
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
|
||||
<afterSyncTasks>
|
||||
<task>generateAllDebugSources</task>
|
||||
<task>generateDebugSources</task>
|
||||
</afterSyncTasks>
|
||||
<option name="ALLOW_USER_CONFIGURATION" value="false" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
||||
|
@ -23,78 +23,48 @@
|
|||
</facet>
|
||||
<facet type="native-android-gradle" name="Native-Android-Gradle">
|
||||
<configuration>
|
||||
<option name="SELECTED_BUILD_VARIANT" value="allDebug" />
|
||||
<option name="SELECTED_BUILD_VARIANT" value="debug" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/all/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/all/debug" />
|
||||
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
|
||||
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/all/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/all/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/all/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/all/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/all/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/all/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/all/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/renderscript" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/allDebug/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/all/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/all/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/all/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/all/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/all/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/all/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/all/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAllDebug/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/renderscript" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/all/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testAll/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestAll/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni/netguard" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/google-services/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/renderscript" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
|
||||
|
@ -108,39 +78,43 @@
|
|||
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/renderscript" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/renderscript" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/renderscript" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/binaries" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes-jar" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/cmake" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/objectFiles" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
|
||||
|
@ -148,42 +122,42 @@
|
|||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-iid-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-tasks-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-media-compat-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:recyclerview-v7-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-ads-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="android.arch.lifecycle:common:1.0.0@jar" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-base-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-fragment-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-vector-drawable-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="android.arch.lifecycle:runtime-1.0.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:appcompat-v7-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-basement-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-annotations:26.1.0@jar" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-basement-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-analytics-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-core-utils-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-core-ui-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-iid-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-ads-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-compat-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-common-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="android.arch.core:common:1.0.0@jar" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-ads-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-ads-lite-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-tasks-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-core-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-gass-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-common-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:support-v4-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.android.support:animated-vector-drawable-26.1.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-ads-lite-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.squareup.picasso:picasso:2.5.2@jar" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-base-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-analytics-impl-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-analytics-impl-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.android.gms:play-services-gass-11.4.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="com.google.firebase:firebase-analytics-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-iid-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-tasks-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-media-compat-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:recyclerview-v7-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-ads-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="android.arch.lifecycle:common:1.0.0@jar" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-base-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-fragment-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-vector-drawable-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="android.arch.lifecycle:runtime-1.0.0" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:appcompat-v7-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-basement-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-annotations:26.1.0@jar" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-basement-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-analytics-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-core-utils-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-core-ui-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-iid-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-ads-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-compat-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-common-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="android.arch.core:common:1.0.0@jar" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-ads-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-ads-lite-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-tasks-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-core-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-gass-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-common-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:support-v4-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.android.support:animated-vector-drawable-26.1.0" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-ads-lite-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.squareup.picasso:picasso:2.5.2@jar" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-base-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-analytics-impl-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-analytics-impl-license-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.android.gms:play-services-gass-11.4.2" level="project" />
|
||||
<orderEntry type="library" name="com.google.firebase:firebase-analytics-license-11.4.2" level="project" />
|
||||
</component>
|
||||
</module>
|
113
app/build.gradle
113
app/build.gradle
|
@ -1,101 +1,66 @@
|
|||
apply plugin: 'com.android.model.application'
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
model {
|
||||
android {
|
||||
compileSdkVersion = 26
|
||||
buildToolsVersion = "26.0.2"
|
||||
android {
|
||||
compileSdkVersion = 26
|
||||
buildToolsVersion = "26.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "eu.faircode.netguard"
|
||||
}
|
||||
defaultConfig {
|
||||
applicationId = "eu.faircode.netguard"
|
||||
versionName = "2.142"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 26
|
||||
versionCode = 2017102301
|
||||
archivesBaseName = "NetGuard-v$versionName"
|
||||
|
||||
compileOptions.with {
|
||||
sourceCompatibility JavaVersion.VERSION_1_7
|
||||
targetCompatibility JavaVersion.VERSION_1_7
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
cppFlags ""
|
||||
arguments "-DANDROID_PLATFORM=android-14"
|
||||
// https://developer.android.com/ndk/guides/cmake.html
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
platformVersion = "14"
|
||||
moduleName = "netguard"
|
||||
toolchain = "clang"
|
||||
ldLibs.add("log")
|
||||
abiFilters 'armeabi', 'x86'
|
||||
}
|
||||
}
|
||||
|
||||
sources {
|
||||
main {
|
||||
jni {
|
||||
source {
|
||||
srcDirs.removeAll()
|
||||
srcDirs.add('src/main/jni/netguard')
|
||||
}
|
||||
exportedHeaders {
|
||||
}
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled = true
|
||||
useProguard = true
|
||||
proguardFiles.add(file('proguard-rules.pro'))
|
||||
ndk.with {
|
||||
debuggable = false
|
||||
}
|
||||
}
|
||||
debug {
|
||||
minifyEnabled = true
|
||||
useProguard = true
|
||||
proguardFiles.add(file('proguard-rules.pro'))
|
||||
ndk.with {
|
||||
debuggable = false
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled = true
|
||||
useProguard = true
|
||||
proguardFiles.add(file('proguard-rules.pro'))
|
||||
}
|
||||
|
||||
productFlavors {
|
||||
create("all") {
|
||||
versionName = "2.141"
|
||||
minSdkVersion.apiLevel = 14
|
||||
targetSdkVersion.apiLevel = 26
|
||||
versionCode = 2017102202
|
||||
archivesBaseName = "NetGuard-v$versionName"
|
||||
}
|
||||
create("lollipop-and-later") {
|
||||
versionName = "2.141"
|
||||
minSdkVersion.apiLevel = 20
|
||||
targetSdkVersion.apiLevel = 26
|
||||
versionCode = 2017102212
|
||||
archivesBaseName = "NetGuard-v$versionName"
|
||||
}
|
||||
create("kitkat-and-earlier") {
|
||||
versionName = "2.141"
|
||||
minSdkVersion.apiLevel = 14
|
||||
maxSdkVersion = 19
|
||||
targetSdkVersion.apiLevel = 26
|
||||
versionCode = 2017102222
|
||||
archivesBaseName = "NetGuard-v$versionName"
|
||||
}
|
||||
debug {
|
||||
minifyEnabled = true
|
||||
useProguard = true
|
||||
proguardFiles.add(file('proguard-rules.pro'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
// https://developer.android.com/topic/libraries/support-library/revisions.html
|
||||
compile 'com.android.support:appcompat-v7:26.1.+'
|
||||
compile 'com.android.support:recyclerview-v7:26.1.+'
|
||||
implementation 'com.android.support:appcompat-v7:26.1.+'
|
||||
implementation 'com.android.support:recyclerview-v7:26.1.+'
|
||||
|
||||
// https://developers.google.com/android/guides/setup
|
||||
compile 'com.google.android.gms:play-services-base:11.4.+'
|
||||
implementation 'com.google.android.gms:play-services-base:11.4.+'
|
||||
|
||||
// https://firebase.google.com/docs/android/setup
|
||||
compile 'com.google.firebase:firebase-core:11.4.+'
|
||||
compile 'com.google.firebase:firebase-ads:11.4.+'
|
||||
implementation 'com.google.firebase:firebase-core:11.4.+'
|
||||
implementation 'com.google.firebase:firebase-ads:11.4.+'
|
||||
|
||||
// https://mvnrepository.com/artifact/com.squareup.picasso/picasso
|
||||
compile 'com.squareup.picasso:picasso:2.5.+'
|
||||
implementation 'com.squareup.picasso:picasso:2.5.+'
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="eu.faircode.netguard">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="eu.faircode.netguard">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
</manifest>
|
|
@ -11,6 +11,7 @@
|
|||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- http://developer.android.com/guide/topics/security/permissions.html#normal-dangerous -->
|
||||
|
||||
<permission
|
||||
|
|
|
@ -56,7 +56,7 @@ int check_dhcp(const struct arguments *args, const struct udp_session *u,
|
|||
struct dhcp_packet *response = calloc(500, 1);
|
||||
|
||||
// Hack
|
||||
inet_pton(AF_INET, "10.1.10.1", &u->saddr);
|
||||
inet_pton(AF_INET, "10.1.10.1", (void *) &u->saddr);
|
||||
|
||||
/*
|
||||
Discover:
|
||||
|
|
|
@ -35,16 +35,14 @@ int32_t get_qname(const uint8_t *data, const size_t datalen, uint16_t off, char
|
|||
c = 1;
|
||||
off += 2;
|
||||
}
|
||||
}
|
||||
else if (ptr + 1 + len <= datalen && noff + len <= DNS_QNAME_MAX) {
|
||||
} else if (ptr + 1 + len <= datalen && noff + len <= DNS_QNAME_MAX) {
|
||||
memcpy(qname + noff, data + ptr + 1, len);
|
||||
*(qname + noff + len) = '.';
|
||||
noff += (len + 1);
|
||||
|
||||
ptr += (len + 1);
|
||||
len = *(data + ptr);
|
||||
}
|
||||
else
|
||||
} else
|
||||
break;
|
||||
}
|
||||
ptr++;
|
||||
|
@ -98,8 +96,7 @@ void parse_dns_response(const struct arguments *args, const struct udp_session *
|
|||
q, qtype, qclass, qname);
|
||||
}
|
||||
off += 4;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_WARN,
|
||||
"DNS response Q invalid off %d datalen %d", off, *datalen);
|
||||
return;
|
||||
|
@ -131,22 +128,19 @@ void parse_dns_response(const struct arguments *args, const struct udp_session *
|
|||
"DNS answer %d qname %s qtype %d ttl %d data %s",
|
||||
a, name, qtype, ttl, rd);
|
||||
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_DEBUG,
|
||||
"DNS answer %d qname %s qclass %d qtype %d ttl %d length %d",
|
||||
a, name, qclass, qtype, ttl, rdlength);
|
||||
|
||||
off += rdlength;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_WARN,
|
||||
"DNS response A invalid off %d rdlength %d datalen %d",
|
||||
off, rdlength, *datalen);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_WARN,
|
||||
"DNS response A invalid off %d datalen %d", off, *datalen);
|
||||
return;
|
||||
|
@ -173,8 +167,7 @@ void parse_dns_response(const struct arguments *args, const struct udp_session *
|
|||
if (u->version == 4) {
|
||||
inet_ntop(AF_INET, &u->saddr.ip4, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &u->daddr.ip4, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &u->saddr.ip6, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &u->daddr.ip6, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -188,8 +181,7 @@ void parse_dns_response(const struct arguments *args, const struct udp_session *
|
|||
name, 0, 0);
|
||||
log_packet(args, objPacket);
|
||||
}
|
||||
}
|
||||
else if (acount > 0)
|
||||
} else if (acount > 0)
|
||||
log_android(ANDROID_LOG_WARN,
|
||||
"DNS response qr %d opcode %d qcount %d acount %d",
|
||||
dns->qr, dns->opcode, qcount, acount);
|
||||
|
@ -217,8 +209,7 @@ int get_dns_query(const struct arguments *args, const struct udp_session *u,
|
|||
*qtype = ntohs(*((uint16_t *) (data + off)));
|
||||
*qclass = ntohs(*((uint16_t *) (data + off + 2)));
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_WARN, "DNS query invalid off %d datalen %d", off, datalen);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@ int check_icmp_session(const struct arguments *args, struct ng_session *s,
|
|||
if (s->icmp.version == 4) {
|
||||
inet_ntop(AF_INET, &s->icmp.saddr.ip4, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &s->icmp.daddr.ip4, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &s->icmp.saddr.ip6, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &s->icmp.daddr.ip6, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -79,8 +78,7 @@ void check_icmp_socket(const struct arguments *args, const struct epoll_event *e
|
|||
serr, strerror(serr));
|
||||
|
||||
s->icmp.stop = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Check socket read
|
||||
if (ev->events & EPOLLIN) {
|
||||
s->icmp.time = time(NULL);
|
||||
|
@ -95,13 +93,11 @@ void check_icmp_socket(const struct arguments *args, const struct epoll_event *e
|
|||
|
||||
if (errno != EINTR && errno != EAGAIN)
|
||||
s->icmp.stop = 1;
|
||||
}
|
||||
else if (bytes == 0) {
|
||||
} else if (bytes == 0) {
|
||||
log_android(ANDROID_LOG_WARN, "ICMP recv eof");
|
||||
s->icmp.stop = 1;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Socket read data
|
||||
char dest[INET6_ADDRSTRLEN + 1];
|
||||
if (s->icmp.version == 4)
|
||||
|
@ -163,8 +159,7 @@ jboolean handle_icmp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
inet_ntop(AF_INET, &ip4->saddr, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &ip4->daddr, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &ip6->ip6_src, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &ip6->ip6_dst, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -201,8 +196,7 @@ jboolean handle_icmp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
s->icmp.saddr.ip4 = (__be32) ip4->saddr;
|
||||
s->icmp.daddr.ip4 = (__be32) ip4->daddr;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
memcpy(&s->icmp.saddr.ip6, &ip6->ip6_src, 16);
|
||||
memcpy(&s->icmp.daddr.ip6, &ip6->ip6_dst, 16);
|
||||
}
|
||||
|
@ -264,8 +258,7 @@ jboolean handle_icmp(const struct arguments *args,
|
|||
server4.sin_family = AF_INET;
|
||||
server4.sin_addr.s_addr = (__be32) ip4->daddr;
|
||||
server4.sin_port = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
server6.sin6_family = AF_INET6;
|
||||
memcpy(&server6.sin6_addr, &ip6->ip6_dst, 16);
|
||||
server6.sin6_port = 0;
|
||||
|
@ -273,7 +266,8 @@ jboolean handle_icmp(const struct arguments *args,
|
|||
|
||||
// Send raw ICMP message
|
||||
if (sendto(cur->socket, icmp, (socklen_t) icmplen, MSG_NOSIGNAL,
|
||||
(const struct sockaddr *) (version == 4 ? &server4 : &server6),
|
||||
(version == 4 ? (const struct sockaddr *) &server4
|
||||
: (const struct sockaddr *) &server6),
|
||||
(socklen_t) (version == 4 ? sizeof(server4) : sizeof(server6))) != icmplen) {
|
||||
log_android(ANDROID_LOG_ERROR, "ICMP sendto error %d: %s", errno, strerror(errno));
|
||||
if (errno != EINTR && errno != EAGAIN) {
|
||||
|
@ -330,8 +324,7 @@ ssize_t write_icmp(const struct arguments *args, const struct icmp_session *cur,
|
|||
|
||||
// Calculate IP4 checksum
|
||||
ip4->check = ~calc_checksum(0, (uint8_t *) ip4, sizeof(struct iphdr));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
len = sizeof(struct ip6_hdr) + datalen;
|
||||
buffer = malloc(len);
|
||||
struct ip6_hdr *ip6 = (struct ip6_hdr *) buffer;
|
||||
|
@ -350,9 +343,11 @@ ssize_t write_icmp(const struct arguments *args, const struct icmp_session *cur,
|
|||
}
|
||||
|
||||
inet_ntop(cur->version == 4 ? AF_INET : AF_INET6,
|
||||
cur->version == 4 ? &cur->saddr.ip4 : &cur->saddr.ip6, source, sizeof(source));
|
||||
cur->version == 4 ? (const void *) &cur->saddr.ip4 : (const void *) &cur->saddr.ip6,
|
||||
source, sizeof(source));
|
||||
inet_ntop(cur->version == 4 ? AF_INET : AF_INET6,
|
||||
cur->version == 4 ? &cur->daddr.ip4 : &cur->daddr.ip6, dest, sizeof(dest));
|
||||
cur->version == 4 ? (const void *) &cur->daddr.ip4 : (const void *) &cur->daddr.ip6,
|
||||
dest, sizeof(dest));
|
||||
|
||||
// Send raw ICMP message
|
||||
log_android(ANDROID_LOG_WARN,
|
||||
|
@ -366,8 +361,7 @@ ssize_t write_icmp(const struct arguments *args, const struct icmp_session *cur,
|
|||
if (res >= 0) {
|
||||
if (pcap_file != NULL)
|
||||
write_pcap_rec(buffer, (size_t) res);
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_WARN, "ICMP write error %d: %s", errno, strerror(errno));
|
||||
|
||||
free(buffer);
|
||||
|
|
|
@ -46,8 +46,7 @@ int check_tun(const struct arguments *args,
|
|||
args->tun, errno, strerror(errno));
|
||||
report_exit(args, "fcntl tun %d F_GETFL error %d: %s",
|
||||
args->tun, errno, strerror(errno));
|
||||
}
|
||||
else
|
||||
} else
|
||||
report_exit(args, "tun %d exception", args->tun);
|
||||
return -1;
|
||||
}
|
||||
|
@ -69,8 +68,7 @@ int check_tun(const struct arguments *args,
|
|||
args->tun, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (length > 0) {
|
||||
} else if (length > 0) {
|
||||
// Write pcap record
|
||||
if (pcap_file != NULL)
|
||||
write_pcap_rec(buffer, (size_t) length);
|
||||
|
@ -84,8 +82,7 @@ int check_tun(const struct arguments *args,
|
|||
handle_ip(args, buffer, (size_t) length, epoll_fd, sessions, maxsessions);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// tun eof
|
||||
free(buffer);
|
||||
|
||||
|
@ -167,8 +164,7 @@ void handle_ip(const struct arguments *args,
|
|||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (version == 6) {
|
||||
} else if (version == 6) {
|
||||
if (length < sizeof(struct ip6_hdr)) {
|
||||
log_android(ANDROID_LOG_WARN, "IP6 packet too short length %d", length);
|
||||
return;
|
||||
|
@ -203,8 +199,7 @@ void handle_ip(const struct arguments *args,
|
|||
payload = (uint8_t *) (pkt + sizeof(struct ip6_hdr) + off);
|
||||
|
||||
// TODO checksum
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_ERROR, "Unknown version %d", version);
|
||||
return;
|
||||
}
|
||||
|
@ -228,8 +223,7 @@ void handle_ip(const struct arguments *args,
|
|||
sport = ntohs(icmp->icmp_id);
|
||||
dport = ntohs(icmp->icmp_id);
|
||||
|
||||
}
|
||||
else if (protocol == IPPROTO_UDP) {
|
||||
} else if (protocol == IPPROTO_UDP) {
|
||||
if (length - (payload - pkt) < sizeof(struct udphdr)) {
|
||||
log_android(ANDROID_LOG_WARN, "UDP packet too short");
|
||||
return;
|
||||
|
@ -241,8 +235,7 @@ void handle_ip(const struct arguments *args,
|
|||
dport = ntohs(udp->dest);
|
||||
|
||||
// TODO checksum (IPv6)
|
||||
}
|
||||
else if (protocol == IPPROTO_TCP) {
|
||||
} else if (protocol == IPPROTO_TCP) {
|
||||
if (length - (payload - pkt) < sizeof(struct tcphdr)) {
|
||||
log_android(ANDROID_LOG_WARN, "TCP packet too short");
|
||||
return;
|
||||
|
@ -267,8 +260,7 @@ void handle_ip(const struct arguments *args,
|
|||
flags[flen++] = 'R';
|
||||
|
||||
// TODO checksum
|
||||
}
|
||||
else if (protocol != IPPROTO_HOPOPTS && protocol != IPPROTO_IGMP && protocol != IPPROTO_ESP)
|
||||
} else if (protocol != IPPROTO_HOPOPTS && protocol != IPPROTO_IGMP && protocol != IPPROTO_ESP)
|
||||
log_android(ANDROID_LOG_WARN, "Unknown protocol %d", protocol);
|
||||
|
||||
flags[flen] = 0;
|
||||
|
@ -320,8 +312,7 @@ void handle_ip(const struct arguments *args,
|
|||
handle_udp(args, pkt, length, payload, uid, redirect, epoll_fd);
|
||||
else if (protocol == IPPROTO_TCP)
|
||||
handle_tcp(args, pkt, length, payload, uid, allowed, redirect, epoll_fd);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (protocol == IPPROTO_UDP)
|
||||
block_udp(args, pkt, length, payload, uid);
|
||||
if (protocol == IPPROTO_TCP)
|
||||
|
@ -442,8 +433,7 @@ jint get_uid_sub(const int version, const int protocol,
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_ERROR, "Invalid field #%d: %s", fields, line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ Java_eu_faircode_netguard_ServiceSinkhole_jni_1get_1stats(JNIEnv *env, jobject i
|
|||
getrlimit(RLIMIT_NOFILE, &rlim);
|
||||
jcount[4] = (jint) rlim.rlim_cur;
|
||||
|
||||
(*env)->ReleaseIntArrayElements(env, jarray, jcount, NULL);
|
||||
(*env)->ReleaseIntArrayElements(env, jarray, jcount, 0);
|
||||
return jarray;
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ void report_error(const struct arguments *args, jint error, const char *fmt, ...
|
|||
static jmethodID midProtect = NULL;
|
||||
|
||||
int protect_socket(const struct arguments *args, int socket) {
|
||||
if (args->sdk >= 21)
|
||||
if (args->sdk >= 23)
|
||||
return 0;
|
||||
|
||||
jclass cls = (*args->env)->GetObjectClass(args->env, args->instance);
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in6.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip6.h>
|
||||
#include <netinet/udp.h>
|
||||
|
@ -212,14 +214,14 @@ typedef struct pcap_hdr_s {
|
|||
guint32_t sigfigs;
|
||||
guint32_t snaplen;
|
||||
guint32_t network;
|
||||
} __packed;
|
||||
} __packed pcap_hdr_s;
|
||||
|
||||
typedef struct pcaprec_hdr_s {
|
||||
guint32_t ts_sec;
|
||||
guint32_t ts_usec;
|
||||
guint32_t incl_len;
|
||||
guint32_t orig_len;
|
||||
} __packed;
|
||||
} __packed pcaprec_hdr_s;
|
||||
|
||||
#define LINKTYPE_RAW 101
|
||||
|
||||
|
@ -271,7 +273,7 @@ typedef struct dns_rr {
|
|||
__be16 qclass;
|
||||
__be32 ttl;
|
||||
__be16 rdlength;
|
||||
} __packed;
|
||||
} __packed dns_rr;
|
||||
|
||||
// DHCP
|
||||
|
||||
|
@ -293,12 +295,12 @@ typedef struct dhcp_packet {
|
|||
uint8_t sname[64];
|
||||
uint8_t file[128];
|
||||
uint32_t option_format;
|
||||
} __packed;
|
||||
} __packed dhcp_packet;
|
||||
|
||||
typedef struct dhcp_option {
|
||||
uint8_t code;
|
||||
uint8_t length;
|
||||
} __packed;
|
||||
} __packed dhcp_option;
|
||||
|
||||
// Prototypes
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ sighandler_t old_handler;
|
|||
sigjmp_buf jump;
|
||||
|
||||
void handle_sigabrt(int sig) {
|
||||
log_android(ANDROID_LOG_ERROR, "sigabrt");
|
||||
old_handler(sig);
|
||||
siglongjmp(jump, 1);
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ int check_tcp_session(const struct arguments *args, struct ng_session *s,
|
|||
if (s->tcp.version == 4) {
|
||||
inet_ntop(AF_INET, &s->tcp.saddr.ip4, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &s->tcp.daddr.ip4, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &s->tcp.saddr.ip6, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &s->tcp.daddr.ip6, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -126,8 +125,7 @@ int monitor_tcp_session(const struct arguments *args, struct ng_session *s, int
|
|||
events = events | EPOLLOUT;
|
||||
else
|
||||
events = events | EPOLLIN;
|
||||
}
|
||||
else if (s->tcp.state == TCP_ESTABLISHED || s->tcp.state == TCP_CLOSE_WAIT) {
|
||||
} else if (s->tcp.state == TCP_ESTABLISHED || s->tcp.state == TCP_CLOSE_WAIT) {
|
||||
|
||||
// Check for incoming data
|
||||
if (get_send_window(&s->tcp) > 0)
|
||||
|
@ -161,8 +159,7 @@ int monitor_tcp_session(const struct arguments *args, struct ng_session *s, int
|
|||
if (epoll_ctl(epoll_fd, EPOLL_CTL_MOD, s->socket, &s->ev)) {
|
||||
s->tcp.state = TCP_CLOSING;
|
||||
log_android(ANDROID_LOG_ERROR, "epoll mod tcp error %d: %s", errno, strerror(errno));
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_DEBUG, "epoll mod tcp socket %d in %d out %d",
|
||||
s->socket, (events & EPOLLIN) != 0, (events & EPOLLOUT) != 0);
|
||||
}
|
||||
|
@ -235,8 +232,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
if (s->tcp.version == 4) {
|
||||
inet_ntop(AF_INET, &s->tcp.saddr.ip4, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &s->tcp.daddr.ip4, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &s->tcp.saddr.ip6, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &s->tcp.daddr.ip6, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -274,7 +270,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
else
|
||||
icmp.icmp_code = ICMP_UNREACH_HOST;
|
||||
icmp.icmp_cksum = 0;
|
||||
icmp.icmp_cksum = ~calc_checksum(0, &icmp, 4);
|
||||
icmp.icmp_cksum = ~calc_checksum(0, (const uint8_t *) &icmp, 4);
|
||||
|
||||
struct icmp_session sicmp;
|
||||
memset(&sicmp, 0, sizeof(struct icmp_session));
|
||||
|
@ -282,16 +278,14 @@ void check_tcp_socket(const struct arguments *args,
|
|||
if (s->tcp.version == 4) {
|
||||
sicmp.saddr.ip4 = (__be32) s->tcp.saddr.ip4;
|
||||
sicmp.daddr.ip4 = (__be32) s->tcp.daddr.ip4;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
memcpy(&sicmp.saddr.ip6, &s->tcp.saddr.ip6, 16);
|
||||
memcpy(&sicmp.daddr.ip6, &s->tcp.daddr.ip6, 16);
|
||||
}
|
||||
|
||||
write_icmp(args, &sicmp, &icmp, 8);
|
||||
write_icmp(args, &sicmp, (uint8_t *) &icmp, 8);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Assume socket okay
|
||||
if (s->tcp.state == TCP_LISTEN) {
|
||||
// Check socket connect
|
||||
|
@ -307,8 +301,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
else
|
||||
s->tcp.socks5 = SOCKS5_CONNECTED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (ev->events & EPOLLIN) {
|
||||
uint8_t buffer[32];
|
||||
ssize_t bytes = recv(s->socket, buffer, sizeof(buffer), 0);
|
||||
|
@ -316,8 +309,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
log_android(ANDROID_LOG_ERROR, "%s recv SOCKS5 error %d: %s",
|
||||
session, errno, strerror(errno));
|
||||
write_rst(args, &s->tcp);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
char *h = hex(buffer, (const size_t) bytes);
|
||||
log_android(ANDROID_LOG_INFO, "%s recv SOCKS5 %s", session, h);
|
||||
free(h);
|
||||
|
@ -335,30 +327,26 @@ void check_tcp_socket(const struct arguments *args,
|
|||
write_rst(args, &s->tcp);
|
||||
}
|
||||
|
||||
}
|
||||
else if (s->tcp.socks5 == SOCKS5_AUTH &&
|
||||
bytes == 2 &&
|
||||
(buffer[0] == 1 || buffer[0] == 5)) {
|
||||
} else if (s->tcp.socks5 == SOCKS5_AUTH &&
|
||||
bytes == 2 &&
|
||||
(buffer[0] == 1 || buffer[0] == 5)) {
|
||||
if (buffer[1] == 0) {
|
||||
s->tcp.socks5 = SOCKS5_CONNECT;
|
||||
log_android(ANDROID_LOG_WARN, "%s SOCKS5 auth OK", session);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
s->tcp.socks5 = 0;
|
||||
log_android(ANDROID_LOG_ERROR, "%s SOCKS5 auth error %d",
|
||||
session, buffer[1]);
|
||||
write_rst(args, &s->tcp);
|
||||
}
|
||||
|
||||
}
|
||||
else if (s->tcp.socks5 == SOCKS5_CONNECT &&
|
||||
bytes == 6 + (s->tcp.version == 4 ? 4 : 16) &&
|
||||
buffer[0] == 5) {
|
||||
} else if (s->tcp.socks5 == SOCKS5_CONNECT &&
|
||||
bytes == 6 + (s->tcp.version == 4 ? 4 : 16) &&
|
||||
buffer[0] == 5) {
|
||||
if (buffer[1] == 0) {
|
||||
s->tcp.socks5 = SOCKS5_CONNECTED;
|
||||
log_android(ANDROID_LOG_WARN, "%s SOCKS5 connected", session);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
s->tcp.socks5 = 0;
|
||||
log_android(ANDROID_LOG_ERROR, "%s SOCKS5 connect error %d",
|
||||
session, buffer[1]);
|
||||
|
@ -376,8 +364,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
*/
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
s->tcp.socks5 = 0;
|
||||
log_android(ANDROID_LOG_ERROR, "%s recv SOCKS5 state %d",
|
||||
session, s->tcp.socks5);
|
||||
|
@ -400,8 +387,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
write_rst(args, &s->tcp);
|
||||
}
|
||||
|
||||
}
|
||||
else if (s->tcp.socks5 == SOCKS5_AUTH) {
|
||||
} else if (s->tcp.socks5 == SOCKS5_AUTH) {
|
||||
uint8_t ulen = strlen(socks5_username);
|
||||
uint8_t plen = strlen(socks5_password);
|
||||
uint8_t buffer[512];
|
||||
|
@ -425,8 +411,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
write_rst(args, &s->tcp);
|
||||
}
|
||||
|
||||
}
|
||||
else if (s->tcp.socks5 == SOCKS5_CONNECT) {
|
||||
} else if (s->tcp.socks5 == SOCKS5_CONNECT) {
|
||||
uint8_t buffer[22];
|
||||
*(buffer + 0) = 5; // version
|
||||
*(buffer + 1) = 1; // TCP/IP stream connection
|
||||
|
@ -435,8 +420,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
if (s->tcp.version == 4) {
|
||||
memcpy(buffer + 4, &s->tcp.daddr.ip4, 4);
|
||||
*((__be16 *) (buffer + 4 + 4)) = s->tcp.dest;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
memcpy(buffer + 4, &s->tcp.daddr.ip6, 16);
|
||||
*((__be16 *) (buffer + 4 + 16)) = s->tcp.dest;
|
||||
}
|
||||
|
@ -455,8 +439,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
write_rst(args, &s->tcp);
|
||||
}
|
||||
|
||||
}
|
||||
else if (s->tcp.socks5 == SOCKS5_CONNECTED) {
|
||||
} else if (s->tcp.socks5 == SOCKS5_CONNECTED) {
|
||||
s->tcp.remote_seq++; // remote SYN
|
||||
if (write_syn_ack(args, &s->tcp) >= 0) {
|
||||
s->tcp.time = time(NULL);
|
||||
|
@ -464,8 +447,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
s->tcp.state = TCP_SYN_RECV;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
// Always forward data
|
||||
int fwd = 0;
|
||||
|
@ -493,13 +475,11 @@ void check_tcp_socket(const struct arguments *args,
|
|||
if (errno == EINTR || errno == EAGAIN) {
|
||||
// Retry later
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
write_rst(args, &s->tcp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fwd = 1;
|
||||
buffer_size -= sent;
|
||||
s->tcp.sent += sent;
|
||||
|
@ -511,8 +491,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
s->tcp.forward = s->tcp.forward->next;
|
||||
free(p->data);
|
||||
free(p);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_WARN,
|
||||
"%s partial send %u/%u",
|
||||
session, s->tcp.forward->sent, s->tcp.forward->len);
|
||||
|
@ -570,8 +549,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
|
||||
if (errno != EINTR && errno != EAGAIN)
|
||||
write_rst(args, &s->tcp);
|
||||
}
|
||||
else if (bytes == 0) {
|
||||
} else if (bytes == 0) {
|
||||
log_android(ANDROID_LOG_WARN, "%s recv eof", session);
|
||||
|
||||
if (s->tcp.forward == NULL) {
|
||||
|
@ -586,8 +564,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
s->tcp.state = TCP_LAST_ACK;
|
||||
else
|
||||
log_android(ANDROID_LOG_ERROR, "%s invalid close", session);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// There was still data to send
|
||||
log_android(ANDROID_LOG_ERROR, "%s close with queue", session);
|
||||
write_rst(args, &s->tcp);
|
||||
|
@ -598,8 +575,7 @@ void check_tcp_socket(const struct arguments *args,
|
|||
session, errno, strerror(errno));
|
||||
s->socket = -1;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Socket read data
|
||||
log_android(ANDROID_LOG_DEBUG, "%s recv bytes %d", session, bytes);
|
||||
s->tcp.received += bytes;
|
||||
|
@ -652,8 +628,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
inet_ntop(AF_INET, &ip4->saddr, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &ip4->daddr, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &ip6->ip6_src, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &ip6->ip6_dst, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -697,7 +672,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
uint16_t mss = get_default_mss(version);
|
||||
uint8_t ws = 0;
|
||||
int optlen = tcpoptlen;
|
||||
uint8_t *options = tcpoptions;
|
||||
uint8_t *options = (uint8_t *) tcpoptions;
|
||||
while (optlen > 0) {
|
||||
uint8_t kind = *options;
|
||||
uint8_t len = *(options + 1);
|
||||
|
@ -713,8 +688,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
if (kind == 1) {
|
||||
optlen--;
|
||||
options++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
optlen -= len;
|
||||
options += len;
|
||||
}
|
||||
|
@ -746,8 +720,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
s->tcp.saddr.ip4 = (__be32) ip4->saddr;
|
||||
s->tcp.daddr.ip4 = (__be32) ip4->daddr;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
memcpy(&s->tcp.saddr.ip6, &ip6->ip6_src, 16);
|
||||
memcpy(&s->tcp.daddr.ip6, &ip6->ip6_dst, 16);
|
||||
}
|
||||
|
@ -799,8 +772,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
log_android(ANDROID_LOG_WARN, "%s resetting blocked session", packet);
|
||||
write_rst(args, &s->tcp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_WARN, "%s unknown session", packet);
|
||||
|
||||
struct tcp_session rst;
|
||||
|
@ -812,8 +784,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
rst.saddr.ip4 = (__be32) ip4->saddr;
|
||||
rst.daddr.ip4 = (__be32) ip4->daddr;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
memcpy(&rst.saddr.ip6, &ip6->ip6_src, 16);
|
||||
memcpy(&rst.daddr.ip6, &ip6->ip6_dst, 16);
|
||||
}
|
||||
|
@ -824,8 +795,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
write_rst(args, &rst);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
char session[250];
|
||||
sprintf(session,
|
||||
"%s %s loc %u rem %u acked %u",
|
||||
|
@ -840,8 +810,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
log_android(ANDROID_LOG_WARN, "%s was closed", session);
|
||||
write_rst(args, &cur->tcp);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int oldstate = cur->tcp.state;
|
||||
uint32_t oldlocal = cur->tcp.local_seq;
|
||||
uint32_t oldremote = cur->tcp.remote_seq;
|
||||
|
@ -874,45 +843,35 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
log_android(ANDROID_LOG_WARN, "%s received reset", session);
|
||||
cur->tcp.state = TCP_CLOSING;
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (!tcphdr->ack || ntohl(tcphdr->ack_seq) == cur->tcp.local_seq) {
|
||||
if (tcphdr->syn) {
|
||||
log_android(ANDROID_LOG_WARN, "%s repeated SYN", session);
|
||||
// The socket is probably not opened yet
|
||||
|
||||
}
|
||||
else if (tcphdr->fin /* +ACK */) {
|
||||
} else if (tcphdr->fin /* +ACK */) {
|
||||
if (cur->tcp.state == TCP_ESTABLISHED) {
|
||||
log_android(ANDROID_LOG_WARN, "%s FIN received", session);
|
||||
if (cur->tcp.forward == NULL) {
|
||||
cur->tcp.remote_seq++; // remote FIN
|
||||
if (write_ack(args, &cur->tcp) >= 0)
|
||||
cur->tcp.state = TCP_CLOSE_WAIT;
|
||||
}
|
||||
else
|
||||
} else
|
||||
cur->tcp.state = TCP_CLOSE_WAIT;
|
||||
}
|
||||
|
||||
else if (cur->tcp.state == TCP_CLOSE_WAIT) {
|
||||
} else if (cur->tcp.state == TCP_CLOSE_WAIT) {
|
||||
log_android(ANDROID_LOG_WARN, "%s repeated FIN", session);
|
||||
// The socket is probably not closed yet
|
||||
}
|
||||
|
||||
else if (cur->tcp.state == TCP_FIN_WAIT1) {
|
||||
} else if (cur->tcp.state == TCP_FIN_WAIT1) {
|
||||
log_android(ANDROID_LOG_WARN, "%s last ACK", session);
|
||||
cur->tcp.remote_seq++; // remote FIN
|
||||
if (write_ack(args, &cur->tcp) >= 0)
|
||||
cur->tcp.state = TCP_CLOSE;
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_ERROR, "%s invalid FIN", session);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
else if (tcphdr->ack) {
|
||||
} else if (tcphdr->ack) {
|
||||
cur->tcp.acked = ntohl(tcphdr->ack_seq);
|
||||
|
||||
if (cur->tcp.state == TCP_SYN_RECV)
|
||||
|
@ -920,31 +879,22 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
|
||||
else if (cur->tcp.state == TCP_ESTABLISHED) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
else if (cur->tcp.state == TCP_LAST_ACK)
|
||||
} else if (cur->tcp.state == TCP_LAST_ACK)
|
||||
cur->tcp.state = TCP_CLOSING;
|
||||
|
||||
else if (cur->tcp.state == TCP_CLOSE_WAIT) {
|
||||
// ACK after FIN/ACK
|
||||
}
|
||||
|
||||
else if (cur->tcp.state == TCP_FIN_WAIT1) {
|
||||
} else if (cur->tcp.state == TCP_FIN_WAIT1) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_ERROR, "%s invalid state", session);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_ERROR, "%s unknown packet", session);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
uint32_t ack = ntohl(tcphdr->ack_seq);
|
||||
if ((uint32_t) (ack + 1) == cur->tcp.local_seq) {
|
||||
// Keep alive
|
||||
|
@ -956,12 +906,10 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
session, errno, strerror(errno));
|
||||
else
|
||||
log_android(ANDROID_LOG_WARN, "%s enabled keep alive", session);
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_WARN, "%s keep alive", session);
|
||||
|
||||
}
|
||||
else if (compare_u32(ack, cur->tcp.local_seq) < 0) {
|
||||
} else if (compare_u32(ack, cur->tcp.local_seq) < 0) {
|
||||
if (compare_u32(ack, cur->tcp.acked) <= 0)
|
||||
log_android(
|
||||
ack == cur->tcp.acked ? ANDROID_LOG_WARN : ANDROID_LOG_ERROR,
|
||||
|
@ -976,8 +924,7 @@ jboolean handle_tcp(const struct arguments *args,
|
|||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_ERROR, "%s future ACK", session);
|
||||
write_rst(args, &cur->tcp);
|
||||
return 0;
|
||||
|
@ -1032,8 +979,7 @@ void queue_tcp(const struct arguments *args,
|
|||
cur->forward = n;
|
||||
else
|
||||
p->next = n;
|
||||
}
|
||||
else if (s != NULL && s->seq == seq) {
|
||||
} else if (s != NULL && s->seq == seq) {
|
||||
if (s->len == datalen)
|
||||
log_android(ANDROID_LOG_WARN, "%s segment already queued %u..%u",
|
||||
session,
|
||||
|
@ -1046,8 +992,7 @@ void queue_tcp(const struct arguments *args,
|
|||
free(s->data);
|
||||
s->data = malloc(datalen);
|
||||
memcpy(s->data, data, datalen);
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_ERROR, "%s segment larger %u..%u < %u",
|
||||
session,
|
||||
s->seq - cur->remote_start, s->seq + s->len - cur->remote_start,
|
||||
|
@ -1065,8 +1010,7 @@ int open_tcp_socket(const struct arguments *args,
|
|||
version = (strstr(socks5_addr, ":") == NULL ? 4 : 6);
|
||||
else
|
||||
version = cur->version;
|
||||
}
|
||||
else
|
||||
} else
|
||||
version = (strstr(redirect->raddr, ":") == NULL ? 4 : 6);
|
||||
|
||||
// Get TCP socket
|
||||
|
@ -1099,27 +1043,23 @@ int open_tcp_socket(const struct arguments *args,
|
|||
addr4.sin_family = AF_INET;
|
||||
inet_pton(AF_INET, socks5_addr, &addr4.sin_addr);
|
||||
addr4.sin_port = htons(socks5_port);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
addr6.sin6_family = AF_INET6;
|
||||
inet_pton(AF_INET6, socks5_addr, &addr6.sin6_addr);
|
||||
addr6.sin6_port = htons(socks5_port);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (version == 4) {
|
||||
addr4.sin_family = AF_INET;
|
||||
addr4.sin_addr.s_addr = (__be32) cur->daddr.ip4;
|
||||
addr4.sin_port = cur->dest;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
addr6.sin6_family = AF_INET6;
|
||||
memcpy(&addr6.sin6_addr, &cur->daddr.ip6, 16);
|
||||
addr6.sin6_port = cur->dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log_android(ANDROID_LOG_WARN, "TCP%d redirect to %s/%u",
|
||||
version, redirect->raddr, redirect->rport);
|
||||
|
||||
|
@ -1127,8 +1067,7 @@ int open_tcp_socket(const struct arguments *args,
|
|||
addr4.sin_family = AF_INET;
|
||||
inet_pton(AF_INET, redirect->raddr, &addr4.sin_addr);
|
||||
addr4.sin_port = htons(redirect->rport);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
addr6.sin6_family = AF_INET6;
|
||||
inet_pton(AF_INET6, redirect->raddr, &addr6.sin6_addr);
|
||||
addr6.sin6_port = htons(redirect->rport);
|
||||
|
@ -1137,7 +1076,8 @@ int open_tcp_socket(const struct arguments *args,
|
|||
|
||||
// Initiate connect
|
||||
int err = connect(sock,
|
||||
(const struct sockaddr *) (version == 4 ? &addr4 : &addr6),
|
||||
(version == 4 ? (const struct sockaddr *) &addr4
|
||||
: (const struct sockaddr *) &addr6),
|
||||
(socklen_t) (version == 4
|
||||
? sizeof(struct sockaddr_in)
|
||||
: sizeof(struct sockaddr_in6)));
|
||||
|
@ -1238,8 +1178,7 @@ ssize_t write_tcp(const struct arguments *args, const struct tcp_session *cur,
|
|||
pseudo.ippseudo_len = htons(sizeof(struct tcphdr) + optlen + datalen);
|
||||
|
||||
csum = calc_checksum(0, (uint8_t *) &pseudo, sizeof(struct ippseudo));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr) + optlen + datalen;
|
||||
buffer = malloc(len);
|
||||
struct ip6_hdr *ip6 = (struct ip6_hdr *) buffer;
|
||||
|
@ -1305,9 +1244,11 @@ ssize_t write_tcp(const struct arguments *args, const struct tcp_session *cur,
|
|||
tcp->check = ~csum;
|
||||
|
||||
inet_ntop(cur->version == 4 ? AF_INET : AF_INET6,
|
||||
cur->version == 4 ? &cur->saddr.ip4 : &cur->saddr.ip6, source, sizeof(source));
|
||||
cur->version == 4 ? (const void *) &cur->saddr.ip4 : (const void *) &cur->saddr.ip6,
|
||||
source, sizeof(source));
|
||||
inet_ntop(cur->version == 4 ? AF_INET : AF_INET6,
|
||||
cur->version == 4 ? &cur->daddr.ip4 : &cur->daddr.ip6, dest, sizeof(dest));
|
||||
cur->version == 4 ? (const void *) &cur->daddr.ip4 : (const void *) &cur->daddr.ip6,
|
||||
dest, sizeof(dest));
|
||||
|
||||
// Send packet
|
||||
log_android(ANDROID_LOG_DEBUG,
|
||||
|
@ -1327,8 +1268,7 @@ ssize_t write_tcp(const struct arguments *args, const struct tcp_session *cur,
|
|||
if (res >= 0) {
|
||||
if (pcap_file != NULL)
|
||||
write_pcap_rec(buffer, (size_t) res);
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_ERROR, "TCP write%s%s%s%s data %d error %d: %s",
|
||||
(tcp->syn ? " SYN" : ""),
|
||||
(tcp->ack ? " ACK" : ""),
|
||||
|
|
|
@ -40,8 +40,7 @@ int check_udp_session(const struct arguments *args, struct ng_session *s,
|
|||
if (s->udp.version == 4) {
|
||||
inet_ntop(AF_INET, &s->udp.saddr.ip4, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &s->udp.daddr.ip4, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &s->udp.saddr.ip6, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &s->udp.daddr.ip6, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -101,8 +100,7 @@ void check_udp_socket(const struct arguments *args, const struct epoll_event *ev
|
|||
log_android(ANDROID_LOG_ERROR, "UDP SO_ERROR %d: %s", serr, strerror(serr));
|
||||
|
||||
s->udp.state = UDP_FINISHING;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Check socket read
|
||||
if (ev->events & EPOLLIN) {
|
||||
s->udp.time = time(NULL);
|
||||
|
@ -116,13 +114,11 @@ void check_udp_socket(const struct arguments *args, const struct epoll_event *ev
|
|||
|
||||
if (errno != EINTR && errno != EAGAIN)
|
||||
s->udp.state = UDP_FINISHING;
|
||||
}
|
||||
else if (bytes == 0) {
|
||||
} else if (bytes == 0) {
|
||||
log_android(ANDROID_LOG_WARN, "UDP recv eof");
|
||||
s->udp.state = UDP_FINISHING;
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// Socket read data
|
||||
char dest[INET6_ADDRSTRLEN + 1];
|
||||
if (s->udp.version == 4)
|
||||
|
@ -192,8 +188,7 @@ void block_udp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
inet_ntop(AF_INET, &ip4->saddr, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &ip4->daddr, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &ip6->ip6_src, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &ip6->ip6_dst, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -212,8 +207,7 @@ void block_udp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
s->udp.saddr.ip4 = (__be32) ip4->saddr;
|
||||
s->udp.daddr.ip4 = (__be32) ip4->daddr;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
memcpy(&s->udp.saddr.ip6, &ip6->ip6_src, 16);
|
||||
memcpy(&s->udp.daddr.ip6, &ip6->ip6_dst, 16);
|
||||
}
|
||||
|
@ -257,8 +251,7 @@ jboolean handle_udp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
inet_ntop(AF_INET, &ip4->saddr, source, sizeof(source));
|
||||
inet_ntop(AF_INET, &ip4->daddr, dest, sizeof(dest));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inet_ntop(AF_INET6, &ip6->ip6_src, source, sizeof(source));
|
||||
inet_ntop(AF_INET6, &ip6->ip6_dst, dest, sizeof(dest));
|
||||
}
|
||||
|
@ -295,8 +288,7 @@ jboolean handle_udp(const struct arguments *args,
|
|||
if (version == 4) {
|
||||
s->udp.saddr.ip4 = (__be32) ip4->saddr;
|
||||
s->udp.daddr.ip4 = (__be32) ip4->daddr;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
memcpy(&s->udp.saddr.ip6, &ip6->ip6_src, 16);
|
||||
memcpy(&s->udp.daddr.ip6, &ip6->ip6_dst, 16);
|
||||
}
|
||||
|
@ -376,14 +368,12 @@ jboolean handle_udp(const struct arguments *args,
|
|||
addr4.sin_family = AF_INET;
|
||||
addr4.sin_addr.s_addr = (__be32) cur->udp.daddr.ip4;
|
||||
addr4.sin_port = cur->udp.dest;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
addr6.sin6_family = AF_INET6;
|
||||
memcpy(&addr6.sin6_addr, &cur->udp.daddr.ip6, 16);
|
||||
addr6.sin6_port = cur->udp.dest;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
rversion = (strstr(redirect->raddr, ":") == NULL ? 4 : 6);
|
||||
log_android(ANDROID_LOG_WARN, "UDP%d redirect to %s/%u",
|
||||
rversion, redirect->raddr, redirect->rport);
|
||||
|
@ -392,8 +382,7 @@ jboolean handle_udp(const struct arguments *args,
|
|||
addr4.sin_family = AF_INET;
|
||||
inet_pton(AF_INET, redirect->raddr, &addr4.sin_addr);
|
||||
addr4.sin_port = htons(redirect->rport);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
addr6.sin6_family = AF_INET6;
|
||||
inet_pton(AF_INET6, redirect->raddr, &addr6.sin6_addr);
|
||||
addr6.sin6_port = htons(redirect->rport);
|
||||
|
@ -401,15 +390,15 @@ jboolean handle_udp(const struct arguments *args,
|
|||
}
|
||||
|
||||
if (sendto(cur->socket, data, (socklen_t) datalen, MSG_NOSIGNAL,
|
||||
(const struct sockaddr *) (rversion == 4 ? &addr4 : &addr6),
|
||||
(rversion == 4 ? (const struct sockaddr *) &addr4
|
||||
: (const struct sockaddr *) &addr6),
|
||||
(socklen_t) (rversion == 4 ? sizeof(addr4) : sizeof(addr6))) != datalen) {
|
||||
log_android(ANDROID_LOG_ERROR, "UDP sendto error %d: %s", errno, strerror(errno));
|
||||
if (errno != EINTR && errno != EAGAIN) {
|
||||
cur->udp.state = UDP_FINISHING;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
cur->udp.sent += datalen;
|
||||
|
||||
return 1;
|
||||
|
@ -445,8 +434,7 @@ int open_udp_socket(const struct arguments *args,
|
|||
log_android(ANDROID_LOG_ERROR, "UDP setsockopt SO_BROADCAST error %d: %s",
|
||||
errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// http://man7.org/linux/man-pages/man7/ipv6.7.html
|
||||
if (*((uint8_t *) &cur->daddr.ip6) == 0xFF) {
|
||||
log_android(ANDROID_LOG_WARN, "UDP6 broadcast");
|
||||
|
@ -516,8 +504,7 @@ ssize_t write_udp(const struct arguments *args, const struct udp_session *cur,
|
|||
pseudo.ippseudo_len = htons(sizeof(struct udphdr) + datalen);
|
||||
|
||||
csum = calc_checksum(0, (uint8_t *) &pseudo, sizeof(struct ippseudo));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
len = sizeof(struct ip6_hdr) + sizeof(struct udphdr) + datalen;
|
||||
buffer = malloc(len);
|
||||
struct ip6_hdr *ip6 = (struct ip6_hdr *) buffer;
|
||||
|
@ -558,9 +545,13 @@ ssize_t write_udp(const struct arguments *args, const struct udp_session *cur,
|
|||
udp->check = ~csum;
|
||||
|
||||
inet_ntop(cur->version == 4 ? AF_INET : AF_INET6,
|
||||
cur->version == 4 ? &cur->saddr.ip4 : &cur->saddr.ip6, source, sizeof(source));
|
||||
(cur->version == 4 ? (const void *) &cur->saddr.ip4 : (const void *) &cur->saddr.ip6),
|
||||
source,
|
||||
sizeof(source));
|
||||
inet_ntop(cur->version == 4 ? AF_INET : AF_INET6,
|
||||
cur->version == 4 ? &cur->daddr.ip4 : &cur->daddr.ip6, dest, sizeof(dest));
|
||||
(cur->version == 4 ? (const void *) &cur->daddr.ip4 : (const void *) &cur->daddr.ip6),
|
||||
dest,
|
||||
sizeof(dest));
|
||||
|
||||
// Send packet
|
||||
log_android(ANDROID_LOG_DEBUG,
|
||||
|
@ -573,8 +564,7 @@ ssize_t write_udp(const struct arguments *args, const struct udp_session *cur,
|
|||
if (res >= 0) {
|
||||
if (pcap_file != NULL)
|
||||
write_pcap_rec(buffer, (size_t) res);
|
||||
}
|
||||
else
|
||||
} else
|
||||
log_android(ANDROID_LOG_WARN, "UDP write error %d: %s", errno, strerror(errno));
|
||||
|
||||
free(buffer);
|
||||
|
|
|
@ -66,7 +66,7 @@ void log_android(int prio, const char *fmt, ...) {
|
|||
va_list argptr;
|
||||
va_start(argptr, fmt);
|
||||
vsprintf(line, fmt, argptr);
|
||||
__android_log_print(prio, TAG, line);
|
||||
__android_log_print(prio, TAG, "%s", line);
|
||||
va_end(argptr);
|
||||
}
|
||||
}
|
||||
|
@ -148,8 +148,7 @@ int32_t get_local_port(const int sock) {
|
|||
if (getsockname(sock, (struct sockaddr *) &sin, &len) < 0) {
|
||||
log_android(ANDROID_LOG_ERROR, "getsockname error %d: %s", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return ntohs(sin.sin_port);
|
||||
}
|
||||
|
||||
|
@ -162,8 +161,7 @@ int is_event(int fd, short event) {
|
|||
if (r < 0) {
|
||||
log_android(ANDROID_LOG_ERROR, "poll readable error %d: %s", errno, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
else if (r == 0)
|
||||
} else if (r == 0)
|
||||
return 0;
|
||||
else
|
||||
return (p.revents & event);
|
||||
|
|
|
@ -8,7 +8,7 @@ buildscript {
|
|||
// http://tools.android.com/tech-docs/new-build-system/gradle-experimental
|
||||
// https://bintray.com/android/android-tools/com.android.tools.build.gradle-experimental/view
|
||||
// https://bintray.com/android/android-tools/com.google.gms.google-services/view
|
||||
classpath 'com.android.tools.build:gradle-experimental:0.9.3'
|
||||
classpath 'com.android.tools.build:gradle:3.0.0-rc2'
|
||||
classpath 'com.google.gms:google-services:3.1.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Mon Sep 12 16:15:29 CEST 2016
|
||||
#Mon Oct 23 20:40:54 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
|
||||
|
|
Loading…
Reference in a new issue