Updater: Add initial Tor support

This commit is contained in:
Tad 2018-09-20 17:41:19 -04:00
parent 289b110d8f
commit b50352bc8e
8 changed files with 372 additions and 13 deletions

View File

@ -1,18 +1,18 @@
From 4727712ba79e02a706735e0f01e094a0e4a8deb2 Mon Sep 17 00:00:00 2001 From 03e04247e9416a901fbb30b742d985ac6c801598 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us> From: Tad <tad@spotco.us>
Date: Fri, 6 Apr 2018 14:14:03 -0400 Date: Thu, 20 Sep 2018 16:43:46 -0400
Subject: [PATCH] Switch to our update server Subject: [PATCH] Switch to our update server
Change-Id: Ief2f6ae8952de1a5a8e3ca73989fab42ca22f622 Change-Id: I26dc2942736cf0cfe4e7b92ddfdd04b9d74dbae5
--- ---
src/org/lineageos/updater/misc/Utils.java | 10 +--------- src/org/lineageos/updater/misc/Utils.java | 10 ++--------
1 file changed, 1 insertion(+), 9 deletions(-) 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java
index 67895da..d4d3379 100644 index 171c2cc..d97a492 100644
--- a/src/org/lineageos/updater/misc/Utils.java --- a/src/org/lineageos/updater/misc/Utils.java
+++ b/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java
@@ -147,16 +147,8 @@ public class Utils { @@ -149,16 +149,10 @@ public class Utils {
String incrementalVersion = SystemProperties.get(Constants.PROP_BUILD_VERSION_INCREMENTAL); String incrementalVersion = SystemProperties.get(Constants.PROP_BUILD_VERSION_INCREMENTAL);
String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE, String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE,
SystemProperties.get(Constants.PROP_DEVICE)); SystemProperties.get(Constants.PROP_DEVICE));
@ -22,14 +22,15 @@ index 67895da..d4d3379 100644
- if (serverUrl.trim().isEmpty()) { - if (serverUrl.trim().isEmpty()) {
- serverUrl = context.getString(R.string.updater_server_url); - serverUrl = context.getString(R.string.updater_server_url);
- } - }
- + String server = "0OTA_SERVER_CLEARNET0";
- return serverUrl.replace("{device}", device) - return serverUrl.replace("{device}", device)
- .replace("{type}", type) - .replace("{type}", type)
- .replace("{incr}", incrementalVersion); - .replace("{incr}", incrementalVersion);
+ return "0OTASERVER0?base=LineageOS&device=" + device + "&inc=" + incrementalVersion; + return server + "?base=LineageOS&device=" + device + "&inc=" + incrementalVersion;
} }
public static String getChangelogURL(Context context) { public static String getChangelogURL(Context context) {
-- --
2.18.0 2.19.0

View File

@ -0,0 +1,353 @@
From b2c506b55254ad9d21cc0718ca7f093b7207b424 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 20 Sep 2018 21:44:53 -0400
Subject: [PATCH] Add support for routing over Tor
Change-Id: Ibfe080c3d801af34fb64fda1b6b8f4f39a2b1ccf
---
res/layout/preferences_dialog.xml | 8 +++
res/values/strings.xml | 2 +
.../lineageos/updater/UpdatesActivity.java | 12 ++++
.../updater/UpdatesCheckReceiver.java | 4 ++
.../updater/controller/UpdaterController.java | 4 ++
.../updater/download/DownloadClient.java | 8 ++-
.../download/HttpURLConnectionClient.java | 20 +++++-
src/org/lineageos/updater/misc/Constants.java | 1 +
src/org/lineageos/updater/misc/Utils.java | 65 +++++++++++++++++++
9 files changed, 120 insertions(+), 4 deletions(-)
diff --git a/res/layout/preferences_dialog.xml b/res/layout/preferences_dialog.xml
index 898f53e..db88a41 100644
--- a/res/layout/preferences_dialog.xml
+++ b/res/layout/preferences_dialog.xml
@@ -15,6 +15,14 @@
android:text="@string/menu_auto_updates_check"
android:textSize="16sp" />
+ <Switch
+ android:id="@+id/preferences_onion_routing"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="16dp"
+ android:text="@string/menu_onion_routing"
+ android:textSize="16sp" />
+
<Switch
android:id="@+id/preferences_auto_delete_updates"
android:layout_width="match_parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aa84059..a85dd6a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -64,6 +64,7 @@
<string name="menu_refresh">Refresh</string>
<string name="menu_preferences">Preferences</string>
<string name="menu_auto_updates_check">Auto updates check</string>
+ <string name="menu_onion_routing">Perform requests over Tor</string>
<string name="menu_auto_delete_updates">Delete updates when installed</string>
<string name="menu_delete_update">Delete</string>
<string name="menu_copy_url">Copy URL</string>
@@ -79,6 +80,7 @@
<string name="snack_download_failed">The download failed. Please check your internet connection and try again later.</string>
<string name="snack_download_verification_failed">The update verification failed.</string>
<string name="snack_download_verified">Download completed.</string>
+ <string name="snack_orbot_not_available">Orbot is not installed, disabling Tor routing!</string>
<string name="snack_update_not_installable">This update can\'t be installed on top of the current build.</string>
diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java
index 2d3fc57..15d4a66 100644
--- a/src/org/lineageos/updater/UpdatesActivity.java
+++ b/src/org/lineageos/updater/UpdatesActivity.java
@@ -340,10 +340,14 @@ public class UpdatesActivity extends UpdatesListActivity {
final DownloadClient downloadClient;
try {
+ if(Utils.isOnionRoutingEnabled(getApplicationContext())) {
+ Utils.requestStartOrbot(getApplicationContext());
+ }
downloadClient = new DownloadClient.Builder()
.setUrl(url)
.setDestination(jsonFileTmp)
.setDownloadCallback(callback)
+ .setUseOnionRouting(Utils.isOnionRoutingEnabled(getApplicationContext()))
.build();
} catch (IOException exception) {
Log.e(TAG, "Could not build download client");
@@ -407,6 +411,7 @@ public class UpdatesActivity extends UpdatesListActivity {
private void showPreferencesDialog() {
View view = LayoutInflater.from(this).inflate(R.layout.preferences_dialog, null);
Switch autoCheck = view.findViewById(R.id.preferences_auto_updates_check);
+ Switch onionRouting = view.findViewById(R.id.preferences_onion_routing);
Switch autoDelete = view.findViewById(R.id.preferences_auto_delete_updates);
Switch dataWarning = view.findViewById(R.id.preferences_mobile_data_warning);
Switch abPerfMode = view.findViewById(R.id.preferences_ab_perf_mode);
@@ -417,6 +422,7 @@ public class UpdatesActivity extends UpdatesListActivity {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
autoCheck.setChecked(prefs.getBoolean(Constants.PREF_AUTO_UPDATES_CHECK, true));
+ onionRouting.setChecked(prefs.getBoolean(Constants.PREF_ONION_ROUTING, false));
autoDelete.setChecked(prefs.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false));
dataWarning.setChecked(prefs.getBoolean(Constants.PREF_MOBILE_DATA_WARNING, true));
abPerfMode.setChecked(prefs.getBoolean(Constants.PREF_AB_PERF_MODE, false));
@@ -428,6 +434,8 @@ public class UpdatesActivity extends UpdatesListActivity {
prefs.edit()
.putBoolean(Constants.PREF_AUTO_UPDATES_CHECK,
autoCheck.isChecked())
+ .putBoolean(Constants.PREF_ONION_ROUTING,
+ onionRouting.isChecked() && Utils.isOrbotInstalled(getApplicationContext()))
.putBoolean(Constants.PREF_AUTO_DELETE_UPDATES,
autoDelete.isChecked())
.putBoolean(Constants.PREF_MOBILE_DATA_WARNING,
@@ -443,6 +451,10 @@ public class UpdatesActivity extends UpdatesListActivity {
UpdatesCheckReceiver.cancelUpdatesCheck(this);
}
+ if(onionRouting.isChecked() && !Utils.isOrbotInstalled(getApplicationContext())) {
+ showSnackbar(R.string.snack_orbot_not_available, Snackbar.LENGTH_LONG);
+ }
+
boolean enableABPerfMode = abPerfMode.isChecked();
mUpdaterService.getUpdaterController().setPerformanceMode(enableABPerfMode);
})
diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java
index c7f1b4e..0abbde5 100644
--- a/src/org/lineageos/updater/UpdatesCheckReceiver.java
+++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java
@@ -111,10 +111,14 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
};
try {
+ if(Utils.isOnionRoutingEnabled(context)) {
+ Utils.requestStartOrbot(context);
+ }
DownloadClient downloadClient = new DownloadClient.Builder()
.setUrl(url)
.setDestination(jsonNew)
.setDownloadCallback(callback)
+ .setUseOnionRouting(Utils.isOnionRoutingEnabled(context))
.build();
downloadClient.start();
} catch (IOException e) {
diff --git a/src/org/lineageos/updater/controller/UpdaterController.java b/src/org/lineageos/updater/controller/UpdaterController.java
index 8fd5760..7287146 100644
--- a/src/org/lineageos/updater/controller/UpdaterController.java
+++ b/src/org/lineageos/updater/controller/UpdaterController.java
@@ -357,12 +357,16 @@ public class UpdaterController {
update.setFile(destination);
DownloadClient downloadClient;
try {
+ if(Utils.isOnionRoutingEnabled(mContext)) {
+ Utils.requestStartOrbot(mContext);
+ }
downloadClient = new DownloadClient.Builder()
.setUrl(update.getDownloadUrl())
.setDestination(update.getFile())
.setDownloadCallback(getDownloadCallback(downloadId))
.setProgressListener(getProgressListener(downloadId))
.setUseDuplicateLinks(true)
+ .setUseOnionRouting(Utils.isOnionRoutingEnabled(mContext))
.build();
} catch (IOException exception) {
Log.e(TAG, "Could not build download client");
diff --git a/src/org/lineageos/updater/download/DownloadClient.java b/src/org/lineageos/updater/download/DownloadClient.java
index 6a2a490..374e017 100644
--- a/src/org/lineageos/updater/download/DownloadClient.java
+++ b/src/org/lineageos/updater/download/DownloadClient.java
@@ -64,6 +64,7 @@ public interface DownloadClient {
private DownloadClient.DownloadCallback mCallback;
private DownloadClient.ProgressListener mProgressListener;
private boolean mUseDuplicateLinks;
+ private boolean mOnionRouting;
public DownloadClient build() throws IOException {
if (mUrl == null) {
@@ -74,7 +75,7 @@ public interface DownloadClient {
throw new IllegalStateException("No download callback defined");
}
return new HttpURLConnectionClient(mUrl, mDestination, mProgressListener, mCallback,
- mUseDuplicateLinks);
+ mUseDuplicateLinks, mOnionRouting);
}
public Builder setUrl(String url) {
@@ -101,5 +102,10 @@ public interface DownloadClient {
mUseDuplicateLinks = useDuplicateLinks;
return this;
}
+
+ public Builder setUseOnionRouting(boolean onionRouting) {
+ mOnionRouting = onionRouting;
+ return this;
+ }
}
}
diff --git a/src/org/lineageos/updater/download/HttpURLConnectionClient.java b/src/org/lineageos/updater/download/HttpURLConnectionClient.java
index 2b7c80e..c76d747 100644
--- a/src/org/lineageos/updater/download/HttpURLConnectionClient.java
+++ b/src/org/lineageos/updater/download/HttpURLConnectionClient.java
@@ -18,12 +18,16 @@ package org.lineageos.updater.download;
import android.os.SystemClock;
import android.util.Log;
+import org.lineageos.updater.misc.Utils;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
import java.net.URL;
import java.util.Comparator;
import java.util.List;
@@ -42,6 +46,7 @@ public class HttpURLConnectionClient implements DownloadClient {
private final DownloadClient.ProgressListener mProgressListener;
private final DownloadClient.DownloadCallback mCallback;
private final boolean mUseDuplicateLinks;
+ private final boolean mUseOnionRouting;
private DownloadThread mDownloadThread;
@@ -60,8 +65,14 @@ public class HttpURLConnectionClient implements DownloadClient {
HttpURLConnectionClient(String url, File destination,
DownloadClient.ProgressListener progressListener,
DownloadClient.DownloadCallback callback,
- boolean useDuplicateLinks) throws IOException {
- mClient = (HttpURLConnection) new URL(url).openConnection();
+ boolean useDuplicateLinks, boolean useOnionRouting) throws IOException {
+ mUseOnionRouting = useOnionRouting;
+ if(useOnionRouting) {
+ Proxy orbot = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("127.0.0.1", 9050));
+ mClient = (HttpURLConnection) new URL(url).openConnection(orbot);
+ } else {
+ mClient = (HttpURLConnection) new URL(url).openConnection();
+ }
mDestination = destination;
mProgressListener = progressListener;
mCallback = callback;
@@ -224,7 +235,7 @@ public class HttpURLConnectionClient implements DownloadClient {
}
Log.d(TAG, "Downloading from " + newUrl);
changeClientUrl(url);
- mClient.setConnectTimeout(5000);
+ mClient.setConnectTimeout(mUseOnionRouting ? 45000 : 5000);
mClient.connect();
if (!isSuccessCode(mClient.getResponseCode())) {
throw new IOException("Server replied with " + mClient.getResponseCode());
@@ -246,6 +257,9 @@ public class HttpURLConnectionClient implements DownloadClient {
@Override
public void run() {
try {
+ if(mUseOnionRouting) {
+ Utils.waitUntilOrbotIsAvailable();
+ }
mClient.setInstanceFollowRedirects(!mUseDuplicateLinks);
mClient.connect();
int responseCode = mClient.getResponseCode();
diff --git a/src/org/lineageos/updater/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java
index 5bc0e8b..b8a3193 100644
--- a/src/org/lineageos/updater/misc/Constants.java
+++ b/src/org/lineageos/updater/misc/Constants.java
@@ -25,6 +25,7 @@ public final class Constants {
public static final String PREF_LAST_UPDATE_CHECK = "last_update_check";
public static final String PREF_AUTO_UPDATES_CHECK = "auto_updates_check";
+ public static final String PREF_ONION_ROUTING = "onion_routing";
public static final String PREF_AUTO_DELETE_UPDATES = "auto_delete_updates";
public static final String PREF_AB_PERF_MODE = "ab_perf_mode";
public static final String PREF_MOBILE_DATA_WARNING = "pref_mobile_data_warning";
diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java
index d97a492..a151c75 100644
--- a/src/org/lineageos/updater/misc/Utils.java
+++ b/src/org/lineageos/updater/misc/Utils.java
@@ -44,6 +44,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.net.Socket;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
@@ -145,12 +146,76 @@ public class Utils {
return updates;
}
+ //Credit: https://stackoverflow.com/a/6758962
+ public static boolean isPackageInstalled(Context context, String packageID) {
+ PackageManager pm = context.getPackageManager();
+ try {
+ pm.getPackageInfo(packageID, PackageManager.GET_META_DATA);
+ } catch(PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean isOrbotInstalled(Context context) {
+ return isPackageInstalled(context, "org.torproject.android");
+ }
+
+ public static boolean isOnionRoutingEnabled(Context context) {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ return preferences.getBoolean(Constants.PREF_ONION_ROUTING, false);
+ }
+
+ //Credit: OrbotHelper/NetCipher
+ public static void requestStartOrbot(Context context) {
+ Intent intent = new Intent("org.torproject.android.intent.action.START");
+ intent.setPackage("org.torproject.android");
+ intent.putExtra("org.torproject.android.intent.extra.PACKAGE_NAME", context.getPackageName());
+ context.sendBroadcast(intent);
+ }
+
+ //Credit: https://www.geekality.net/2013/04/30/java-simple-check-to-see-if-a-server-is-listening-on-a-port/
+ public static boolean isPortListening(String host, int port) {
+ Socket s = null;
+ try {
+ s = new Socket(host, port);
+ return true;
+ } catch(Exception e) {
+ return false;
+ } finally {
+ if (s != null) {
+ try {
+ s.close();
+ } catch(Exception e1) {
+ }
+ }
+ }
+ }
+
+ public static boolean waitUntilOrbotIsAvailable() {
+ int tries = 0;
+ boolean listening;
+ while(!(listening = isPortListening("127.0.0.1", 9050)) && tries <= 60) {
+ tries++;
+ try {
+ Thread.sleep(1000);
+ } catch(Exception e) {
+
+ }
+ }
+ return listening;
+ }
+
public static String getServerURL(Context context) {
String incrementalVersion = SystemProperties.get(Constants.PROP_BUILD_VERSION_INCREMENTAL);
String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE,
SystemProperties.get(Constants.PROP_DEVICE));
String server = "0OTA_SERVER_CLEARNET0";
+ String serverOnion = "0OTA_SERVER_ONION0";
+ if(serverOnion.toLowerCase().startsWith("http") && isOnionRoutingEnabled(context)) {
+ server = serverOnion;
+ }
return server + "?base=LineageOS&device=" + device + "&inc=" + incrementalVersion;
}
--
2.19.0

@ -1 +1 @@
Subproject commit 65ee44ddf038b4a66b266325e7d5a77dff3d9bb4 Subproject commit 2a1209875213eb9afd38b9b85b1f4c9af0582d95

View File

@ -133,6 +133,7 @@ patch -p1 < "$DOS_PATCHES/android_packages_apps_SetupWizard/0001-Remove_Analytic
enterAndClear "packages/apps/Updater"; enterAndClear "packages/apps/Updater";
patch -p1 < "$DOS_PATCHES_COMMON/android_packages_apps_Updater/0001-Server.patch"; #Switch to our server patch -p1 < "$DOS_PATCHES_COMMON/android_packages_apps_Updater/0001-Server.patch"; #Switch to our server
patch -p1 < "$DOS_PATCHES_COMMON/android_packages_apps_Updater/0002-Tor_Support.patch"; #Add Tor support
#TODO: Remove changelog #TODO: Remove changelog
enterAndClear "packages/apps/WallpaperPicker"; enterAndClear "packages/apps/WallpaperPicker";

View File

@ -43,7 +43,8 @@ sed -i '/.*setup_services/s/LineageOS/'"$DOS_BRANDING_NAME"'/' res/values*/strin
sed -i '/.*services_explanation/s/LineageOS/'"$DOS_BRANDING_NAME"'/' res/values*/strings.xml; sed -i '/.*services_explanation/s/LineageOS/'"$DOS_BRANDING_NAME"'/' res/values*/strings.xml;
enter "packages/apps/Updater"; enter "packages/apps/Updater";
sed -i 's|0OTASERVER0|'"$DOS_BRANDING_SERVER_OTA"'|' src/org/lineageos/updater/misc/Utils.java; sed -i 's|0OTA_SERVER_CLEARNET0|'"$DOS_BRANDING_SERVER_OTA"'|' src/org/lineageos/updater/misc/Utils.java;
sed -i 's|0OTA_SERVER_ONION0|'"$DOS_BRANDING_SERVER_OTA_ONION"'|' src/org/lineageos/updater/misc/Utils.java;
sed -i 's|>LineageOS|>'"$DOS_BRANDING_NAME"'|' res/values*/strings.xml; sed -i 's|>LineageOS|>'"$DOS_BRANDING_NAME"'|' res/values*/strings.xml;
enter "vendor/cm"; enter "vendor/cm";

View File

@ -137,6 +137,7 @@ patch -p1 < "$DOS_PATCHES/android_packages_apps_SetupWizard/0001-Remove_Analytic
enterAndClear "packages/apps/Updater"; enterAndClear "packages/apps/Updater";
patch -p1 < "$DOS_PATCHES_COMMON/android_packages_apps_Updater/0001-Server.patch"; #Switch to our server patch -p1 < "$DOS_PATCHES_COMMON/android_packages_apps_Updater/0001-Server.patch"; #Switch to our server
patch -p1 < "$DOS_PATCHES_COMMON/android_packages_apps_Updater/0002-Tor_Support.patch"; #Add Tor support
#TODO: Remove changelog #TODO: Remove changelog
enterAndClear "packages/apps/WallpaperPicker"; enterAndClear "packages/apps/WallpaperPicker";

View File

@ -55,7 +55,8 @@ sed -i '/.*setup_services/s/LineageOS/'"$DOS_BRANDING_NAME"'/' res/values*/strin
sed -i '/.*services_explanation/s/LineageOS/'"$DOS_BRANDING_NAME"'/' res/values*/strings.xml; sed -i '/.*services_explanation/s/LineageOS/'"$DOS_BRANDING_NAME"'/' res/values*/strings.xml;
enter "packages/apps/Updater"; enter "packages/apps/Updater";
sed -i 's|0OTASERVER0|'"$DOS_BRANDING_SERVER_OTA"'|' src/org/lineageos/updater/misc/Utils.java; sed -i 's|0OTA_SERVER_CLEARNET0|'"$DOS_BRANDING_SERVER_OTA"'|' src/org/lineageos/updater/misc/Utils.java;
sed -i 's|0OTA_SERVER_ONION0|'"$DOS_BRANDING_SERVER_OTA_ONION"'|' src/org/lineageos/updater/misc/Utils.java;
sed -i 's|>LineageOS|>'"$DOS_BRANDING_NAME"'|' res/values*/strings.xml; sed -i 's|>LineageOS|>'"$DOS_BRANDING_NAME"'|' res/values*/strings.xml;
enter "vendor/lineage"; enter "vendor/lineage";

View File

@ -53,6 +53,7 @@ export DOS_BRANDING_BOOTANIMATION_COLOR="#FF5722-#03A9F4"; #plasma
export DOS_BRANDING_LINK_ABOUT="https://divestos.xyz/index.php?page=about"; export DOS_BRANDING_LINK_ABOUT="https://divestos.xyz/index.php?page=about";
export DOS_BRANDING_LINK_PRIVACY="https://divestos.xyz/index.php?page=privacy_policy"; export DOS_BRANDING_LINK_PRIVACY="https://divestos.xyz/index.php?page=privacy_policy";
export DOS_BRANDING_SERVER_OTA="https://divestos.xyz/updater.php"; export DOS_BRANDING_SERVER_OTA="https://divestos.xyz/updater.php";
export DOS_BRANDING_SERVER_OTA_ONION=$DOS_BRANDING_SERVER_OTA; #TODO: Setup Onion
export DOS_THEME_50="FFCA28"; #Amber 400 export DOS_THEME_50="FFCA28"; #Amber 400
export DOS_THEME_100="FFC107"; #Amber 500 export DOS_THEME_100="FFC107"; #Amber 500