Skip to content

Commit

Permalink
8.0
Browse files Browse the repository at this point in the history
REQUIRED UPGRADE

Fix -> #588
  • Loading branch information
tonikelope committed Oct 20, 2023
1 parent fc4830c commit adb742d
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 54 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tonikelope</groupId>
<artifactId>MegaBasterd</artifactId>
<version>7.99</version>
<version>8.0</version>
<packaging>jar</packaging>
<repositories>
<repository>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/tonikelope/megabasterd/ChunkDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,6 @@ public void run() {

} else if (_current_smart_proxy == null) {

if (!getDownload().isTurbo()) {
getDownload().enableTurboMode();
}

String[] smart_proxy = proxy_manager.getProxy(_excluded_proxy_list);

_current_smart_proxy = smart_proxy[0];
Expand All @@ -218,6 +214,10 @@ public void run() {

if (_current_smart_proxy != null) {

if (!getDownload().isTurbo()) {
getDownload().enableTurboMode();
}

String[] proxy_info = _current_smart_proxy.split(":");

Proxy proxy = new Proxy(smart_proxy_socks ? Proxy.Type.SOCKS : Proxy.Type.HTTP, new InetSocketAddress(proxy_info[0], Integer.parseInt(proxy_info[1])));
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/tonikelope/megabasterd/Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void disableTurboMode() {
_turbo = false;
MiscTools.GUIRun(() -> {

getView().getSpeed_label().setForeground(Color.BLACK);
getView().getSpeed_label().setForeground(new Color(0, 128, 255));

});
}
Expand Down Expand Up @@ -1353,8 +1353,6 @@ private boolean verifyFileCBCMAC(String filename) throws FileNotFoundException,

int old_thread_priority = Thread.currentThread().getPriority();

Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

int[] int_key = bin2i32a(UrlBASE642Bin(_file_key));
int[] iv = new int[]{int_key[4], int_key[5]};
int[] meta_mac = new int[]{int_key[6], int_key[7]};
Expand Down Expand Up @@ -1430,8 +1428,6 @@ private boolean verifyFileCBCMAC(String filename) throws FileNotFoundException,

int[] cbc = {file_mac[0] ^ file_mac[1], file_mac[2] ^ file_mac[3]};

Thread.currentThread().setPriority(old_thread_priority);

return (cbc[0] == meta_mac[0] && cbc[1] == meta_mac[1]);
}
}
Expand Down Expand Up @@ -1519,7 +1515,7 @@ public String[] getMegaFileMetadata(String link, MainPanelView panel, boolean re
error_code = ex.getCode();

if (error_code == -16) {
_status_error = "ERROR: MEGA LINK BLOCKED/DELETED";
_status_error = "ERROR: MEGA FILE BLOCKED/DELETED";
}

if (Arrays.asList(FATAL_API_ERROR_CODES).contains(error_code)) {
Expand Down Expand Up @@ -1608,11 +1604,15 @@ public String getMegaFileDownloadUrl(String link) throws IOException, Interrupte

error_code = ex.getCode();

if (error_code == -16) {
_status_error = "ERROR: MEGA FILE BLOCKED/DELETED";
}

if (Arrays.asList(FATAL_API_ERROR_CODES).contains(error_code)) {

_auto_retry_on_error = Arrays.asList(FATAL_API_ERROR_CODES_WITH_RETRY).contains(error_code);

stopDownloader(ex.getMessage() + " " + truncateText(link, 80));
stopDownloader(error_code == -16 ? _status_error : ex.getMessage() + " " + truncateText(link, 80));

} else {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<Component id="restore_button" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="file_tree_scrollpane" pref="295" max="32767" attributes="0"/>
<Component id="file_tree_scrollpane" pref="289" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="node_bar" min="-2" pref="14" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
Expand Down Expand Up @@ -210,9 +210,12 @@
<Component class="javax.swing.JLabel" name="total_space_label">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="28" style="1"/>
<Font name="Dialog" size="32" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="[0 B]"/>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="33" red="0" type="rgb"/>
</Property>
<Property name="text" type="java.lang.String" value="[---]"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
Expand Down
23 changes: 18 additions & 5 deletions src/main/java/com/tonikelope/megabasterd/FolderLinkDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public FolderLinkDialog(MainPanelView parent, boolean modal, String link) {

translateLabels(this);

file_tree.setRootVisible(false);

node_bar.setIndeterminate(true);

folder_link_label.setText(link);
Expand All @@ -108,15 +110,23 @@ public FolderLinkDialog(MainPanelView parent, boolean modal, String link) {
} else if (_mega_error == -18) {

MiscTools.GUIRun(() -> {
JOptionPane.showMessageDialog(tthis, LabelTranslatorSingleton.getInstance().translate("MEGA LINK TEMPORARILY UNAVAILABLE!"), "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(tthis, LabelTranslatorSingleton.getInstance().translate("MEGA FOLDER TEMPORARILY UNAVAILABLE!"), "Error", JOptionPane.ERROR_MESSAGE);

setVisible(false);
});

} else if (_mega_error == -16) {

MiscTools.GUIRun(() -> {
JOptionPane.showMessageDialog(tthis, LabelTranslatorSingleton.getInstance().translate("MEGA FOLDER BLOCKED/DELETED"), "Error", JOptionPane.ERROR_MESSAGE);

setVisible(false);
});

} else {

MiscTools.GUIRun(() -> {
JOptionPane.showMessageDialog(tthis, LabelTranslatorSingleton.getInstance().translate("MEGA LINK ERROR!"), "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(tthis, LabelTranslatorSingleton.getInstance().translate("MEGA FOLDER LINK ERROR!"), "Error", JOptionPane.ERROR_MESSAGE);

setVisible(false);
});
Expand Down Expand Up @@ -221,8 +231,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

total_space_label.setFont(new java.awt.Font("Dialog", 1, 28)); // NOI18N
total_space_label.setText("[0 B]");
total_space_label.setFont(new java.awt.Font("Dialog", 1, 32)); // NOI18N
total_space_label.setForeground(new java.awt.Color(0, 51, 255));
total_space_label.setText("[---]");
total_space_label.setDoubleBuffered(true);
total_space_label.setEnabled(false);

Expand Down Expand Up @@ -260,7 +271,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(folder_link_label)
.addComponent(restore_button))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 295, Short.MAX_VALUE)
.addComponent(file_tree_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(node_bar, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
Expand Down Expand Up @@ -589,6 +600,8 @@ private void _genDownloadLiks() {

Enumeration files_tree = root.depthFirstEnumeration();

total_space_label.setText("[---]");

THREAD_POOL.execute(() -> {

String folder_id = findFirstRegex("#F!([^!]+)", _link, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/MainPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/
public final class MainPanel {

public static final String VERSION = "7.99";
public static final String VERSION = "8.0";
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;
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/tonikelope/megabasterd/MainPanelView.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ private void _new_upload_dialog(FileGrabberDialog dialog) {

Runnable run = () -> {

Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

MegaAPI ma = getMain_panel().getMega_active_accounts().get(mega_account);

try {
Expand Down Expand Up @@ -1042,8 +1040,6 @@ private void new_download_menuActionPerformed(java.awt.event.ActionEvent evt) {/

Runnable run = () -> {

Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

//Convert to legacy link format
String link_data = MiscTools.newMegaLinks2Legacy(dialog.getLinks_textarea().getText());

Expand Down
40 changes: 20 additions & 20 deletions src/main/java/com/tonikelope/megabasterd/MegaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void _realLogin(String pincode) throws Exception {
request = "[{\"a\":\"us\",\"user\":\"" + _email + "\",\"uh\":\"" + _user_hash + "\"}]";
}

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=");
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -198,7 +198,7 @@ private void _readAccountVersionAndSalt() throws Exception {

String request = "[{\"a\":\"us0\",\"user\":\"" + _email + "\"}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=");
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno));

String res = RAW_REQUEST(request, url_api);

Expand All @@ -216,7 +216,7 @@ public boolean check2FA(String email) throws Exception {

String request = "[{\"a\":\"mfag\",\"e\":\"" + email + "\"}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=");
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -286,7 +286,7 @@ public Long[] getQuota() {

URL url_api;

url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -330,7 +330,7 @@ public void fetchNodes() throws IOException {

try {

url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -551,12 +551,12 @@ public String getMegaFileDownloadUrl(String link) throws MegaAPIException, Malfo

request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]";

url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "") + "&n=" + folder_id);
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + "&n=" + folder_id);

} else {

request = "[{\"a\":\"g\", \"g\":\"1\", \"p\":\"" + file_id + "\"}]";
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));
}

String data = RAW_REQUEST(request, url_api);
Expand Down Expand Up @@ -589,13 +589,13 @@ public String[] getMegaFileMetadata(String link) throws MegaAPIException, Malfor

request = "[{\"a\":\"g\", \"g\":\"1\", \"n\":\"" + file_id + "\"}]";

url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : "") + "&n=" + folder_id);
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + "&n=" + folder_id);

} else {

request = "[{\"a\":\"g\", \"p\":\"" + file_id + "\"}]";

url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));
}

String data = RAW_REQUEST(request, url_api);
Expand Down Expand Up @@ -698,7 +698,7 @@ public String initUploadFile(String filename) throws MegaAPIException {

String request = "[{\"a\":\"u\", \"s\":" + String.valueOf(f.length()) + "}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -741,7 +741,7 @@ public String uploadThumbnails(Upload upload, String node_handle, String filenam

String request = "[{\"a\":\"ufa\", \"s\":" + String.valueOf(file_bytes[0].length) + ", \"ssl\":1}, {\"a\":\"ufa\", \"s\":" + String.valueOf(file_bytes[1].length) + ", \"ssl\":1}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -799,7 +799,7 @@ public String uploadThumbnails(Upload upload, String node_handle, String filenam

request = "[{\"a\":\"pfa\", \"fa\":\"0*" + hash[0] + "/1*" + hash[1] + "\", \"n\":\"" + node_handle + "\"}]";

url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -828,7 +828,7 @@ public HashMap<String, Object> finishUploadFile(String fbasename, int[] ul_key,

byte[] enc_att = _encAttr("{\"n\":\"" + fbasename + "\"}", i32a2bin(Arrays.copyOfRange(ul_key, 0, 4)));

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String request = "[{\"a\":\"p\", \"t\":\"" + mega_parent + "\", \"n\":[{\"h\":\"" + completion_handle + "\", \"t\":0, \"a\":\"" + Bin2UrlBASE64(enc_att) + "\", \"k\":\"" + Bin2UrlBASE64(encryptKey(i32a2bin(fkey), master_key)) + "\"}], \"i\":\"" + _req_id + "\", \"cr\" : [ [\"" + root_node + "\"] , [\"" + completion_handle + "\"] , [0,0, \"" + Bin2UrlBASE64(encryptKey(i32a2bin(fkey), share_key)) + "\"]]}]";

Expand Down Expand Up @@ -885,7 +885,7 @@ public HashMap<String, Object> createDir(String name, String parent_node, byte[]

byte[] enc_node_key = encryptKey(node_key, master_key);

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String request = "[{\"a\":\"p\", \"t\":\"" + parent_node + "\", \"n\":[{\"h\":\"xxxxxxxx\",\"t\":1,\"a\":\"" + Bin2UrlBASE64(enc_att) + "\",\"k\":\"" + Bin2UrlBASE64(enc_node_key) + "\"}],\"i\":\"" + _req_id + "\"}]";

Expand Down Expand Up @@ -915,7 +915,7 @@ public HashMap<String, Object> createDirInsideAnotherSharedDir(String name, Stri

byte[] enc_node_key_s = encryptKey(node_key, share_key);

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String request = "[{\"a\":\"p\", \"t\":\"" + parent_node + "\", \"n\":[{\"h\":\"xxxxxxxx\",\"t\":1,\"a\":\"" + Bin2UrlBASE64(enc_att) + "\",\"k\":\"" + Bin2UrlBASE64(enc_node_key) + "\"}],\"i\":\"" + _req_id + "\", \"cr\" : [ [\"" + root_node + "\"] , [\"xxxxxxxx\"] , [0,0, \"" + Bin2UrlBASE64(enc_node_key_s) + "\"]]}]";

Expand Down Expand Up @@ -945,7 +945,7 @@ public String getPublicFileLink(String node, byte[] node_key) {

String request = "[{\"a\":\"l\", \"n\":\"" + node + "\"}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -976,7 +976,7 @@ public String getPublicFolderLink(String node, byte[] node_key) {

String request = "[{\"a\":\"l\", \"n\":\"" + node + "\", \"i\":\"" + _req_id + "\"}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -1023,7 +1023,7 @@ public String shareFolder(String node, byte[] node_key, byte[] share_key) {
//OJO
String request = "[{\"a\":\"s2\",\"n\":\"" + node + "\",\"s\":[{\"u\":\"EXP\",\"r\":0}],\"i\":\"" + _req_id + "\",\"ok\":\"AAAAAAAAAAAAAAAAAAAAAA\",\"ha\":\"AAAAAAAAAAAAAAAAAAAAAA\",\"cr\":[[\"" + node + "\"],[\"" + node + "\"],[0,0,\"" + enc_nk + "\"]]}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + (_sid != null ? "&sid=" + _sid : ""));
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : ""));

return RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -1055,7 +1055,7 @@ public HashMap<String, Object> getFolderNodes(String folder_id, String folder_ke

String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\", \"ca\":\"1\"}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + "&n=" + folder_id);
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&n=" + folder_id);

String res = RAW_REQUEST(request, url_api);

Expand Down Expand Up @@ -1202,7 +1202,7 @@ public ArrayList<String> getNLinksFromFolder(String folder_id, String folder_key

String request = "[{\"a\":\"f\", \"c\":\"1\", \"r\":\"1\"}]";

URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&v=3&lang=es&domain=meganz&ec=" + "&n=" + folder_id);
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + "&n=" + folder_id);

String res = RAW_REQUEST(request, url_api);

Expand Down
Loading

0 comments on commit adb742d

Please sign in to comment.