Skip to content

Commit

Permalink
add a checkbox to control the User-Agent override
Browse files Browse the repository at this point in the history
  • Loading branch information
dlenski committed Aug 10, 2018
1 parent 6959e0d commit 697cad1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,12 @@ private boolean runVPN() {
mCacheDir = mContext.getCacheDir().getPath();
extractBinaries();

String userAgent = getStringPref("reported_user_agent");
String userAgent = getBoolPref("reported_user_agent_override")
? getStringPref("reported_user_agent") : null;

setState(STATE_CONNECTING);
synchronized (mMainloopLock) {
if (userAgent.length() > 0)
if (userAgent != null)
mOC = new AndroidOC(userAgent);
else
mOC = new AndroidOC();
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@
<string name="unknown">Unknown</string>
<string name="batch_mode">Batch mode</string>
<string name="reported_os">Reported OS</string>
<string name="reported_user_agent_override">Override reported User-Agent</string>
<string name="reported_user_agent_override_summary">Use a custom HTTP User-Agent header, instead of OpenConnect\'s default; some servers are picky about this value.</string>
<string name="reported_user_agent">Reported User-Agent</string>
<string name="reported_user_agent_summary">Override the HTTP User-Agent header.\n\nSome Cisco servers accept \"Cisco AnyConnect VPN Agent\"; some Juniper servers accept \"ncsvc\".</string>
<string name="reported_user_agent_summary">Some Cisco servers accept \"Cisco AnyConnect VPN Agent\"; some Juniper servers accept \"ncsvc\".</string>
<string name="custom_csd_wrapper">Custom CSD wrapper</string>
<string name="split_tunnel_mode">Split tunnel mode</string>
<string name="split_tunnel_networks">Split tunnel networks</string>
Expand Down
8 changes: 7 additions & 1 deletion app/src/main/res/xml/pref_openconnect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@
android:entries="@array/reported_os_entries"
android:entryValues="@array/reported_os_values"
android:defaultValue="android" />
<CheckBoxPreference
android:key="reported_user_agent_override"
android:title="@string/reported_user_agent_override"
android:summary="@string/reported_user_agent_override_summary"
android:defaultValue="false" />
<EditTextPreference
android:key="reported_user_agent"
android:title="@string/reported_user_agent"
android:dependency="reported_user_agent_override"
android:dialogTitle="@string/reported_user_agent"
android:dialogMessage="@string/reported_user_agent_summary"
android:defaultValue="" />
android:defaultValue="OpenConnect VPN Agent (Java)" />
<app.openconnect.ShowTextPreference
android:key="custom_csd_wrapper"
android:title="@string/custom_csd_wrapper"
Expand Down

0 comments on commit 697cad1

Please sign in to comment.