tonikelope 2020-01-18 16:34:09 +01:00
parent 74cdeada79
commit 8730f2bfc8
7 changed files with 166 additions and 40 deletions

View File

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

View File

@ -167,6 +167,12 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
String chunk_url = ChunkWriterManager.genChunkUrl(worker_url, _download.getFile_size(), chunk_offset, chunk_size);
if (http_error == 509 && MainPanel.isRun_command()) {
MainPanel.run_external_command();
}
if ((_current_smart_proxy != null || http_error == 509) && MainPanel.isUse_smart_proxy() && !MainPanel.isUse_proxy()) {
if (_current_smart_proxy != null && (slow_proxy || chunk_error)) {

View File

@ -38,6 +38,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 PROXY:PORT", "Usar esta lista de proxys (en vez de la incluida en MegaBasterd) El formato es PROXY:PUERTO");
_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***");

View File

@ -55,13 +55,14 @@ import javax.swing.UIManager;
*/
public final class MainPanel {
public static final String VERSION = "7.10";
public static final String VERSION = "7.11";
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;
public static final int STREAMER_PORT = 1337;
public static final int WATCHDOG_PORT = 1338;
public static final int DEFAULT_MEGA_PROXY_PORT = 9999;
public static final int RUN_COMMAND_TIME = 600;
public static final String DEFAULT_LANGUAGE = "EN";
public static final boolean DEFAULT_SMART_PROXY = true;
public static final double FORCE_GARBAGE_COLLECTION_MAX_MEMORY_PERCENT = 0.7;
@ -77,12 +78,15 @@ public final class MainPanel {
private static String _proxy_user;
private static String _proxy_pass;
private static boolean _use_smart_proxy;
private static boolean _run_command;
private static String _run_command_path;
private static String _font;
private static SmartMegaProxyManager _proxy_manager;
private static String _language;
private static String _new_version;
private static Boolean _resume_uploads;
private static Boolean _resume_downloads;
private static long _last_run_command;
private static final Logger LOG = Logger.getLogger(MainPanel.class.getName());
public static void main(String args[]) {
@ -116,6 +120,14 @@ public final class MainPanel {
});
}
public static boolean isRun_command() {
return _run_command;
}
public static String getRun_command_path() {
return _run_command_path;
}
public static Boolean getApp_image() {
return _app_image;
}
@ -197,6 +209,8 @@ public final class MainPanel {
_exit = false;
_last_run_command = -1;
_restart = false;
_elc_accounts = new HashMap<>();
@ -779,6 +793,21 @@ public final class MainPanel {
_proxy_pass = DBTools.selectSettingValue("proxy_pass");
}
String run_command_string = DBTools.selectSettingValue("run_command");
if (run_command_string != null) {
_run_command = run_command_string.equals("yes");
}
String old_run_command_path = _run_command_path;
_run_command_path = DBTools.selectSettingValue("run_command_path");
if (_run_command && old_run_command_path != null && !old_run_command_path.equals(_run_command_path)) {
_last_run_command = -1;
}
String use_megacrypter_reverse = selectSettingValue("megacrypter_reverse");
if (use_megacrypter_reverse != null) {
@ -809,6 +838,22 @@ public final class MainPanel {
}
}
public static synchronized void run_external_command() {
if (_run_command && (_last_run_command == -1 || _last_run_command + RUN_COMMAND_TIME * 1000 < System.currentTimeMillis())) {
if (_run_command_path != null && !_run_command_path.equals("")) {
try {
Runtime.getRuntime().exec(_run_command_path);
} catch (IOException ex) {
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, ex.getMessage());
}
_last_run_command = System.currentTimeMillis();
}
}
}
public boolean checkByeBye() {
boolean exit = true;

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="1071" max="32767" attributes="0"/>
<Component id="jTabbedPane1" pref="1153" 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"/>
@ -1054,24 +1054,11 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="run_command_textbox" max="32767" attributes="0"/>
<Component id="jSeparator15" alignment="1" max="32767" attributes="0"/>
<Component id="jSeparator12" alignment="1" max="32767" attributes="0"/>
<Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
<Component id="proxy_panel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="rec_zoom_label" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="start_frozen_checkbox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="custom_chunks_dir_checkbox" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="custom_chunks_dir_button" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="custom_chunks_dir_current_label" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
@ -1083,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="227" max="32767" attributes="0"/>
<EmptySpace min="0" pref="309" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
@ -1101,6 +1088,21 @@
<Component id="jButton1" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="proxy_panel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="run_command_checkbox" min="-2" max="-2" attributes="0"/>
<Component id="start_frozen_checkbox" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="custom_chunks_dir_checkbox" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="custom_chunks_dir_button" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="custom_chunks_dir_current_label" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="rec_zoom_label" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -1142,9 +1144,13 @@
<Component id="start_frozen_checkbox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jSeparator15" min="-2" pref="8" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="run_command_checkbox" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="run_command_textbox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="proxy_panel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="rec_zoom_label" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -1524,6 +1530,27 @@
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator15">
</Component>
<Component class="javax.swing.JCheckBox" name="run_command_checkbox">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="18" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Execute this command when MEGA download limit is reached:"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="run_command_checkboxActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="run_command_textbox">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="18" style="0"/>
</Property>
<Property name="doubleBuffered" type="boolean" value="true"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@ -493,6 +493,21 @@ public class SettingsDialog extends javax.swing.JDialog {
custom_proxy_list_label.setEnabled(use_smart_proxy);
custom_proxy_textarea.setEnabled(use_smart_proxy);
boolean run_command = false;
String run_command_string = DBTools.selectSettingValue("run_command");
if (run_command_string != null) {
run_command = run_command_string.equals("yes");
}
run_command_checkbox.setSelected(run_command);
run_command_textbox.setEnabled(run_command);
run_command_textbox.setText(DBTools.selectSettingValue("run_command_path"));
boolean init_paused = false;
String init_paused_string = DBTools.selectSettingValue("start_frozen");
@ -673,6 +688,8 @@ public class SettingsDialog extends javax.swing.JDialog {
jSeparator12 = new javax.swing.JSeparator();
start_frozen_checkbox = new javax.swing.JCheckBox();
jSeparator15 = new javax.swing.JSeparator();
run_command_checkbox = new javax.swing.JCheckBox();
run_command_textbox = new javax.swing.JTextField();
status = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@ -1444,28 +1461,31 @@ public class SettingsDialog extends javax.swing.JDialog {
start_frozen_checkbox.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
start_frozen_checkbox.setText("Freeze transferences before start");
run_command_checkbox.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
run_command_checkbox.setText("Execute this command when MEGA download limit is reached:");
run_command_checkbox.setDoubleBuffered(true);
run_command_checkbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
run_command_checkboxActionPerformed(evt);
}
});
run_command_textbox.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
run_command_textbox.setDoubleBuffered(true);
run_command_textbox.setEnabled(false);
javax.swing.GroupLayout advanced_panelLayout = new javax.swing.GroupLayout(advanced_panel);
advanced_panel.setLayout(advanced_panelLayout);
advanced_panelLayout.setHorizontalGroup(
advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, advanced_panelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator15, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSeparator12, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jSeparator1)
.addComponent(proxy_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(advanced_panelLayout.createSequentialGroup()
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(rec_zoom_label, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(start_frozen_checkbox, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(custom_chunks_dir_checkbox, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, advanced_panelLayout.createSequentialGroup()
.addComponent(custom_chunks_dir_button)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(custom_chunks_dir_current_label)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(advanced_panelLayout.createSequentialGroup()
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(run_command_textbox)
.addComponent(jSeparator15)
.addComponent(jSeparator12)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, advanced_panelLayout.createSequentialGroup()
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(advanced_panelLayout.createSequentialGroup()
.addComponent(font_label)
@ -1475,7 +1495,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, 227, Short.MAX_VALUE))
.addGap(0, 309, Short.MAX_VALUE))
.addGroup(advanced_panelLayout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -1486,7 +1506,19 @@ public class SettingsDialog extends javax.swing.JDialog {
.addComponent(import_settings_button)
.addGap(18, 18, 18)
.addComponent(export_settings_button))
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(proxy_panel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, advanced_panelLayout.createSequentialGroup()
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(run_command_checkbox)
.addComponent(start_frozen_checkbox)
.addComponent(custom_chunks_dir_checkbox)
.addGroup(advanced_panelLayout.createSequentialGroup()
.addComponent(custom_chunks_dir_button)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(custom_chunks_dir_current_label))
.addComponent(rec_zoom_label))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
advanced_panelLayout.setVerticalGroup(
@ -1521,9 +1553,13 @@ public class SettingsDialog extends javax.swing.JDialog {
.addComponent(start_frozen_checkbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator15, javax.swing.GroupLayout.PREFERRED_SIZE, 8, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(run_command_checkbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(run_command_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(proxy_panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(18, 18, 18)
.addComponent(rec_zoom_label)
.addContainerGap())
);
@ -1542,7 +1578,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, 1071, Short.MAX_VALUE)
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1153, 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)
@ -1606,6 +1642,8 @@ public class SettingsDialog extends javax.swing.JDialog {
settings.put("use_custom_chunks_dir", custom_chunks_dir_checkbox.isSelected() ? "yes" : "no");
settings.put("custom_chunks_dir", _custom_chunks_dir);
settings.put("custom_proxy_list", custom_proxy_textarea.getText());
settings.put("run_command", run_command_checkbox.isSelected() ? "yes" : "no");
settings.put("run_command_path", run_command_textbox.getText());
String old_font = DBTools.selectSettingValue("font");
@ -2749,6 +2787,13 @@ public class SettingsDialog extends javax.swing.JDialog {
}
}//GEN-LAST:event_custom_chunks_dir_buttonActionPerformed
private void run_command_checkboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_run_command_checkboxActionPerformed
// TODO add your handling code here:
run_command_textbox.setEnabled(run_command_checkbox.isSelected());
}//GEN-LAST:event_run_command_checkboxActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel accounts_panel;
private javax.swing.JButton add_elc_account_button;
@ -2833,6 +2878,8 @@ public class SettingsDialog extends javax.swing.JDialog {
private javax.swing.JLabel rec_zoom_label;
private javax.swing.JButton remove_elc_account_button;
private javax.swing.JButton remove_mega_account_button;
private javax.swing.JCheckBox run_command_checkbox;
private javax.swing.JTextField run_command_textbox;
private javax.swing.JButton save_button;
private javax.swing.JCheckBox smart_proxy_checkbox;
private javax.swing.JCheckBox start_frozen_checkbox;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

After

Width:  |  Height:  |  Size: 188 KiB