proxy fixes

This commit is contained in:
gdlbo
2022-07-05 13:02:24 +03:00
parent 5054dbdc7d
commit a74c48d8d0
3 changed files with 44 additions and 74 deletions
@@ -8,7 +8,6 @@ import static ru.vtosters.lite.ui.vkui.VBottomSheetBuilder.VBSContent;
import static ru.vtosters.lite.utils.About.getBuildNumber;
import static ru.vtosters.lite.utils.About.getCommitLink;
import static ru.vtosters.lite.utils.CacheUtils.humanReadableByteCountBin;
import static ru.vtosters.lite.utils.Globals.*;
import static ru.vtosters.lite.utils.Globals.edit;
import static ru.vtosters.lite.utils.Globals.getDrawableFromUrl;
import static ru.vtosters.lite.utils.Globals.getIdentifier;
@@ -20,7 +19,6 @@ import static ru.vtosters.lite.utils.Globals.restartApplication;
import static ru.vtosters.lite.utils.Preferences.ads;
import static ru.vtosters.lite.utils.Preferences.devmenu;
import static ru.vtosters.lite.utils.Preferences.disableSettingsSumms;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import static ru.vtosters.lite.utils.Preferences.hasSpecialVerif;
import static ru.vtosters.lite.utils.Preferences.hasVerification;
import static ru.vtosters.lite.utils.Preferences.isValidSignature;
@@ -29,7 +27,6 @@ import static ru.vtosters.lite.utils.Preferences.navbar;
import static ru.vtosters.lite.utils.Preferences.offline;
import static ru.vtosters.lite.utils.Preferences.shortinfo;
import static ru.vtosters.lite.utils.Preferences.vkme;
import static ru.vtosters.lite.utils.Proxy.*;
import static ru.vtosters.lite.utils.Themes.getDarkTheme;
import static ru.vtosters.lite.utils.Themes.getLightTheme;
import static ru.vtosters.lite.utils.Themes.setTheme;
@@ -1,6 +1,8 @@
package ru.vtosters.lite.utils;
import static android.graphics.Bitmap.*;
import static android.graphics.Bitmap.Config;
import static android.graphics.Bitmap.createBitmap;
import static android.graphics.Bitmap.createScaledBitmap;
import static androidx.core.content.ContextCompat.getDrawable;
import static ru.vtosters.lite.utils.CacheUtils.getInstance;
import static ru.vtosters.lite.utils.LocaleUtils.getLocale;
@@ -2,23 +2,19 @@ package ru.vtosters.lite.utils;
import static java.lang.System.clearProperty;
import static java.lang.System.getProperties;
import static ru.vtosters.lite.utils.Globals.edit;
import static ru.vtosters.lite.utils.Globals.getPrefsValue;
import static ru.vtosters.lite.utils.Preferences.getBoolValue;
import android.util.Log;
import java.util.Properties;
public class Proxy{
public static String linkReplacer(String link){
String vkapi = "api.vk.com";
String oauth = "oauth.vk.com";
String vkstatic = "static.vk.com";
var vkapi = "api.vk.com";
var oauth = "oauth.vk.com";
var vkstatic = "static.vk.com";
String proxyapi = getPrefsValue("proxyapi");
String proxyoauth = getPrefsValue("proxyoauth");
String proxystatic = getPrefsValue("proxystatic");
var proxyapi = getPrefsValue("proxyapi");
var proxyoauth = getPrefsValue("proxyoauth");
var proxystatic = getPrefsValue("proxystatic");
if(!proxy() || link.isEmpty()){
return link;
@@ -45,7 +41,7 @@ public class Proxy{
}
public static String getAwayPhpCom(){
String proxyapi = getPrefsValue("proxyapi");
var proxyapi = getPrefsValue("proxyapi");
if(!proxy() & proxyapi.isEmpty()){
return "m.vk.com";
@@ -55,123 +51,102 @@ public class Proxy{
}
public static void setProxy(){
Properties properties = getProperties();
var type = getPrefsValue("proxy");
var properties = getProperties();
switch(getPrefsValue("proxy")) {
resetProxy(type);
switch(type){
case "zaborona":
properties.setProperty("socksProxyHost", "socks.zaboronahelp.pp.ua");
properties.setProperty("socksProxyPort", "1488");
resetProxySocks();
break;
case "socks":
properties.setProperty("socksProxyHost", proxyHostSocks());
properties.setProperty("socksProxyPort", proxyPortSocks());
resetProxySocks();
break;
case "http":
properties.setProperty("http.proxyHost", proxyHostHTTP());
properties.setProperty("http.proxyPort", proxyPortHTTP());
properties.setProperty("http.proxyUser", proxyUserHTTP());
properties.setProperty("http.proxyPassword", proxyPassHTTP());
resetProxyHttp();
break;
case "https":
properties.setProperty("https.proxyHost", proxyHostHTTPS());
properties.setProperty("https.proxyPort", proxyPortHTTPS());
properties.setProperty("https.proxyUser", proxyUserHTTPS());
properties.setProperty("https.proxyPassword", proxyPassHTTPS());
resetProxyHttps();
break;
default:
resetProxy();
break;
}
}
public static void resetProxy(){
clearProperty("https.proxyHost");
clearProperty("https.proxyPort");
clearProperty("https.proxyUser");
clearProperty("https.proxyPassword");
clearProperty("http.proxyHost");
clearProperty("http.proxyPort");
clearProperty("http.proxyUser");
clearProperty("http.proxyPassword");
public static void resetProxy(String except){
if(!except.equals("https")){
clearProperty("https.proxyHost");
clearProperty("https.proxyPort");
clearProperty("https.proxyUser");
clearProperty("https.proxyPassword");
}
if(!except.equals("http")){
clearProperty("http.proxyHost");
clearProperty("http.proxyPort");
clearProperty("http.proxyUser");
clearProperty("http.proxyPassword");
}
if(except.equals("socks") || except.equals("zaborona")){
return;
}
clearProperty("socksProxyHost");
clearProperty("socksPortHost");
} // Reset all proxies
public static void resetProxySocks(){
clearProperty("https.proxyHost");
clearProperty("https.proxyPort");
clearProperty("https.proxyUser");
clearProperty("https.proxyPassword");
clearProperty("http.proxyHost");
clearProperty("http.proxyPort");
clearProperty("http.proxyUser");
clearProperty("http.proxyPassword");
} // Reset all except socks
public static void resetProxyHttp(){
clearProperty("https.proxyHost");
clearProperty("https.proxyPort");
clearProperty("https.proxyUser");
clearProperty("https.proxyPassword");
clearProperty("socksProxyHost");
clearProperty("socksPortHost");
} // Reset all except http
public static void resetProxyHttps(){
clearProperty("http.proxyHost");
clearProperty("http.proxyPort");
clearProperty("http.proxyUser");
clearProperty("http.proxyPassword");
clearProperty("socksProxyHost");
clearProperty("socksPortHost");
} // Reset all except https
} // Reset proxy
public static String proxyHostHTTP(){
String string = getPrefsValue("proxyHostHTTP");
var string = getPrefsValue("proxyHostHTTP");
return string.isEmpty() ? "192.168.0.1" : string;
}
public static String proxyHostHTTPS(){
String string = getPrefsValue("proxyHostHTTPS");
var string = getPrefsValue("proxyHostHTTPS");
return string.isEmpty() ? "192.168.0.1" : string;
}
public static String proxyHostSocks(){
String string = getPrefsValue("proxyHostSocks");
var string = getPrefsValue("proxyHostSocks");
return string.isEmpty() ? "192.168.0.1" : string;
}
public static String proxyPortHTTP(){
String string = getPrefsValue("proxyPortHTTP");
var string = getPrefsValue("proxyPortHTTP");
return string.isEmpty() ? "8888" : string;
}
public static String proxyPortHTTPS(){
String string = getPrefsValue("proxyPortHTTPS");
var string = getPrefsValue("proxyPortHTTPS");
return string.isEmpty() ? "8888" : string;
}
public static String proxyPortSocks(){
String string = getPrefsValue("proxyPortSocks");
var string = getPrefsValue("proxyPortSocks");
return string.isEmpty() ? "8888" : string;
}
public static String proxyUserHTTP(){
String string = getPrefsValue("proxyUserHTTP");
var string = getPrefsValue("proxyUserHTTP");
return string.isEmpty() ? "" : string;
}
public static String proxyUserHTTPS(){
String string = getPrefsValue("proxyUserHTTPS");
var string = getPrefsValue("proxyUserHTTPS");
return string.isEmpty() ? "" : string;
}
public static String proxyPassHTTP(){
String string = getPrefsValue("proxyPassHTTP");
var string = getPrefsValue("proxyPassHTTP");
return string.isEmpty() ? "" : string;
}
@@ -183,8 +158,4 @@ public class Proxy{
public static boolean proxy(){
return getPrefsValue("proxy").equals("apiproxy");
}
public static boolean proxyvk(){
return getBoolValue("proxyvk", false);
} // Official vk proxy enforcer
}