From 41e740f697ddc69c40a42d556592a8a6d6045c66 Mon Sep 17 00:00:00 2001 From: Daniel Lenski Date: Mon, 6 Aug 2018 22:27:07 -0700 Subject: [PATCH] allow user to override HTTP User-Agent Latest LibOpenConnect has two constructors, one of which accepts a User-Agent string. --- .../core/OpenConnectManagementThread.java | 15 ++++++++++++++- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/pref_openconnect.xml | 6 ++++++ external/openconnect | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/openconnect/core/OpenConnectManagementThread.java b/app/src/main/java/app/openconnect/core/OpenConnectManagementThread.java index a92fd3d4..3c706422 100644 --- a/app/src/main/java/app/openconnect/core/OpenConnectManagementThread.java +++ b/app/src/main/java/app/openconnect/core/OpenConnectManagementThread.java @@ -162,6 +162,14 @@ private void acceptCert(String hash, boolean save) { } private class AndroidOC extends LibOpenConnect { + AndroidOC() { + super(); + } + + AndroidOC(String userAgent) { + super(userAgent); + } + private String getPeerCertSHA1() { MessageDigest md; try { @@ -699,9 +707,14 @@ private boolean runVPN() { mCacheDir = mContext.getCacheDir().getPath(); extractBinaries(); + String userAgent = getStringPref("reported_user_agent"); + setState(STATE_CONNECTING); synchronized (mMainloopLock) { - mOC = new AndroidOC(); + if (userAgent.length() > 0) + mOC = new AndroidOC(userAgent); + else + mOC = new AndroidOC(); } if (setPreferences() == false) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b5a9c6de..d9cc4312 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -164,6 +164,8 @@ Unknown Batch mode Reported OS + Reported User-Agent + Override the HTTP User-Agent header.\n\nSome Cisco servers accept "Cisco AnyConnect VPN Agent"; some Juniper servers accept "ncsvc" Custom CSD wrapper Split tunnel mode Split tunnel networks diff --git a/app/src/main/res/xml/pref_openconnect.xml b/app/src/main/res/xml/pref_openconnect.xml index 6ebbb2c1..7afe7d83 100644 --- a/app/src/main/res/xml/pref_openconnect.xml +++ b/app/src/main/res/xml/pref_openconnect.xml @@ -79,6 +79,12 @@ android:entries="@array/reported_os_entries" android:entryValues="@array/reported_os_values" android:defaultValue="android" /> +