Skip to content

Commit

Permalink
2.98
Browse files Browse the repository at this point in the history
- Upload MULTI SLOT CHUNK SIZE 10MB
  • Loading branch information
tonikelope committed Mar 5, 2018
1 parent 1e4fca1 commit 69c049a
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 32 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>2.97</version>
<version>2.98</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void run() {
conta_error = 0;

while (!_upload.getMain_panel().isExit() && !_exit && !_upload.isStopped() && conta_error < MAX_SLOT_ERROR) {
chunk = new Chunk(_upload.nextChunkId(), _upload.getFile_size(), worker_url);
chunk = new Chunk(_upload.nextChunkId(), _upload.getFile_size(), worker_url, Upload.CHUNK_SIZE_MULTI);

f.seek(chunk.getOffset());

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 @@ -48,7 +48,7 @@
*/
public final class MainPanel {

public static final String VERSION = "2.97";
public static final String VERSION = "2.98";
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;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/tonikelope/megabasterd/SettingsDialog.form
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
<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="Use multi slot download mode (download restart required)"/>
<Property name="text" type="java.lang.String" value="Use multi slot download mode"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
Expand Down Expand Up @@ -600,7 +600,7 @@
</Group>
<Component id="limit_upload_speed_checkbox" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="476" max="32767" attributes="0"/>
<EmptySpace min="0" pref="612" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
Expand Down Expand Up @@ -685,7 +685,7 @@
<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="Use multi slot upload mode (upload restart required)"/>
<Property name="text" type="java.lang.String" value="Use multi slot upload mode"/>
<Property name="doubleBuffered" type="boolean" value="true"/>
</Properties>
<Events>
Expand Down Expand Up @@ -727,7 +727,7 @@
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="2"/>
</Property>
<Property name="text" type="java.lang.String" value="Note: MULTI-SLOT is required if you want to stop and resume uploads."/>
<Property name="text" type="java.lang.String" value="Note: MULTI-SLOT is required if you want to resume uploads."/>
</Properties>
</Component>
</SubComponents>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/tonikelope/megabasterd/SettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
use_mega_label.setText("Mega account (default):");

multi_slot_down_checkbox.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
multi_slot_down_checkbox.setText("Use multi slot download mode (download restart required)");
multi_slot_down_checkbox.setText("Use multi slot download mode");
multi_slot_down_checkbox.setDoubleBuffered(true);
multi_slot_down_checkbox.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
Expand Down Expand Up @@ -894,7 +894,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
max_uploads_spinner.setDoubleBuffered(true);

multi_slot_up_checkbox.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N
multi_slot_up_checkbox.setText("Use multi slot upload mode (upload restart required)");
multi_slot_up_checkbox.setText("Use multi slot upload mode");
multi_slot_up_checkbox.setDoubleBuffered(true);
multi_slot_up_checkbox.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
Expand All @@ -916,7 +916,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
});

rec_upload_slots_label.setFont(new java.awt.Font("Dialog", 2, 14)); // NOI18N
rec_upload_slots_label.setText("Note: MULTI-SLOT is required if you want to stop and resume uploads.");
rec_upload_slots_label.setText("Note: MULTI-SLOT is required if you want to resume uploads.");

javax.swing.GroupLayout uploads_panelLayout = new javax.swing.GroupLayout(uploads_panel);
uploads_panel.setLayout(uploads_panelLayout);
Expand Down Expand Up @@ -949,7 +949,7 @@ public void stateChanged(javax.swing.event.ChangeEvent evt) {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(max_up_speed_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(limit_upload_speed_checkbox))
.addGap(0, 476, Short.MAX_VALUE)))
.addGap(0, 612, Short.MAX_VALUE)))
.addContainerGap())))
);
uploads_panelLayout.setVerticalGroup(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tonikelope/megabasterd/Transference.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public interface Transference {

int MIN_WORKERS = 2;
int MAX_WORKERS = 30;
int MAX_WORKERS = 40;
int MAX_SIM_TRANSFERENCES = 30;
int SIM_TRANSFERENCES_DEFAULT = 4;
boolean LIMIT_TRANSFERENCE_SPEED_DEFAULT = false;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/tonikelope/megabasterd/Upload.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN

public static final boolean USE_SLOTS_DEFAULT = true;
public static final int WORKERS_DEFAULT = 8;
public static final int CHUNK_SIZE_MULTI = 10;
private final MainPanel _main_panel;
private volatile UploadView _view;
private volatile ProgressMeter _progress_meter;
Expand Down Expand Up @@ -1179,7 +1180,7 @@ public boolean isStatusError() {
public long calculateLastUploadedChunk(long bytes_read) {

if (bytes_read > 3584 * 1024) {
return 7 + (long) Math.ceil((float) (bytes_read - 3584 * 1024) / (1024 * 1024));
return 7 + (long) Math.ceil((float) (bytes_read - 3584 * 1024) / (1024 * 1024 * (this.isUse_slots() ? Upload.CHUNK_SIZE_MULTI : 1)));
} else {
int i = 0, tot = 0;

Expand Down
85 changes: 66 additions & 19 deletions src/main/java/com/tonikelope/megabasterd/UploadMACGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void run() {

while (_chunk_queue.containsKey(_last_chunk_id_read + 1)) {

if (!upload_workers_finish && _bytes_read == _upload.getFile_size()) {
if (!upload_workers_finish && _upload.getProgress() == _upload.getFile_size()) {

_upload.getView().printStatusNormal("Finishing FILE MAC calculation... ***DO NOT EXIT MEGABASTERD NOW***");

Expand All @@ -139,36 +139,83 @@ public void run() {

InputStream chunk_is = chunk.getInputStream();

try {
if (Upload.CHUNK_SIZE_MULTI == 1 || chunk.getId() <= 7) {

int[] chunk_mac = {file_iv[0], file_iv[1], file_iv[0], file_iv[1]};
byte[] byte_block = new byte[16];
try {

while ((reads = chunk_is.read(byte_block)) != -1) {
int[] chunk_mac = {file_iv[0], file_iv[1], file_iv[0], file_iv[1]};
byte[] byte_block = new byte[16];

if (reads < byte_block.length) {
for (int i = reads; i < byte_block.length; i++) {
byte_block[i] = 0;
while ((reads = chunk_is.read(byte_block)) != -1) {

if (reads < byte_block.length) {
for (int i = reads; i < byte_block.length; i++) {
byte_block[i] = 0;
}
}
}

int_block = bin2i32a(byte_block);
int_block = bin2i32a(byte_block);

for (int i = 0; i < chunk_mac.length; i++) {
chunk_mac[i] ^= int_block[i];
}

for (int i = 0; i < chunk_mac.length; i++) {
chunk_mac[i] ^= int_block[i];
chunk_mac = bin2i32a(cryptor.doFinal(i32a2bin(chunk_mac)));
}

chunk_mac = bin2i32a(cryptor.doFinal(i32a2bin(chunk_mac)));
}
for (int i = 0; i < file_mac.length; i++) {
file_mac[i] ^= chunk_mac[i];
}

file_mac = bin2i32a(cryptor.doFinal(i32a2bin(file_mac)));

for (int i = 0; i < file_mac.length; i++) {
file_mac[i] ^= chunk_mac[i];
} catch (IOException | IllegalBlockSizeException | BadPaddingException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}
} else {

do {
int[] chunk_mac = {file_iv[0], file_iv[1], file_iv[0], file_iv[1]};

byte[] byte_block = new byte[16];

long chunk_size = 0;

do {

if ((reads = chunk_is.read(byte_block)) != -1) {

if (reads < byte_block.length) {

for (int i = reads; i < byte_block.length; i++) {
byte_block[i] = 0;
}
}

int_block = bin2i32a(byte_block);

for (int i = 0; i < chunk_mac.length; i++) {
chunk_mac[i] ^= int_block[i];
}

chunk_mac = bin2i32a(cryptor.doFinal(i32a2bin(chunk_mac)));

chunk_size += byte_block.length;
}

} while (reads != -1 && chunk_size < 1024 * 1024);

if (chunk_size > 0) {

for (int i = 0; i < file_mac.length; i++) {
file_mac[i] ^= chunk_mac[i];
}

file_mac = bin2i32a(cryptor.doFinal(i32a2bin(file_mac)));
}

file_mac = bin2i32a(cryptor.doFinal(i32a2bin(file_mac)));
} while (reads != -1);

} catch (IOException | IllegalBlockSizeException | BadPaddingException ex) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
}

_bytes_read += chunk.getSize();
Expand Down

0 comments on commit 69c049a

Please sign in to comment.