Skip to content

Commit a48b89d

Browse files
committed
Update to SDK 29 so we can use setHttpProxy to capture more traffic
On Android 10+, this should allow us to capture HTTP(S) sent to _any_ port, not just to the hardcoded 80/443/8080/etc list.
1 parent b4cb5a9 commit a48b89d

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ language: android
22
dist: trusty
33
android:
44
components:
5-
- build-tools-29.0.2
6-
- android-28
5+
- build-tools-29.0.3
6+
- android-29
77
before_install:
88
- openssl aes-256-cbc -K $encrypted_410c058128c0_key -iv $encrypted_410c058128c0_iv
99
-in android-travis-cert-store.enc -out ./android-travis-cert-store.jks -d
@@ -12,7 +12,7 @@ script:
1212
- jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -storepass $CERT_STORE_PWD
1313
-keypass $CERT_STORE_PWD -keystore ./android-travis-cert-store.jks app/build/outputs/apk/release/app-release-unsigned.apk
1414
$CERT_ALIAS
15-
- ${ANDROID_HOME}/build-tools/29.0.2/zipalign -v 4 app/build/outputs/apk/release/app-release-unsigned.apk ./httptoolkit.apk
15+
- ${ANDROID_HOME}/build-tools/29.0.3/zipalign -v 4 app/build/outputs/apk/release/app-release-unsigned.apk ./httptoolkit.apk
1616
deploy:
1717
provider: releases
1818
api_key:

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ apply plugin: 'kotlin-android-extensions'
44

55
android {
66

7-
compileSdkVersion 28
8-
buildToolsVersion "29.0.2"
7+
compileSdkVersion 29
8+
buildToolsVersion "29.0.3"
99
defaultConfig {
1010
applicationId "tech.httptoolkit.android.v1"
1111
minSdkVersion 21
12-
targetSdkVersion 28
12+
targetSdkVersion 29
1313
versionCode 9
1414
versionName "1.0.0-alpha9"
1515

app/src/main/java/tech/httptoolkit/android/ProxyVpnService.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.content.Intent
55
import android.app.*
66
import android.content.pm.PackageManager
77
import android.graphics.BitmapFactory
8+
import android.net.ProxyInfo
89
import android.os.Build
910
import android.os.ParcelFileDescriptor
1011
import android.util.Log
@@ -148,6 +149,15 @@ class ProxyVpnService : VpnService(), IProtectSocket {
148149
vpnInterface = Builder()
149150
.addAddress(VPN_IP_ADDRESS, 32)
150151
.addRoute(ALL_ROUTES, 0)
152+
.apply {
153+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
154+
// Where possible, we want to explicitly set the proxy in addition to
155+
// manually redirecting traffic. This is useful because it captures HTTP sent
156+
// to non-default ports. We still need to do both though, as not all clients
157+
// will use the proxy settings.
158+
setHttpProxy(ProxyInfo.buildDirectProxy(proxyConfig.ip, proxyConfig.port))
159+
}
160+
}
151161

152162
.setMtu(MAX_PACKET_LEN) // Limit the packet size to the buffer used by ProxyVpnRunnable
153163
.setBlocking(true) // We use a blocking loop to read in ProxyVpnRunnable

0 commit comments

Comments
 (0)