Custom Smart Proxy Auth USER AND PASS REQUIRED IN BASE64

Custom Smart Proxy List SOCKS support (put * before IP for SOCKS proxy)
This commit is contained in:
tonikelope 2020-02-26 14:35:40 +01:00
parent 28de933492
commit 5a1aeb62fd
14 changed files with 169 additions and 90 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>7.19</version>
<version>7.20</version>
<packaging>jar</packaging>
<dependencies>
<dependency>

View File

@ -119,7 +119,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
int http_error = 0, http_status = -1, conta_error = 0;
boolean chunk_error = false, slow_proxy = false, timeout = false;
boolean chunk_error = false, slow_proxy = false, timeout = false, smart_proxy_socks = false;
String worker_url = null;
@ -131,7 +131,11 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
if (MainPanel.FORCE_SMART_PROXY) {
_current_smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
_current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
if (!getDownload().isTurbo()) {
getDownload().enableTurboMode();
@ -183,7 +187,11 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
_excluded_proxy_list.add(_current_smart_proxy);
_current_smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
_current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
Logger.getLogger(MiscTools.class.getName()).log(Level.WARNING, "{0}: worker {1} excluding proxy -> {2} {3}", new Object[]{Thread.currentThread().getName(), _id, _current_smart_proxy, _download.getFile_name()});
@ -193,7 +201,11 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
getDownload().enableTurboMode();
}
_current_smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);
_current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
}
@ -201,7 +213,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
String[] proxy_info = _current_smart_proxy.split(":");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
Proxy proxy = new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
URL url = new URL(chunk_url);
@ -224,7 +236,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
_current_smart_proxy = null;
con = (HttpURLConnection) url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
con = (HttpURLConnection) url.openConnection(new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
if (MainPanel.getProxy_user() != null && !"".equals(MainPanel.getProxy_user())) {

View File

@ -5,11 +5,11 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.ArrayList;
/**
*

View File

@ -39,7 +39,7 @@ public class LabelTranslatorSingleton {
private void Spanish() {
_addTranslation("Execute this command when MEGA download limit is reached:", "Ejecutar este comando cuando se alcance el límite de descarga de MEGA:");
_addTranslation("Use this proxy list (instead of the one included in MegaBasterd) Format is IP:PORT[@user:password_b64]", "Usar esta lista de proxys (en vez de la incluida en MegaBasterd) El formato es IP:PUERTO[@usuario:password_b64]");
_addTranslation("Use this proxy list (instead of the one included in MegaBasterd) Format is [*]IP:PORT[@user_b64:password_b64]", "Usar esta lista de proxys (en vez de la incluida en MegaBasterd) El formato es [*]IP:PUERTO[@usuario_b64:password_b64]");
_addTranslation("Waiting for completion handler ... ***DO NOT EXIT MEGABASTERD NOW***", "Esperando manejador de finalización ... ***NO CIERRES MEGABASTERD EN ESTE MOMENTO***");
_addTranslation("Finishing calculating CBC-MAC code (this could take a while) ... ***DO NOT EXIT MEGABASTERD NOW***", "Terminando de calcular código CBC-MAC (esto podría llevar tiempo) ... ***NO CIERRES MEGABASTERD EN ESTE MOMENTO***");
_addTranslation("Split content in different uploads", "Separar contenido en diferentes subidas");
@ -299,7 +299,7 @@ public class LabelTranslatorSingleton {
public String translate(String orig) {
return _rosetta.containsKey(orig) ? _rosetta.get(orig) : orig;
return (orig != null && _rosetta.containsKey(orig)) ? _rosetta.get(orig) : orig;
}
private static class LazyHolder {

View File

@ -57,7 +57,7 @@ import javax.swing.UIManager;
*/
public final class MainPanel {
public static final String VERSION = "7.19";
public static final String VERSION = "7.20";
public static final boolean FORCE_SMART_PROXY = false; //TRUE FOR DEBUGING SMART PROXY
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;

View File

@ -1210,8 +1210,6 @@ public final class MainPanelView extends javax.swing.JFrame {
MainPanel.getProxy_manager().refreshProxyList();
updateSmartProxyStatus("SmartProxy: ON (" + String.valueOf(MainPanel.getProxy_manager().getProxyCount()) + ")");
} else {
updateSmartProxyStatus("SmartProxy: OFF");

View File

@ -356,7 +356,7 @@ public class MegaAPI implements Serializable {
int mega_error = 0, http_error = 0, conta_error = 0, http_status;
boolean empty_response = false;
boolean empty_response = false, smart_proxy_socks = false;
HttpsURLConnection con = null;
@ -366,7 +366,11 @@ public class MegaAPI implements Serializable {
if (MainPanel.FORCE_SMART_PROXY) {
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
}
@ -384,18 +388,26 @@ public class MegaAPI implements Serializable {
excluded_proxy_list.add(current_smart_proxy);
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
} else if (current_smart_proxy == null) {
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
}
if (current_smart_proxy != null) {
String[] proxy_info = current_smart_proxy.split(":");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
Proxy proxy = new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
con = (HttpsURLConnection) url_api.openConnection(proxy);
@ -408,7 +420,7 @@ public class MegaAPI implements Serializable {
if (MainPanel.isUse_proxy()) {
con = (HttpsURLConnection) url_api.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
con = (HttpsURLConnection) url_api.openConnection(new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
if (MainPanel.getProxy_user() != null && !"".equals(MainPanel.getProxy_user())) {

View File

@ -858,11 +858,17 @@ public class MiscTools {
String current_smart_proxy = null;
boolean smart_proxy_socks = false;
ArrayList<String> excluded_proxy_list = new ArrayList<>();
if (MainPanel.FORCE_SMART_PROXY) {
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
}
@ -882,18 +888,26 @@ public class MiscTools {
excluded_proxy_list.add(current_smart_proxy);
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
} else if (current_smart_proxy == null) {
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
}
if (current_smart_proxy != null) {
String[] proxy_info = current_smart_proxy.split(":");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
Proxy proxy = new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
con = (HttpURLConnection) url.openConnection(proxy);
@ -901,7 +915,7 @@ public class MiscTools {
if (MainPanel.isUse_proxy()) {
con = (HttpURLConnection) url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
con = (HttpURLConnection) url.openConnection(new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
if (MainPanel.getProxy_user() != null && !"".equals(MainPanel.getProxy_user())) {
@ -917,7 +931,7 @@ public class MiscTools {
if (MainPanel.isUse_proxy()) {
con = (HttpURLConnection) url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
con = (HttpURLConnection) url.openConnection(new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
if (MainPanel.getProxy_user() != null && !"".equals(MainPanel.getProxy_user())) {

View File

@ -31,7 +31,7 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" pref="1122" max="32767" attributes="0"/>
<Component id="jTabbedPane1" pref="1071" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="status" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
@ -48,7 +48,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jTabbedPane1" pref="518" max="32767" attributes="0"/>
<Component id="jTabbedPane1" pref="907" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
@ -191,7 +191,7 @@
</Group>
</Group>
</Group>
<EmptySpace min="0" pref="76" max="32767" attributes="0"/>
<EmptySpace min="0" pref="25" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
@ -254,7 +254,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="rec_download_slots_label" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jSeparator7" min="-2" pref="2" max="-2" attributes="0"/>
<Component id="jSeparator7" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="limit_download_speed_checkbox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -295,7 +295,7 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="custom_proxy_list_label" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="186" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="224" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -556,7 +556,7 @@
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" value="Use this proxy list (instead of the one included in MegaBasterd) Format is IP:PORT[@user:password_b64]"/>
<Property name="text" type="java.lang.String" value="Use this proxy list (instead of the one included in MegaBasterd) Format is [*]IP:PORT[@user_b64:password_b64]"/>
</Properties>
</Component>
</SubComponents>
@ -804,7 +804,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="mega_accounts_scrollpane" pref="111" max="32767" attributes="0"/>
<Component id="mega_accounts_scrollpane" pref="305" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="remove_mega_account_button" alignment="3" min="-2" max="-2" attributes="0"/>
@ -813,7 +813,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="elc_accounts_label" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="elc_accounts_scrollpane" pref="111" max="32767" attributes="0"/>
<Component id="elc_accounts_scrollpane" pref="306" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="remove_elc_account_button" alignment="3" min="-2" max="-2" attributes="0"/>
@ -1070,7 +1070,7 @@
<Component id="zoom_label" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="zoom_spinner" min="-2" pref="100" max="-2" attributes="0"/>
<EmptySpace min="0" pref="261" max="32767" attributes="0"/>
<EmptySpace min="0" pref="237" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
@ -1167,10 +1167,8 @@
<SubComponents>
<Container class="javax.swing.JPanel" name="proxy_panel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Proxy settings"/>
</Border>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="javax.swing.BorderFactory.createTitledBorder((String)null)" type="code"/>
</Property>
</Properties>
@ -1218,9 +1216,9 @@
<Component id="proxy_port_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="proxy_port_textfield" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="18" max="32767" attributes="0"/>
<Component id="proxy_auth_panel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -1294,10 +1292,8 @@
</Component>
<Container class="javax.swing.JPanel" name="proxy_auth_panel">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Authentication"/>
</Border>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="javax.swing.BorderFactory.createTitledBorder((String)null)" type="code"/>
</Property>
</Properties>
@ -1307,25 +1303,27 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="proxy_user_label" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="proxy_user_textfield" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Component id="proxy_user_textfield" pref="297" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="proxy_pass_label" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Component id="proxy_pass_textfield" pref="461" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="proxy_pass_textfield" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="12" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="proxy_user_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="proxy_user_textfield" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="proxy_pass_label" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="proxy_pass_textfield" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

View File

@ -832,7 +832,7 @@ public class SettingsDialog extends javax.swing.JDialog {
custom_proxy_textarea.addMouseListener(new ContextMenuMouseListener());
custom_proxy_list_label.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
custom_proxy_list_label.setText("Use this proxy list (instead of the one included in MegaBasterd) Format is IP:PORT[@user:password_b64]");
custom_proxy_list_label.setText("Use this proxy list (instead of the one included in MegaBasterd) Format is [*]IP:PORT[@user_b64:password_b64]");
javax.swing.GroupLayout downloads_panelLayout = new javax.swing.GroupLayout(downloads_panel);
downloads_panel.setLayout(downloads_panelLayout);
@ -886,7 +886,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addComponent(rec_smart_proxy_label, javax.swing.GroupLayout.PREFERRED_SIZE, 542, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(custom_proxy_list_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jScrollPane1))))
.addGap(0, 76, Short.MAX_VALUE)))
.addGap(0, 25, Short.MAX_VALUE)))
.addGap(12, 12, 12))
.addGroup(downloads_panelLayout.createSequentialGroup()
.addGroup(downloads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -934,7 +934,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rec_download_slots_label)
.addGap(18, 18, 18)
.addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(limit_download_speed_checkbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -972,7 +972,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(custom_proxy_list_label)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
.addContainerGap())
);
@ -1245,7 +1245,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(mega_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
.addComponent(mega_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(accounts_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(remove_mega_account_button)
@ -1253,7 +1253,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(elc_accounts_label)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(elc_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE)
.addComponent(elc_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(accounts_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(remove_elc_account_button)
@ -1265,7 +1265,7 @@ public class SettingsDialog extends javax.swing.JDialog {
advanced_scrollpane.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
proxy_panel.setBorder(javax.swing.BorderFactory.createTitledBorder("Proxy settings"));
proxy_panel.setBorder(javax.swing.BorderFactory.createTitledBorder((String)null));
proxy_host_label.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
proxy_host_label.setText("Host:");
@ -1301,7 +1301,7 @@ public class SettingsDialog extends javax.swing.JDialog {
proxy_warning_label.setText("Note: MegaBasterd will use this proxy for ALL connections.");
proxy_warning_label.setEnabled(false);
proxy_auth_panel.setBorder(javax.swing.BorderFactory.createTitledBorder("Authentication"));
proxy_auth_panel.setBorder(javax.swing.BorderFactory.createTitledBorder((String)null));
proxy_user_label.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
proxy_user_label.setText("Username:");
@ -1329,22 +1329,24 @@ public class SettingsDialog extends javax.swing.JDialog {
.addGroup(proxy_auth_panelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(proxy_user_label)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(proxy_user_textfield)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(6, 6, 6)
.addComponent(proxy_user_textfield, javax.swing.GroupLayout.DEFAULT_SIZE, 297, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(proxy_pass_label)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(proxy_pass_textfield))
.addGap(6, 6, 6)
.addComponent(proxy_pass_textfield, javax.swing.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)
.addContainerGap())
);
proxy_auth_panelLayout.setVerticalGroup(
proxy_auth_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(proxy_auth_panelLayout.createSequentialGroup()
.addGap(0, 12, Short.MAX_VALUE)
.addGroup(proxy_auth_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(proxy_user_label)
.addComponent(proxy_user_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(proxy_pass_label)
.addComponent(proxy_pass_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
javax.swing.GroupLayout proxy_panelLayout = new javax.swing.GroupLayout(proxy_panel);
@ -1384,7 +1386,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addComponent(proxy_host_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(proxy_port_label)
.addComponent(proxy_port_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addComponent(proxy_auth_panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
@ -1504,7 +1506,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addComponent(zoom_label)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(zoom_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 261, Short.MAX_VALUE))
.addGap(0, 237, Short.MAX_VALUE))
.addGroup(advanced_panelLayout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -1592,7 +1594,7 @@ public class SettingsDialog extends javax.swing.JDialog {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1122, Short.MAX_VALUE)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1071, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(status, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(6, 6, 6)
@ -1605,7 +1607,7 @@ public class SettingsDialog extends javax.swing.JDialog {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 518, Short.MAX_VALUE)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 907, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

View File

@ -29,7 +29,7 @@ public final class SmartMegaProxyManager {
public static final int PROXY_AUTO_REFRESH_SLEEP_TIME = 15;
private static final Logger LOG = Logger.getLogger(SmartMegaProxyManager.class.getName());
private volatile String _proxy_list_url;
private final LinkedHashMap<String, Long> _proxy_list;
private final LinkedHashMap<String, Long[]> _proxy_list;
private static final HashMap<String, String> PROXY_LIST_AUTH = new HashMap<>();
private final MainPanel _main_panel;
@ -45,7 +45,7 @@ public final class SmartMegaProxyManager {
return _proxy_list.size();
}
public synchronized String getProxy(ArrayList<String> excluded) {
public synchronized String[] getProxy(ArrayList<String> excluded) {
if (_proxy_list.size() > 0) {
@ -55,9 +55,9 @@ public final class SmartMegaProxyManager {
for (String k : keys) {
if (_proxy_list.get(k) < current_time && (excluded == null || !excluded.contains(k))) {
if (_proxy_list.get(k)[0] < current_time && (excluded == null || !excluded.contains(k))) {
return k;
return new String[]{k, _proxy_list.get(k)[1] == -1L ? "http" : "socks"};
}
}
}
@ -79,7 +79,11 @@ public final class SmartMegaProxyManager {
if (_proxy_list.containsKey(proxy)) {
_proxy_list.put(proxy, System.currentTimeMillis() + PROXY_BLOCK_TIME * 1000);
Long[] proxy_data = _proxy_list.get(proxy);
proxy_data[0] = System.currentTimeMillis() + PROXY_BLOCK_TIME * 1000;
_proxy_list.put(proxy, proxy_data);
LOG.log(Level.WARNING, "{0} Smart Proxy Manager: BLOCKING PROXY -> {1} ({2} secs)", new Object[]{Thread.currentThread().getName(), proxy, PROXY_BLOCK_TIME});
}
@ -95,7 +99,7 @@ public final class SmartMegaProxyManager {
String custom_proxy_list = DBTools.selectSettingValue("custom_proxy_list");
LinkedHashMap<String, Long> custom_clean_list = new LinkedHashMap<>();
LinkedHashMap<String, Long[]> custom_clean_list = new LinkedHashMap<>();
HashMap<String, String> custom_clean_list_auth = new HashMap<>();
@ -109,7 +113,13 @@ public final class SmartMegaProxyManager {
for (String proxy : custom_list) {
System.out.println(proxy);
boolean socks = false;
if (proxy.trim().startsWith("*")) {
socks = true;
proxy = proxy.trim().substring(1);
}
if (proxy.trim().contains("@")) {
@ -117,10 +127,15 @@ public final class SmartMegaProxyManager {
custom_clean_list_auth.put(proxy_parts[0], proxy_parts[1]);
custom_clean_list.put(proxy_parts[0], current_time);
Long[] proxy_data = new Long[]{current_time, socks ? 1L : -1L};
custom_clean_list.put(proxy_parts[0], proxy_data);
} else if (proxy.trim().matches(".+?:[0-9]{1,5}")) {
custom_clean_list.put(proxy, current_time);
Long[] proxy_data = new Long[]{current_time, socks ? 1L : -1L};
custom_clean_list.put(proxy, proxy_data);
}
}
}
@ -177,21 +192,29 @@ public final class SmartMegaProxyManager {
for (String proxy : proxy_list) {
boolean socks = false;
if (proxy.trim().startsWith("*")) {
socks = true;
proxy = proxy.trim().substring(1);
}
if (proxy.trim().contains("@")) {
String[] proxy_parts = proxy.trim().split("@");
PROXY_LIST_AUTH.put(proxy_parts[0], proxy_parts[1]);
_proxy_list.put(proxy_parts[0], current_time);
Long[] proxy_data = new Long[]{current_time, socks ? 1L : -1L};
_proxy_list.put(proxy_parts[0], proxy_data);
} else if (proxy.trim().matches(".+?:[0-9]{1,5}")) {
_proxy_list.put(proxy, current_time);
Long[] proxy_data = new Long[]{current_time, socks ? 1L : -1L};
_proxy_list.put(proxy, proxy_data);
}
if (proxy.trim().matches(".+?:[0-9]{1,5}")) {
_proxy_list.put(proxy, current_time);
}
}
}
@ -206,7 +229,14 @@ public final class SmartMegaProxyManager {
LOG.log(Level.INFO, "{0} Smart Proxy Manager: proxy list refreshed ({1})", new Object[]{Thread.currentThread().getName(), _proxy_list.size()});
}
System.out.println(PROXY_LIST_AUTH);
Set<String> keys = _proxy_list.keySet();
for (String k : keys) {
Long[] pdata = _proxy_list.get(k);
System.out.println(k + " " + String.valueOf(pdata[0]) + " " + String.valueOf(pdata[1]));
}
} catch (MalformedURLException ex) {
LOG.log(Level.SEVERE, ex.getMessage());
@ -235,7 +265,7 @@ public final class SmartMegaProxyManager {
try {
String[] auth_data_parts = auth_data.split(":");
String user = auth_data_parts[0];
String user = new String(MiscTools.BASE642Bin(auth_data_parts[0]), "UTF-8");
String password = new String(MiscTools.BASE642Bin(auth_data_parts[1]), "UTF-8");

View File

@ -49,6 +49,8 @@ public class StreamChunkDownloader implements Runnable {
String current_smart_proxy = null;
boolean smart_proxy_socks = false;
long offset = -1;
SmartMegaProxyManager proxy_manager = MainPanel.getProxy_manager();
@ -57,8 +59,11 @@ public class StreamChunkDownloader implements Runnable {
if (MainPanel.FORCE_SMART_PROXY) {
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
}
while (!_exit && !_chunkmanager.isExit()) {
@ -93,13 +98,21 @@ public class StreamChunkDownloader implements Runnable {
excluded_proxy_list.add(current_smart_proxy);
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
Logger.getLogger(MiscTools.class.getName()).log(Level.WARNING, "{0}: worker {1} excluding proxy -> {2}", new Object[]{Thread.currentThread().getName(), _id, current_smart_proxy});
} else if (current_smart_proxy == null) {
current_smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
String[] smart_proxy = proxy_manager.getProxy(excluded_proxy_list);
current_smart_proxy = smart_proxy[0];
smart_proxy_socks = smart_proxy[1].equals("socks");
}
@ -107,7 +120,7 @@ public class StreamChunkDownloader implements Runnable {
String[] proxy_info = current_smart_proxy.split(":");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
Proxy proxy = new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
URL chunk_url = new URL(chunk_stream.getUrl());
@ -126,7 +139,7 @@ public class StreamChunkDownloader implements Runnable {
if (MainPanel.isUse_proxy()) {
con = (HttpURLConnection) chunk_url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
con = (HttpURLConnection) chunk_url.openConnection(new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(MainPanel.getProxy_host(), MainPanel.getProxy_port())));
if (MainPanel.getProxy_user() != null && !"".equals(MainPanel.getProxy_user())) {
@ -138,7 +151,7 @@ public class StreamChunkDownloader implements Runnable {
String[] proxy_info = current_smart_proxy.split(":");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
Proxy proxy = new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
con = (HttpURLConnection) chunk_url.openConnection(proxy);

View File

@ -1,8 +1,8 @@
package com.tonikelope.megabasterd;
import static com.tonikelope.megabasterd.Download.PROGRESS_WATCHDOG_TIMEOUT;
import static com.tonikelope.megabasterd.MainPanel.*;
import static com.tonikelope.megabasterd.MiscTools.*;
import static com.tonikelope.megabasterd.Transference.PROGRESS_WATCHDOG_TIMEOUT;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 226 KiB