mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-29 13:00:15 +02:00
2.26
-Cleaning...
This commit is contained in:
parent
82b84af50c
commit
1a0470c023
@ -93,7 +93,7 @@ run.classpath=\
|
|||||||
# Space-separated list of JVM arguments used when running the project.
|
# Space-separated list of JVM arguments used when running the project.
|
||||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
||||||
# To set system properties for unit tests define test-sys-prop.name=value:
|
# To set system properties for unit tests define test-sys-prop.name=value:
|
||||||
run.jvmargs=-splash:src/megabasterd/dot_com.png
|
run.jvmargs=-splash:src/megabasterd/dot_com.png -Djava.util.logging.ConsoleHandler.level=INFO
|
||||||
run.test.classpath=\
|
run.test.classpath=\
|
||||||
${javac.test.classpath}:\
|
${javac.test.classpath}:\
|
||||||
${build.test.classes.dir}
|
${build.test.classes.dir}
|
||||||
|
@ -2,9 +2,8 @@ package megabasterd;
|
|||||||
|
|
||||||
import java.awt.Dialog;
|
import java.awt.Dialog;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MainPanel.VERSION;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -176,7 +175,7 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void mcdown_url_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mcdown_url_buttonActionPerformed
|
private void mcdown_url_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mcdown_url_buttonActionPerformed
|
||||||
|
|
||||||
MiscTools.copyTextToClipboard(MEGA_URL);
|
copyTextToClipboard(MEGA_URL);
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(this, "MEGA URL was copied to clipboard!");
|
JOptionPane.showMessageDialog(this, "MEGA URL was copied to clipboard!");
|
||||||
}//GEN-LAST:event_mcdown_url_buttonActionPerformed
|
}//GEN-LAST:event_mcdown_url_buttonActionPerformed
|
||||||
@ -193,7 +192,7 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
String new_version = MiscTools.checkNewVersion("lYsRWaQB", "uVhntmyKcVECRaOxAbcL4A");
|
String new_version = checkNewVersion("lYsRWaQB", "uVhntmyKcVECRaOxAbcL4A");
|
||||||
|
|
||||||
if (new_version != null) {
|
if (new_version != null) {
|
||||||
|
|
||||||
@ -215,26 +214,26 @@ public final class AboutDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void pica_roja_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pica_roja_labelMouseReleased
|
private void pica_roja_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pica_roja_labelMouseReleased
|
||||||
|
|
||||||
MiscTools.openBrowserURL(TONIKELOPE_URL);
|
openBrowserURL(TONIKELOPE_URL);
|
||||||
}//GEN-LAST:event_pica_roja_labelMouseReleased
|
}//GEN-LAST:event_pica_roja_labelMouseReleased
|
||||||
|
|
||||||
private void author_webpage_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_author_webpage_labelMouseReleased
|
private void author_webpage_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_author_webpage_labelMouseReleased
|
||||||
|
|
||||||
MiscTools.openBrowserURL(TONIKELOPE_URL);
|
openBrowserURL(TONIKELOPE_URL);
|
||||||
}//GEN-LAST:event_author_webpage_labelMouseReleased
|
}//GEN-LAST:event_author_webpage_labelMouseReleased
|
||||||
|
|
||||||
private void mc_logo_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mc_logo_labelMouseReleased
|
private void mc_logo_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mc_logo_labelMouseReleased
|
||||||
|
|
||||||
MiscTools.openBrowserURL(MEGACRYPTER_URL);
|
openBrowserURL(MEGACRYPTER_URL);
|
||||||
}//GEN-LAST:event_mc_logo_labelMouseReleased
|
}//GEN-LAST:event_mc_logo_labelMouseReleased
|
||||||
|
|
||||||
private void made_in_spain_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_made_in_spain_labelMouseReleased
|
private void made_in_spain_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_made_in_spain_labelMouseReleased
|
||||||
|
|
||||||
MiscTools.openBrowserURL(SPAIN_URL);
|
openBrowserURL(SPAIN_URL);
|
||||||
}//GEN-LAST:event_made_in_spain_labelMouseReleased
|
}//GEN-LAST:event_made_in_spain_labelMouseReleased
|
||||||
|
|
||||||
private void title_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_title_labelMouseReleased
|
private void title_labelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_title_labelMouseReleased
|
||||||
MiscTools.openBrowserURL(MEGABASTERD_GITHUB_URL);
|
openBrowserURL(MEGABASTERD_GITHUB_URL);
|
||||||
}//GEN-LAST:event_title_labelMouseReleased
|
}//GEN-LAST:event_title_labelMouseReleased
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
@ -17,10 +17,6 @@ public final class Chunk {
|
|||||||
private final String _url;
|
private final String _url;
|
||||||
private final int _size_multi;
|
private final int _size_multi;
|
||||||
|
|
||||||
public int getSize_multi() {
|
|
||||||
return _size_multi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Chunk(long id, long file_size, String file_url) throws ChunkInvalidException {
|
public Chunk(long id, long file_size, String file_url) throws ChunkInvalidException {
|
||||||
_size_multi = 1;
|
_size_multi = 1;
|
||||||
|
|
||||||
@ -75,6 +71,10 @@ public final class Chunk {
|
|||||||
_data_os = new ByteArrayOutputStream((int) _size);
|
_data_os = new ByteArrayOutputStream((int) _size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSize_multi() {
|
||||||
|
return _size_multi;
|
||||||
|
}
|
||||||
|
|
||||||
public long getOffset() {
|
public long getOffset() {
|
||||||
return _offset;
|
return _offset;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,8 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MainPanel.THROTTLE_SLICE_SIZE;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
@ -80,7 +79,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
getLogger(ChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,9 +95,9 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
InputStream is;
|
InputStream is;
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
System.out.println("Worker [" + _id + "]: let's do some work!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: let''s do some work!", new Object[]{Thread.currentThread().getName(), _id});
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
@ -124,7 +123,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
http_status = httpresponse.getStatusLine().getStatusCode();
|
http_status = httpresponse.getStatusLine().getStatusCode();
|
||||||
|
|
||||||
if (http_status != HttpStatus.SC_OK) {
|
if (http_status != HttpStatus.SC_OK) {
|
||||||
System.out.println("Failed : HTTP error code : " + http_status);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), http_status});
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
@ -184,7 +183,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
} else if (!error) {
|
} else if (!error) {
|
||||||
|
|
||||||
System.out.println("Worker [" + _id + "] has downloaded chunk [" + chunk.getId() + "]!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}] has downloaded chunk [{2}]!", new Object[]{Thread.currentThread().getName(), _id, chunk.getId()});
|
||||||
|
|
||||||
_download.getChunkwriter().getChunk_queue().put(chunk.getId(), chunk);
|
_download.getChunkwriter().getChunk_queue().put(chunk.getId(), chunk);
|
||||||
|
|
||||||
@ -208,10 +207,10 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
_download.getProgress_meter().secureNotify();
|
_download.getProgress_meter().secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger(ChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(ChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,16 +219,16 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
_download.emergencyStopDownloader(ex.getMessage());
|
_download.emergencyStopDownloader(ex.getMessage());
|
||||||
getLogger(ChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
Logger.getLogger(ChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_download.stopThisSlot(this);
|
_download.stopThisSlot(this);
|
||||||
|
|
||||||
_download.getChunkwriter().secureNotify();
|
_download.getChunkwriter().secureNotify();
|
||||||
|
|
||||||
System.out.println("Worker [" + _id + "]: bye bye");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: bye bye", new Object[]{Thread.currentThread().getName(), _id});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,8 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MainPanel.THROTTLE_SLICE_SIZE;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
@ -33,9 +32,9 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
HttpGet httpget = null;
|
HttpGet httpget = null;
|
||||||
CloseableHttpResponse httpresponse = null;
|
CloseableHttpResponse httpresponse = null;
|
||||||
|
|
||||||
System.out.println("Worker [" + getId() + "]: let's do some work!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: let''s do some work!", new Object[]{Thread.currentThread().getName(), getId()});
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
@ -69,7 +68,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
if (http_status != HttpStatus.SC_OK) {
|
if (http_status != HttpStatus.SC_OK) {
|
||||||
|
|
||||||
System.out.println("Failed : HTTP error code : " + http_status);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), http_status});
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
@ -159,10 +158,10 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
getDownload().getProgress_meter().secureNotify();
|
getDownload().getProgress_meter().secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger(ChunkDownloaderMono.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(ChunkDownloaderMono.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,21 +170,19 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
||||||
getLogger(ChunkDownloaderMono.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
getDownload().emergencyStopDownloader(ex.getMessage());
|
getDownload().emergencyStopDownloader(ex.getMessage());
|
||||||
|
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException | InterruptedException ex) {
|
||||||
Logger.getLogger(ChunkDownloaderMono.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
Logger.getLogger(ChunkDownloaderMono.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDownload().stopThisSlot(this);
|
getDownload().stopThisSlot(this);
|
||||||
|
|
||||||
getDownload().getChunkwriter().secureNotify();
|
getDownload().getChunkwriter().secureNotify();
|
||||||
|
|
||||||
System.out.println("Worker [" + getId() + "]: bye bye");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: bye bye", new Object[]{Thread.currentThread().getName(), getId()});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,11 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import javax.crypto.CipherInputStream;
|
import javax.crypto.CipherInputStream;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
import static megabasterd.MiscTools.*;
|
||||||
|
import static megabasterd.CryptTools.*;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
@ -79,7 +79,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,13 +99,13 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
return _upload;
|
return _upload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setError_wait(boolean _error_wait) {
|
public void setError_wait(boolean error_wait) {
|
||||||
this._error_wait = _error_wait;
|
_error_wait = error_wait;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
System.out.println("ChunkUploader " + getId() + " hello! " + getUpload().getFile_name());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} ChunkUploader {1} hello! {2}", new Object[]{Thread.currentThread().getName(), getId(), getUpload().getFile_name()});
|
||||||
|
|
||||||
String worker_url = _upload.getUl_url();
|
String worker_url = _upload.getUl_url();
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
@ -113,7 +113,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
boolean error;
|
boolean error;
|
||||||
OutputStream out;
|
OutputStream out;
|
||||||
|
|
||||||
try (final CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient(); RandomAccessFile f = new RandomAccessFile(_upload.getFile_name(), "r");) {
|
try (final CloseableHttpClient httpclient = getApacheKissHttpClient(); RandomAccessFile f = new RandomAccessFile(_upload.getFile_name(), "r");) {
|
||||||
|
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
final FutureTask<CloseableHttpResponse> futureTask;
|
final FutureTask<CloseableHttpResponse> futureTask;
|
||||||
|
|
||||||
try (CipherInputStream cis = new CipherInputStream(chunk.getInputStream(), CryptTools.genCrypter("AES", "AES/CTR/NoPadding", _upload.getByte_file_key(), CryptTools.forwardMEGALinkKeyIV(_upload.getByte_file_iv(), chunk.getOffset())))) {
|
try (CipherInputStream cis = new CipherInputStream(chunk.getInputStream(), genCrypter("AES", "AES/CTR/NoPadding", _upload.getByte_file_key(), forwardMEGALinkKeyIV(_upload.getByte_file_iv(), chunk.getOffset())))) {
|
||||||
|
|
||||||
final PipedInputStream pipein = new PipedInputStream();
|
final PipedInputStream pipein = new PipedInputStream();
|
||||||
final PipedOutputStream pipeout = new PipedOutputStream(pipein);
|
final PipedOutputStream pipeout = new PipedOutputStream(pipein);
|
||||||
@ -161,10 +161,12 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
return httpclient.execute(httppost);
|
return httpclient.execute(httppost);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
THREAD_POOL.execute(futureTask);
|
THREAD_POOL.execute(futureTask);
|
||||||
out = new ThrottledOutputStream(pipeout, _upload.getMain_panel().getStream_supervisor());
|
out = new ThrottledOutputStream(pipeout, _upload.getMain_panel().getStream_supervisor());
|
||||||
System.out.println(" Subiendo chunk " + chunk.getId() + " desde worker " + _id + "...");
|
|
||||||
System.out.println(chunk.getUrl());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Uploading chunk {1} from worker {2}...", new Object[]{Thread.currentThread().getName(), chunk.getId(), _id});
|
||||||
|
|
||||||
while (!_exit && !_upload.isStopped() && (reads = cis.read(buffer)) != -1) {
|
while (!_exit && !_upload.isStopped() && (reads = cis.read(buffer)) != -1) {
|
||||||
out.write(buffer, 0, reads);
|
out.write(buffer, 0, reads);
|
||||||
|
|
||||||
@ -200,7 +202,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (httpresponse != null && (http_status = httpresponse.getStatusLine().getStatusCode()) != HttpStatus.SC_OK) {
|
if (httpresponse != null && (http_status = httpresponse.getStatusLine().getStatusCode()) != HttpStatus.SC_OK) {
|
||||||
System.out.println("Failed : HTTP error code : " + http_status);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), http_status});
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
@ -235,13 +237,13 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
if (MegaAPI.checkMEGAError(response) != 0) {
|
if (MegaAPI.checkMEGAError(response) != 0) {
|
||||||
|
|
||||||
System.out.println("UPLOAD FAILED! (MEGA ERROR: " + MegaAPI.checkMEGAError(response) + ")");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} UPLOAD FAILED! (MEGA ERROR: {1})", new Object[]{Thread.currentThread().getName(), MegaAPI.checkMEGAError(response)});
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
System.out.println("Completion handle -> " + response);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Completion handle -> {1}", new Object[]{Thread.currentThread().getName(), response});
|
||||||
|
|
||||||
_upload.setCompletion_handle(response);
|
_upload.setCompletion_handle(response);
|
||||||
}
|
}
|
||||||
@ -272,7 +274,7 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
} else if (!error) {
|
} else if (!error) {
|
||||||
|
|
||||||
System.out.println(" Worker " + _id + " ha subido chunk " + chunk.getId());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker {1} has uploaded chunk {2}", new Object[]{Thread.currentThread().getName(), _id, chunk.getId()});
|
||||||
|
|
||||||
_upload.getMac_generator().getChunk_queue().put(chunk.getId(), chunk);
|
_upload.getMac_generator().getChunk_queue().put(chunk.getId(), chunk);
|
||||||
|
|
||||||
@ -316,10 +318,10 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
_upload.getProgress_meter().secureNotify();
|
_upload.getProgress_meter().secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) {
|
||||||
getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
@ -337,16 +339,16 @@ public class ChunkUploader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
_upload.emergencyStopUploader(ex.getMessage());
|
_upload.emergencyStopUploader(ex.getMessage());
|
||||||
|
|
||||||
getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
Logger.getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_upload.stopThisSlot(this);
|
_upload.stopThisSlot(this);
|
||||||
|
|
||||||
_upload.getMac_generator().secureNotify();
|
_upload.getMac_generator().secureNotify();
|
||||||
|
|
||||||
System.out.println("ChunkUploader " + _id + " bye bye...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} ChunkUploader {1} bye bye...", new Object[]{Thread.currentThread().getName(), _id});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,11 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import javax.crypto.CipherInputStream;
|
import javax.crypto.CipherInputStream;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
import static megabasterd.MiscTools.*;
|
||||||
|
import static megabasterd.CryptTools.*;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
@ -46,14 +46,14 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
System.out.println("ChunkUploaderMONO " + getId() + " hello! " + getUpload().getFile_name());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} ChunkUploaderMONO {1} hello! {2}", new Object[]{Thread.currentThread().getName(), getId(), getUpload().getFile_name()});
|
||||||
|
|
||||||
String worker_url = getUpload().getUl_url();
|
String worker_url = getUpload().getUl_url();
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
int reads, conta_error, re, http_status, tot_bytes_up = -1;
|
int reads, conta_error, re, http_status, tot_bytes_up = -1;
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient(); RandomAccessFile f = new RandomAccessFile(getUpload().getFile_name(), "r");) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient(); RandomAccessFile f = new RandomAccessFile(getUpload().getFile_name(), "r");) {
|
||||||
|
|
||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
@ -113,9 +113,9 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
if (!isExit() && !getUpload().isStopped()) {
|
if (!isExit() && !getUpload().isStopped()) {
|
||||||
|
|
||||||
try (CipherInputStream cis = new CipherInputStream(chunk.getInputStream(), CryptTools.genCrypter("AES", "AES/CTR/NoPadding", getUpload().getByte_file_key(), CryptTools.forwardMEGALinkKeyIV(getUpload().getByte_file_iv(), chunk.getOffset())))) {
|
try (CipherInputStream cis = new CipherInputStream(chunk.getInputStream(), genCrypter("AES", "AES/CTR/NoPadding", getUpload().getByte_file_key(), forwardMEGALinkKeyIV(getUpload().getByte_file_iv(), chunk.getOffset())))) {
|
||||||
|
|
||||||
System.out.println(" Subiendo chunk " + chunk.getId() + " desde worker " + getId() + "...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Uploading chunk {1} from worker {2}...", new Object[]{Thread.currentThread().getName(), chunk.getId(), getId()});
|
||||||
|
|
||||||
while (!isExit() && !getUpload().isStopped() && (reads = cis.read(buffer)) != -1 && out != null) {
|
while (!isExit() && !getUpload().isStopped() && (reads = cis.read(buffer)) != -1 && out != null) {
|
||||||
out.write(buffer, 0, reads);
|
out.write(buffer, 0, reads);
|
||||||
@ -165,9 +165,9 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
} else if (!error) {
|
} else if (!error) {
|
||||||
|
|
||||||
System.out.println(" Worker " + getId() + " ha subido chunk " + chunk.getId());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker {1} has uploaded chunk {2}", new Object[]{Thread.currentThread().getName(), getId(), chunk.getId()});
|
||||||
|
|
||||||
System.out.println(chunk.getOffset() + " " + tot_bytes_up + " " + getUpload().getFile_size());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} {1} {2}", new Object[]{chunk.getOffset(), tot_bytes_up, getUpload().getFile_size()});
|
||||||
|
|
||||||
if (chunk.getOffset() + tot_bytes_up < getUpload().getFile_size()) {
|
if (chunk.getOffset() + tot_bytes_up < getUpload().getFile_size()) {
|
||||||
|
|
||||||
@ -198,10 +198,10 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
getUpload().getProgress_meter().secureNotify();
|
getUpload().getProgress_meter().secureNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | InterruptedException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | InterruptedException ex) {
|
||||||
getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
System.out.println("Completion handle -> " + response);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Completion handle -> {1}", new Object[]{Thread.currentThread().getName(), response});
|
||||||
|
|
||||||
getUpload().setCompletion_handle(response);
|
getUpload().setCompletion_handle(response);
|
||||||
|
|
||||||
@ -294,17 +294,17 @@ public class ChunkUploaderMono extends ChunkUploader {
|
|||||||
|
|
||||||
getUpload().emergencyStopUploader(ex.getMessage());
|
getUpload().emergencyStopUploader(ex.getMessage());
|
||||||
|
|
||||||
getLogger(ChunkUploader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
} catch (URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
Logger.getLogger(ChunkUploaderMono.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUpload().stopThisSlot(this);
|
getUpload().stopThisSlot(this);
|
||||||
|
|
||||||
getUpload().getMac_generator().secureNotify();
|
getUpload().getMac_generator().secureNotify();
|
||||||
|
|
||||||
System.out.println("ChunkUploaderMONO " + getId() + " bye bye...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} ChunkUploaderMONO {1} bye bye...", new Object[]{Thread.currentThread().getName(), getId()});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
package megabasterd;
|
package megabasterd;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import javax.crypto.CipherInputStream;
|
import javax.crypto.CipherInputStream;
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
import static megabasterd.CryptTools.*;
|
||||||
|
|
||||||
public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable {
|
public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable {
|
||||||
|
|
||||||
@ -26,8 +32,8 @@ public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable
|
|||||||
_download = downloader;
|
_download = downloader;
|
||||||
_secure_notify_lock = new Object();
|
_secure_notify_lock = new Object();
|
||||||
_file_size = _download.getFile_size();
|
_file_size = _download.getFile_size();
|
||||||
_byte_file_key = CryptTools.initMEGALinkKey(_download.getFile_key());
|
_byte_file_key = initMEGALinkKey(_download.getFile_key());
|
||||||
_byte_iv = CryptTools.initMEGALinkKeyIV(_download.getFile_key());
|
_byte_iv = initMEGALinkKeyIV(_download.getFile_key());
|
||||||
_chunk_queue = new ConcurrentHashMap();
|
_chunk_queue = new ConcurrentHashMap();
|
||||||
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
|
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
@ -66,7 +72,7 @@ public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable
|
|||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
getLogger(ChunkWriter.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,17 +112,19 @@ public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
System.out.println("Filewriter: let's do some work!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Filewriter: let''s do some work!", Thread.currentThread().getName());
|
||||||
|
|
||||||
if (_file_size > 0) {
|
if (_file_size > 0) {
|
||||||
while (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
while (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
||||||
while (_chunk_queue.containsKey(_last_chunk_id_written + 1)) {
|
while (_chunk_queue.containsKey(_last_chunk_id_written + 1)) {
|
||||||
current_chunk = _chunk_queue.get(_last_chunk_id_written + 1);
|
current_chunk = _chunk_queue.get(_last_chunk_id_written + 1);
|
||||||
|
|
||||||
try (CipherInputStream cis = new CipherInputStream(current_chunk.getInputStream(), CryptTools.genDecrypter("AES", "AES/CTR/NoPadding", _byte_file_key, CryptTools.forwardMEGALinkKeyIV(_byte_iv, _bytes_written)))) {
|
try (CipherInputStream cis = new CipherInputStream(current_chunk.getInputStream(), genDecrypter("AES", "AES/CTR/NoPadding", _byte_file_key, forwardMEGALinkKeyIV(_byte_iv, _bytes_written)))) {
|
||||||
while ((reads = cis.read(buffer)) != -1) {
|
while ((reads = cis.read(buffer)) != -1) {
|
||||||
_download.getOutput_stream().write(buffer, 0, reads);
|
_download.getOutput_stream().write(buffer, 0, reads);
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException ex) {
|
||||||
|
Logger.getLogger(ChunkWriter.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_bytes_written += current_chunk.getSize();
|
_bytes_written += current_chunk.getSize();
|
||||||
@ -129,17 +137,16 @@ public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable
|
|||||||
|
|
||||||
if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
if (!_exit && (!_download.isStopped() || !_download.getChunkworkers().isEmpty()) && _bytes_written < _file_size) {
|
||||||
|
|
||||||
System.out.println("Filewriter waiting for chunk [" + (_last_chunk_id_written + 1) + "]...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Filewriter waiting for chunk [{1}{2}]...", new Object[]{Thread.currentThread().getName(), _last_chunk_id_written, 1});
|
||||||
|
|
||||||
secureWait();
|
secureWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (IOException ex) {
|
||||||
|
|
||||||
System.out.println(ex.getMessage());
|
|
||||||
|
|
||||||
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
_download.emergencyStopDownloader(ex.getMessage());
|
_download.emergencyStopDownloader(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +154,7 @@ public final class ChunkWriter implements Runnable, SecureSingleThreadNotifiable
|
|||||||
|
|
||||||
_download.secureNotify();
|
_download.secureNotify();
|
||||||
|
|
||||||
System.out.println("Filewriter: bye bye" + _download.getFile().getName());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Filewriter: bye bye{1}", new Object[]{Thread.currentThread().getName(), _download.getFile().getName()});
|
||||||
}
|
}
|
||||||
|
|
||||||
private long calculateLastWrittenChunk(long temp_file_size) {
|
private long calculateLastWrittenChunk(long temp_file_size) {
|
||||||
|
@ -6,8 +6,9 @@ import java.awt.datatransfer.ClipboardOwner;
|
|||||||
import java.awt.datatransfer.Transferable;
|
import java.awt.datatransfer.Transferable;
|
||||||
import static java.lang.Thread.sleep;
|
import static java.lang.Thread.sleep;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureSingleThreadNotifiable, ClipboardChangeObservable {
|
public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureSingleThreadNotifiable, ClipboardChangeObservable {
|
||||||
|
|
||||||
@ -51,10 +52,10 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureSingl
|
|||||||
|
|
||||||
gainOwnership(_contents);
|
gainOwnership(_contents);
|
||||||
|
|
||||||
System.out.println("Spying clipboard ON...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Monitoring clipboard ON...", Thread.currentThread().getName());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Spying clipboard OFF...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Monitoring clipboard OFF...", Thread.currentThread().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureSingl
|
|||||||
try {
|
try {
|
||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(ClipboardSpy.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureSingl
|
|||||||
try {
|
try {
|
||||||
sleep(SLEEP);
|
sleep(SLEEP);
|
||||||
} catch (InterruptedException ex1) {
|
} catch (InterruptedException ex1) {
|
||||||
getLogger(ClipboardSpy.class.getName()).log(SEVERE, null, ex1);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ public final class ClipboardSpy implements Runnable, ClipboardOwner, SecureSingl
|
|||||||
try {
|
try {
|
||||||
sleep(SLEEP);
|
sleep(SLEEP);
|
||||||
} catch (InterruptedException ex1) {
|
} catch (InterruptedException ex1) {
|
||||||
getLogger(ClipboardSpy.class.getName()).log(SEVERE, null, ex1);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public final class ContextMenuMouseListener extends MouseAdapter {
|
|||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
|
if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
|
||||||
if (!(e.getSource() instanceof JTextComponent)) {
|
if (!(e.getSource() instanceof JTextComponent)) {
|
||||||
System.out.println(e.getSource().getClass());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,17 +30,7 @@ import javax.crypto.spec.IvParameterSpec;
|
|||||||
import javax.crypto.spec.PBEKeySpec;
|
import javax.crypto.spec.PBEKeySpec;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static megabasterd.MiscTools.BASE642Bin;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.Bin2UrlBASE64;
|
|
||||||
import static megabasterd.MiscTools.UrlBASE642Bin;
|
|
||||||
import static megabasterd.MiscTools.bin2i32a;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import static megabasterd.MiscTools.getApacheKissHttpClient;
|
|
||||||
import static megabasterd.MiscTools.hex2bin;
|
|
||||||
import static megabasterd.MiscTools.i32a2bin;
|
|
||||||
import static megabasterd.MiscTools.long2bytearray;
|
|
||||||
import static megabasterd.MiscTools.recReverseArray;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
@ -480,7 +470,7 @@ public final class CryptTools {
|
|||||||
|
|
||||||
dec_pass = (String) res_map.get("d");
|
dec_pass = (String) res_map.get("d");
|
||||||
|
|
||||||
byte[] pass_dec_byte = MiscTools.BASE642Bin(dec_pass);
|
byte[] pass_dec_byte = BASE642Bin(dec_pass);
|
||||||
|
|
||||||
byte[] key = Arrays.copyOfRange(pass_dec_byte, 0, 16);
|
byte[] key = Arrays.copyOfRange(pass_dec_byte, 0, 16);
|
||||||
|
|
||||||
@ -508,7 +498,7 @@ public final class CryptTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(CryptTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
JOptionPane.showMessageDialog(main_panel.getView(), ex.getMessage(), "ELC ERROR", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(main_panel.getView(), ex.getMessage(), "ELC ERROR", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -575,20 +565,20 @@ public final class CryptTools {
|
|||||||
|
|
||||||
out.write(buffer, 0, reads);
|
out.write(buffer, 0, reads);
|
||||||
}
|
}
|
||||||
enc_dlc_key = MiscTools.findFirstRegex("< *rc *>(.+)< */ *rc *>", new String(out.toByteArray()), 1);
|
enc_dlc_key = findFirstRegex("< *rc *>(.+)< */ *rc *>", new String(out.toByteArray()), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String dec_dlc_key = new String(CryptTools.aes_ecb_decrypt(MiscTools.BASE642Bin(enc_dlc_key), MiscTools.hex2bin(dlc_master_key))).trim();
|
String dec_dlc_key = new String(CryptTools.aes_ecb_decrypt(BASE642Bin(enc_dlc_key), hex2bin(dlc_master_key))).trim();
|
||||||
|
|
||||||
String dec_dlc_data = new String(CryptTools.aes_cbc_decrypt(MiscTools.BASE642Bin(enc_dlc_data), MiscTools.BASE642Bin(dec_dlc_key), MiscTools.BASE642Bin(dec_dlc_key))).trim();
|
String dec_dlc_data = new String(CryptTools.aes_cbc_decrypt(BASE642Bin(enc_dlc_data), BASE642Bin(dec_dlc_key), BASE642Bin(dec_dlc_key))).trim();
|
||||||
|
|
||||||
String dec_dlc_data_file = MiscTools.findFirstRegex("< *file *>(.+)< */ *file *>", new String(MiscTools.BASE642Bin(dec_dlc_data)), 1);
|
String dec_dlc_data_file = findFirstRegex("< *file *>(.+)< */ *file *>", new String(BASE642Bin(dec_dlc_data)), 1);
|
||||||
|
|
||||||
ArrayList<String> urls = MiscTools.findAllRegex("< *url *>(.+)< */ *url *>", dec_dlc_data_file, 1);
|
ArrayList<String> urls = findAllRegex("< *url *>(.+)< */ *url *>", dec_dlc_data_file, 1);
|
||||||
|
|
||||||
for (String s : urls) {
|
for (String s : urls) {
|
||||||
|
|
||||||
links.add(new String(MiscTools.BASE642Bin(s)));
|
links.add(new String(BASE642Bin(s)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -8,7 +8,7 @@ import java.sql.Statement;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -150,7 +150,7 @@ public final class DBTools {
|
|||||||
value = res.getString(1);
|
value = res.getString(1);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(DBTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(DBTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
@ -26,28 +26,16 @@ import static java.util.concurrent.Executors.newCachedThreadPool;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import static megabasterd.CryptTools.genCrypter;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.DBTools.deleteDownload;
|
import static megabasterd.CryptTools.*;
|
||||||
import static megabasterd.DBTools.insertDownload;
|
import static megabasterd.DBTools.*;
|
||||||
import static megabasterd.DBTools.selectSettingValueFromDB;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.Transference.*;
|
||||||
import static megabasterd.MiscTools.UrlBASE642Bin;
|
|
||||||
import static megabasterd.MiscTools.bin2i32a;
|
|
||||||
import static megabasterd.MiscTools.checkMegaDownloadUrl;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import static megabasterd.MiscTools.formatBytes;
|
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
|
||||||
import static megabasterd.MiscTools.i32a2bin;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
import static megabasterd.MiscTools.truncateText;
|
|
||||||
import static megabasterd.Transference.MAX_WAIT_WORKERS_SHUTDOWN;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -514,7 +502,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
_thread_pool.shutdown();
|
_thread_pool.shutdown();
|
||||||
|
|
||||||
System.out.println("Chunkdownloaders finished!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Chunkdownloaders finished!", Thread.currentThread().getName());
|
||||||
|
|
||||||
getProgress_meter().setExit(true);
|
getProgress_meter().setExit(true);
|
||||||
|
|
||||||
@ -522,22 +510,22 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
System.out.println("Esperando a que todos los hilos terminen...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Waiting all threads to finish...", Thread.currentThread().getName());
|
||||||
|
|
||||||
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
|
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_thread_pool.isTerminated()) {
|
if (!_thread_pool.isTerminated()) {
|
||||||
|
|
||||||
System.out.println("Cerrando thread pool a lo mecagüen...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Closing thread pool ''mecag\u00fcen'' style...", Thread.currentThread().getName());
|
||||||
|
|
||||||
_thread_pool.shutdownNow();
|
_thread_pool.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Downloader thread pool finished!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Downloader thread pool finished!", Thread.currentThread().getName());
|
||||||
|
|
||||||
getMain_panel().getGlobal_dl_speed().detachTransference(this);
|
getMain_panel().getGlobal_dl_speed().detachTransference(this);
|
||||||
|
|
||||||
@ -697,10 +685,10 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
_status_error = true;
|
_status_error = true;
|
||||||
|
|
||||||
System.out.println(ex.getMessage());
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println(ex.getMessage());
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_exit) {
|
if (!_exit) {
|
||||||
@ -710,7 +698,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
try {
|
try {
|
||||||
deleteDownload(_url);
|
deleteDownload(_url);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(Download.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -732,7 +720,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
swingReflectionInvoke("setVisible", getView().getRestart_button(), true);
|
swingReflectionInvoke("setVisible", getView().getRestart_button(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(_file_name + " Downloader: bye bye");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0}{1} Downloader: bye bye", new Object[]{Thread.currentThread().getName(), _file_name});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void provisionIt(boolean retry) throws MegaAPIException, MegaCrypterAPIException {
|
public void provisionIt(boolean retry) throws MegaAPIException, MegaCrypterAPIException {
|
||||||
@ -776,7 +764,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
|
||||||
getLogger(Download.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
|
|
||||||
exit_message = "Error registering download (file " + _download_path + "/" + _file_name + " already downloading or megabasterd.db file is corrupted :()";
|
exit_message = "Error registering download (file " + _download_path + "/" + _file_name + " already downloading or megabasterd.db file is corrupted :()";
|
||||||
}
|
}
|
||||||
@ -804,7 +792,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
throw ex;
|
throw ex;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (NumberFormatException ex) {
|
||||||
|
|
||||||
exit_message = ex.getMessage();
|
exit_message = ex.getMessage();
|
||||||
}
|
}
|
||||||
@ -891,7 +879,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
download_url = _ma.getMegaFileDownloadUrl(_url);
|
download_url = _ma.getMegaFileDownloadUrl(_url);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
download_url = MegaCrypterAPI.getMegaFileDownloadUrl(_url, _file_pass, _file_noexpire, _ma.getSid(), this.getMain_panel().getMega_proxy_server() != null ? (this.getMain_panel().getMega_proxy_server().getPort() + ":" + MiscTools.Bin2BASE64(("megacrypter:" + this.getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
download_url = MegaCrypterAPI.getMegaFileDownloadUrl(_url, _file_pass, _file_noexpire, _ma.getSid(), getMain_panel().getMega_proxy_server() != null ? (getMain_panel().getMega_proxy_server().getPort() + ":" + Bin2BASE64(("megacrypter:" + getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkMegaDownloadUrl(download_url)) {
|
if (checkMegaDownloadUrl(download_url)) {
|
||||||
@ -939,7 +927,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
_thread_pool.execute(c);
|
_thread_pool.execute(c);
|
||||||
|
|
||||||
} catch (java.util.concurrent.RejectedExecutionException e) {
|
} catch (java.util.concurrent.RejectedExecutionException e) {
|
||||||
System.out.println(e.getMessage());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1111,7 +1099,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
try {
|
try {
|
||||||
deleteDownload(_url);
|
deleteDownload(_url);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(Download.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMain_panel().getDownload_manager().getTransference_running_list().remove(this);
|
getMain_panel().getDownload_manager().getTransference_running_list().remove(this);
|
||||||
@ -1129,11 +1117,11 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
if (isRetrying_request()) {
|
if (isRetrying_request()) {
|
||||||
|
|
||||||
getView().stop("Retrying cancelled! " + MiscTools.truncateText(_url, 80));
|
getView().stop("Retrying cancelled! " + truncateText(_url, 80));
|
||||||
|
|
||||||
} else if (isChecking_cbc()) {
|
} else if (isChecking_cbc()) {
|
||||||
|
|
||||||
getView().stop("Verification cancelled! " + MiscTools.truncateText(_file_name, 80));
|
getView().stop("Verification cancelled! " + truncateText(_file_name, 80));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -1194,7 +1182,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
file_info = _ma.getMegaFileMetadata(link);
|
file_info = _ma.getMegaFileMetadata(link);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel, this.getMain_panel().getMega_proxy_server() != null ? (this.getMain_panel().getMega_proxy_server().getPort() + ":" + MiscTools.Bin2BASE64(("megacrypter:" + this.getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel, getMain_panel().getMega_proxy_server() != null ? (getMain_panel().getMega_proxy_server().getPort() + ":" + Bin2BASE64(("megacrypter:" + getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
||||||
@ -1207,31 +1195,31 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
switch (error_code) {
|
switch (error_code) {
|
||||||
|
|
||||||
case -2:
|
case -2:
|
||||||
emergencyStopDownloader("Mega link is not valid! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("Mega link is not valid! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -14:
|
case -14:
|
||||||
emergencyStopDownloader("Mega link is not valid! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("Mega link is not valid! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 22:
|
case 22:
|
||||||
emergencyStopDownloader("MegaCrypter link is not valid! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link is not valid! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 23:
|
case 23:
|
||||||
emergencyStopDownloader("MegaCrypter link is blocked! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link is blocked! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
emergencyStopDownloader("MegaCrypter link has expired! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link has expired! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 25:
|
case 25:
|
||||||
emergencyStopDownloader("MegaCrypter link pass error! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link pass error! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
emergencyStopDownloader("MEGA/MC API FATAL ERROR: " + ex.getMessage() + " " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MEGA/MC API FATAL ERROR: " + ex.getMessage() + " " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1267,7 +1255,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
if (!(ex instanceof MegaAPIException || ex instanceof MegaCrypterAPIException)) {
|
if (!(ex instanceof MegaAPIException || ex instanceof MegaCrypterAPIException)) {
|
||||||
emergencyStopDownloader("Mega link is not valid! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("Mega link is not valid! " + truncateText(link, 80));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1297,7 +1285,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
dl_url = _ma.getMegaFileDownloadUrl(link);
|
dl_url = _ma.getMegaFileDownloadUrl(link);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, _file_pass, _file_noexpire, _ma.getSid(), this.getMain_panel().getMega_proxy_server() != null ? (this.getMain_panel().getMega_proxy_server().getPort() + ":" + MiscTools.Bin2BASE64(("megacrypter:" + this.getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, _file_pass, _file_noexpire, _ma.getSid(), getMain_panel().getMega_proxy_server() != null ? (getMain_panel().getMega_proxy_server().getPort() + ":" + Bin2BASE64(("megacrypter:" + getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
||||||
@ -1307,19 +1295,19 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
switch (error_code) {
|
switch (error_code) {
|
||||||
case 22:
|
case 22:
|
||||||
emergencyStopDownloader("MegaCrypter link is not valid! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link is not valid! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 23:
|
case 23:
|
||||||
emergencyStopDownloader("MegaCrypter link is blocked! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link is blocked! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
emergencyStopDownloader("MegaCrypter link has expired! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link has expired! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 25:
|
case 25:
|
||||||
emergencyStopDownloader("MegaCrypter link pass error! " + MiscTools.truncateText(link, 80));
|
emergencyStopDownloader("MegaCrypter link pass error! " + truncateText(link, 80));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1394,7 +1382,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
getLogger(Download.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,11 @@ package megabasterd;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import static megabasterd.DBTools.deleteDownloads;
|
import static megabasterd.DBTools.*;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
|
|
||||||
public final class DownloadManager extends TransferenceManager {
|
public final class DownloadManager extends TransferenceManager {
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public final class DownloadManager extends TransferenceManager {
|
|||||||
try {
|
try {
|
||||||
deleteDownloads(delete_down.toArray(new String[delete_down.size()]));
|
deleteDownloads(delete_down.toArray(new String[delete_down.size()]));
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(DownloadManager.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
@ -59,7 +60,7 @@ public final class DownloadManager extends TransferenceManager {
|
|||||||
|
|
||||||
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
} catch (MegaAPIException | MegaCrypterAPIException ex) {
|
||||||
|
|
||||||
System.out.println("Provision failed! Retrying in separated thread...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Provision failed! Retrying in separated thread...", Thread.currentThread().getName());
|
||||||
|
|
||||||
THREAD_POOL.execute(new Runnable() {
|
THREAD_POOL.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +72,7 @@ public final class DownloadManager extends TransferenceManager {
|
|||||||
|
|
||||||
} catch (MegaAPIException | MegaCrypterAPIException ex1) {
|
} catch (MegaAPIException | MegaCrypterAPIException ex1) {
|
||||||
|
|
||||||
getLogger(DownloadManager.class.getName()).log(SEVERE, null, ex1);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex1);
|
||||||
}
|
}
|
||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
@ -11,9 +11,8 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
|
|
||||||
public final class DownloadView extends javax.swing.JPanel implements TransferenceView {
|
public final class DownloadView extends javax.swing.JPanel implements TransferenceView {
|
||||||
|
|
||||||
@ -230,7 +229,7 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
});
|
});
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@ -327,7 +326,7 @@ public final class DownloadView extends javax.swing.JPanel implements Transferen
|
|||||||
|
|
||||||
private void copy_link_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copy_link_buttonActionPerformed
|
private void copy_link_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copy_link_buttonActionPerformed
|
||||||
|
|
||||||
MiscTools.copyTextToClipboard(_download.getUrl());
|
copyTextToClipboard(_download.getUrl());
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(_download.getMain_panel().getView(), "Link was copied to clipboard!");
|
JOptionPane.showMessageDialog(_download.getMain_panel().getView(), "Link was copied to clipboard!");
|
||||||
}//GEN-LAST:event_copy_link_buttonActionPerformed
|
}//GEN-LAST:event_copy_link_buttonActionPerformed
|
||||||
|
@ -5,8 +5,6 @@ import java.awt.Dialog;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
@ -14,15 +12,8 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
|||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.TreeModel;
|
import javax.swing.tree.TreeModel;
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.deleteAllExceptSelectedTreeItems;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.deleteSelectedTreeItems;
|
|
||||||
import static megabasterd.MiscTools.formatBytes;
|
|
||||||
import static megabasterd.MiscTools.genID;
|
|
||||||
import static megabasterd.MiscTools.sortTree;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -36,7 +27,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
private long _total_space;
|
private long _total_space;
|
||||||
private volatile String _last_selected_account;
|
private volatile String _last_selected_account;
|
||||||
private final MainPanel _main_panel;
|
private final MainPanel _main_panel;
|
||||||
private boolean _remember_master_pass;
|
private final boolean _remember_master_pass;
|
||||||
|
|
||||||
public boolean isUpload() {
|
public boolean isUpload() {
|
||||||
return _upload;
|
return _upload;
|
||||||
@ -351,8 +342,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
_base_path = files_selected[0].getParentFile().getAbsolutePath();
|
_base_path = files_selected[0].getParentFile().getAbsolutePath();
|
||||||
|
|
||||||
System.out.println(_base_path);
|
|
||||||
|
|
||||||
dir_name_textfield.setText(files_selected[0].getParentFile().getName() + "_" + genID(10));
|
dir_name_textfield.setText(files_selected[0].getParentFile().getName() + "_" + genID(10));
|
||||||
|
|
||||||
dir_name_textfield.setEnabled(true);
|
dir_name_textfield.setEnabled(true);
|
||||||
@ -436,8 +425,6 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
_base_path = filechooser.getSelectedFile().getAbsolutePath();
|
_base_path = filechooser.getSelectedFile().getAbsolutePath();
|
||||||
|
|
||||||
System.out.println(_base_path);
|
|
||||||
|
|
||||||
dir_name_textfield.setText(filechooser.getSelectedFile().getName() + "_" + genID(10));
|
dir_name_textfield.setText(filechooser.getSelectedFile().getName() + "_" + genID(10));
|
||||||
|
|
||||||
dir_name_textfield.setEnabled(true);
|
dir_name_textfield.setEnabled(true);
|
||||||
@ -496,7 +483,7 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
_upload = true;
|
_upload = true;
|
||||||
|
|
||||||
this.setVisible(false);
|
setVisible(false);
|
||||||
}//GEN-LAST:event_dance_buttonActionPerformed
|
}//GEN-LAST:event_dance_buttonActionPerformed
|
||||||
|
|
||||||
private void account_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_account_comboboxItemStateChanged
|
private void account_comboboxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_account_comboboxItemStateChanged
|
||||||
@ -533,9 +520,9 @@ public final class FileGrabberDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
MegaAPI ma = null;
|
MegaAPI ma = null;
|
||||||
try {
|
try {
|
||||||
ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
ma = checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(FileGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Long[] quota = null;
|
Long[] quota = null;
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
package megabasterd;
|
package megabasterd;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.TreeModel;
|
import javax.swing.tree.TreeModel;
|
||||||
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreeNode;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.deleteAllExceptSelectedTreeItems;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.deleteSelectedTreeItems;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import static megabasterd.MiscTools.formatBytes;
|
|
||||||
import static megabasterd.MiscTools.sortTree;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -26,7 +20,7 @@ import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|||||||
*/
|
*/
|
||||||
public final class FolderLinkDialog extends javax.swing.JDialog {
|
public final class FolderLinkDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
private String _link;
|
private final String _link;
|
||||||
|
|
||||||
private boolean _download;
|
private boolean _download;
|
||||||
|
|
||||||
@ -37,7 +31,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
private boolean _mega_error;
|
private boolean _mega_error;
|
||||||
|
|
||||||
public List<HashMap> getDownload_links() {
|
public List<HashMap> getDownload_links() {
|
||||||
return _download_links;
|
return Collections.unmodifiableList(_download_links);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDownload() {
|
public boolean isDownload() {
|
||||||
@ -247,7 +241,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
_download = true;
|
_download = true;
|
||||||
|
|
||||||
this.setVisible(false);
|
setVisible(false);
|
||||||
}//GEN-LAST:event_dance_buttonActionPerformed
|
}//GEN-LAST:event_dance_buttonActionPerformed
|
||||||
|
|
||||||
private void skip_rest_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_rest_buttonActionPerformed
|
private void skip_rest_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skip_rest_buttonActionPerformed
|
||||||
@ -376,7 +370,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
getLogger(FolderLinkDialog.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
|
|
||||||
_mega_error = true;
|
_mega_error = true;
|
||||||
}
|
}
|
||||||
@ -418,7 +412,7 @@ public final class FolderLinkDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
download_link.put("url", url);
|
download_link.put("url", url);
|
||||||
|
|
||||||
download_link.put("filename", MiscTools.cleanFilePath(path));
|
download_link.put("filename", cleanFilePath(path));
|
||||||
|
|
||||||
download_link.put("filekey", ((Map<String, Object>) node.getUserObject()).get("key"));
|
download_link.put("filekey", ((Map<String, Object>) node.getUserObject()).get("key"));
|
||||||
|
|
||||||
|
@ -8,10 +8,8 @@ import java.util.logging.Logger;
|
|||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPasswordField;
|
import javax.swing.JPasswordField;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.Bin2BASE64;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.HashBin;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -182,7 +180,7 @@ public class GetMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_buttonActionPerformed
|
private void cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_buttonActionPerformed
|
||||||
|
|
||||||
this.setVisible(false);
|
setVisible(false);
|
||||||
}//GEN-LAST:event_cancel_buttonActionPerformed
|
}//GEN-LAST:event_cancel_buttonActionPerformed
|
||||||
|
|
||||||
private void ok_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok_buttonActionPerformed
|
private void ok_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok_buttonActionPerformed
|
||||||
@ -196,7 +194,7 @@ public class GetMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
byte[] pass = CryptTools.PBKDF2HMACSHA256(new String(current_pass_textfield.getPassword()), MiscTools.BASE642Bin(_salt), CryptTools.PBKDF2_ITERATIONS);
|
byte[] pass = CryptTools.PBKDF2HMACSHA256(new String(current_pass_textfield.getPassword()), BASE642Bin(_salt), CryptTools.PBKDF2_ITERATIONS);
|
||||||
|
|
||||||
String pass_hash = Bin2BASE64(HashBin("SHA-1", pass));
|
String pass_hash = Bin2BASE64(HashBin("SHA-1", pass));
|
||||||
|
|
||||||
@ -222,7 +220,7 @@ public class GetMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(GetMasterPasswordDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -7,8 +7,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import static megabasterd.MiscTools.formatBytes;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
|
|
||||||
public final class GlobalSpeedMeter implements Runnable {
|
public final class GlobalSpeedMeter implements Runnable {
|
||||||
|
|
||||||
@ -165,7 +164,7 @@ public final class GlobalSpeedMeter implements Runnable {
|
|||||||
Thread.sleep(SLEEP);
|
Thread.sleep(SLEEP);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(GlobalSpeedMeter.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
@ -20,16 +20,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.crypto.CipherInputStream;
|
import javax.crypto.CipherInputStream;
|
||||||
import static megabasterd.MainPanel.STREAMER_PORT;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.checkMegaDownloadUrl;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
@ -93,7 +88,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
try {
|
try {
|
||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(Download.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +174,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel, this.getMain_panel().getMega_proxy_server() != null ? (this.getMain_panel().getMega_proxy_server().getPort() + ":" + MiscTools.Bin2BASE64(("megacrypter:" + this.getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
file_info = MegaCrypterAPI.getMegaFileMetadata(link, panel, getMain_panel().getMega_proxy_server() != null ? (getMain_panel().getMega_proxy_server().getPort() + ":" + Bin2BASE64(("megacrypter:" + getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +233,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
|
|
||||||
MegaAPI ma = null;
|
MegaAPI ma = null;
|
||||||
|
|
||||||
if (mega_account == null || (ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, _main_panel.getView(), mega_account)) == null) {
|
if (mega_account == null || (ma = checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, _main_panel.getView(), mega_account)) == null) {
|
||||||
|
|
||||||
ma = new MegaAPI();
|
ma = new MegaAPI();
|
||||||
}
|
}
|
||||||
@ -247,7 +242,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
dl_url = ma.getMegaFileDownloadUrl(link);
|
dl_url = ma.getMegaFileDownloadUrl(link);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, pass_hash, noexpire_token, ma.getSid(), this.getMain_panel().getMega_proxy_server() != null ? (this.getMain_panel().getMega_proxy_server().getPort() + ":" + MiscTools.Bin2BASE64(("megacrypter:" + this.getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
dl_url = MegaCrypterAPI.getMegaFileDownloadUrl(link, pass_hash, noexpire_token, ma.getSid(), getMain_panel().getMega_proxy_server() != null ? (getMain_panel().getMega_proxy_server().getPort() + ":" + Bin2BASE64(("megacrypter:" + getMain_panel().getMega_proxy_server().getPassword()).getBytes())) : null);
|
||||||
}
|
}
|
||||||
} catch (MegaAPIException | MegaCrypterAPIException e) {
|
} catch (MegaAPIException | MegaCrypterAPIException e) {
|
||||||
error = true;
|
error = true;
|
||||||
@ -277,7 +272,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(KissVideoStreamServer.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (error);
|
} while (error);
|
||||||
@ -286,7 +281,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private long[] parseRangeHeader(String header) {
|
private long[] parseRangeHeader(String header) {
|
||||||
System.out.println(header);
|
|
||||||
Pattern pattern = Pattern.compile("bytes *\\= *([0-9]+) *\\- *([0-9]+)?");
|
Pattern pattern = Pattern.compile("bytes *\\= *([0-9]+) *\\- *([0-9]+)?");
|
||||||
|
|
||||||
Matcher matcher = pattern.matcher(header);
|
Matcher matcher = pattern.matcher(header);
|
||||||
@ -324,7 +319,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
|
|
||||||
HttpGet httpget;
|
HttpGet httpget;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
|
|
||||||
Headers reqheaders = xchg.getRequestHeaders();
|
Headers reqheaders = xchg.getRequestHeaders();
|
||||||
|
|
||||||
@ -336,7 +331,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
|
|
||||||
String link;
|
String link;
|
||||||
|
|
||||||
String[] url_parts = new String(MiscTools.UrlBASE642Bin(url_path.substring(url_path.indexOf("/video/") + 7))).split("\\|");
|
String[] url_parts = new String(UrlBASE642Bin(url_path.substring(url_path.indexOf("/video/") + 7))).split("\\|");
|
||||||
|
|
||||||
mega_account = url_parts[0];
|
mega_account = url_parts[0];
|
||||||
|
|
||||||
@ -344,9 +339,9 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
mega_account = null;
|
mega_account = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
link = new String(url_parts[1]);
|
link = url_parts[1];
|
||||||
|
|
||||||
System.out.println(link + " " + mega_account);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} {1} {2}", new Object[]{Thread.currentThread().getName(), link, mega_account});
|
||||||
|
|
||||||
HashMap cache_info, file_info;
|
HashMap cache_info, file_info;
|
||||||
|
|
||||||
@ -521,11 +516,11 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
if (!(ex instanceof IOException)) {
|
if (!(ex instanceof IOException)) {
|
||||||
Logger.getLogger(KissVideoStreamServer.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
System.out.println("KissVideoStreamerHandle: bye bye");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} KissVideoStreamerHandle: bye bye", Thread.currentThread().getName());
|
||||||
|
|
||||||
xchg.close();
|
xchg.close();
|
||||||
|
|
||||||
|
@ -14,12 +14,8 @@ import javax.swing.JComboBox;
|
|||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.extractMegaLinksFromString;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.extractStringFromClipboardContents;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import static megabasterd.MiscTools.truncateText;
|
|
||||||
|
|
||||||
public final class LinkGrabberDialog extends javax.swing.JDialog implements ClipboardChangeObserver {
|
public final class LinkGrabberDialog extends javax.swing.JDialog implements ClipboardChangeObserver {
|
||||||
|
|
||||||
@ -225,7 +221,7 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
|
|
||||||
_download = true;
|
_download = true;
|
||||||
|
|
||||||
this.setVisible(false);
|
setVisible(false);
|
||||||
}//GEN-LAST:event_dance_buttonActionPerformed
|
}//GEN-LAST:event_dance_buttonActionPerformed
|
||||||
|
|
||||||
private void change_dir_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_change_dir_buttonActionPerformed
|
private void change_dir_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_change_dir_buttonActionPerformed
|
||||||
@ -296,7 +292,7 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
|
|
||||||
String link = i.next();
|
String link = i.next();
|
||||||
|
|
||||||
if (MiscTools.findFirstRegex("(?:https?|mega)://[^/]*/(#.*?)?!.+![^\r\n]+", link, 0) == null) {
|
if (findFirstRegex("(?:https?|mega)://[^/]*/(#.*?)?!.+![^\r\n]+", link, 0) == null) {
|
||||||
|
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
@ -318,9 +314,9 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
Logger.getLogger(LinkGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(LinkGrabberDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
swingReflectionInvoke("setText", dlc_button, "Load DLC container");
|
swingReflectionInvoke("setText", dlc_button, "Load DLC container");
|
||||||
@ -366,16 +362,16 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
_last_selected_account = "";
|
_last_selected_account = "";
|
||||||
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 1);
|
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setEnabled", ((LinkGrabberDialog) tthis).getUse_mega_account_down_combobox(), true);
|
swingReflectionInvokeAndWait("setEnabled", tthis.getUse_mega_account_down_combobox(), true);
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setEnabled", ((LinkGrabberDialog) tthis).getDance_button(), true);
|
swingReflectionInvokeAndWait("setEnabled", tthis.getDance_button(), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,25 +29,13 @@ import static java.util.concurrent.Executors.newCachedThreadPool;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
|
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
|
||||||
import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION;
|
import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION;
|
||||||
import static javax.swing.JOptionPane.showOptionDialog;
|
import static javax.swing.JOptionPane.showOptionDialog;
|
||||||
import static megabasterd.DBTools.deleteUpload;
|
import static megabasterd.DBTools.*;
|
||||||
import static megabasterd.DBTools.selectDownloads;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.DBTools.selectELCAccounts;
|
import static megabasterd.Transference.*;
|
||||||
import static megabasterd.DBTools.selectMegaAccounts;
|
|
||||||
import static megabasterd.DBTools.selectSettingValueFromDB;
|
|
||||||
import static megabasterd.DBTools.selectUploads;
|
|
||||||
import static megabasterd.DBTools.setupSqliteTables;
|
|
||||||
import static megabasterd.MiscTools.BASE642Bin;
|
|
||||||
import static megabasterd.MiscTools.bin2i32a;
|
|
||||||
import static megabasterd.MiscTools.setNimbusLookAndFeel;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
import static megabasterd.Transference.LIMIT_TRANSFERENCE_SPEED_DEFAULT;
|
|
||||||
import static megabasterd.Transference.MAX_TRANSFERENCE_SPEED_DEFAULT;
|
|
||||||
import org.apache.http.auth.Credentials;
|
import org.apache.http.auth.Credentials;
|
||||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||||
|
|
||||||
@ -57,7 +45,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "2.25";
|
public static final String VERSION = "2.26";
|
||||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||||
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
||||||
public static final int STREAMER_PORT = 1337;
|
public static final int STREAMER_PORT = 1337;
|
||||||
@ -67,6 +55,10 @@ public final class MainPanel {
|
|||||||
public static final String ICON_FILE = "mbasterd_mini.png";
|
public static final String ICON_FILE = "mbasterd_mini.png";
|
||||||
public static final String ICON_FILE_MED = "mbasterd_med.png";
|
public static final String ICON_FILE_MED = "mbasterd_med.png";
|
||||||
public static final ExecutorService THREAD_POOL = newCachedThreadPool();
|
public static final ExecutorService THREAD_POOL = newCachedThreadPool();
|
||||||
|
private static String _proxy_host;
|
||||||
|
private static int _proxy_port;
|
||||||
|
private static Credentials _proxy_credentials;
|
||||||
|
private static boolean _use_proxy;
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
|
|
||||||
@ -75,7 +67,7 @@ public final class MainPanel {
|
|||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
System.out.println("Waiting " + args[0] + " seconds before start...");
|
Logger.getLogger(MainPanel.class.getName()).log(Level.INFO, "{0} Waiting {1} seconds before start...", new Object[]{Thread.currentThread().getName(), args[0]});
|
||||||
Thread.sleep(Long.parseLong(args[0]) * 1000);
|
Thread.sleep(Long.parseLong(args[0]) * 1000);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@ -92,6 +84,22 @@ public final class MainPanel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isUse_proxy() {
|
||||||
|
return _use_proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getProxy_host() {
|
||||||
|
return _proxy_host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getProxy_port() {
|
||||||
|
return _proxy_port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Credentials getProxy_credentials() {
|
||||||
|
return _proxy_credentials;
|
||||||
|
}
|
||||||
|
|
||||||
private volatile MainPanelView _view = null; //lazy init
|
private volatile MainPanelView _view = null; //lazy init
|
||||||
private final GlobalSpeedMeter _global_dl_speed, _global_up_speed;
|
private final GlobalSpeedMeter _global_dl_speed, _global_up_speed;
|
||||||
private final DownloadManager _download_manager;
|
private final DownloadManager _download_manager;
|
||||||
@ -111,10 +119,6 @@ public final class MainPanel {
|
|||||||
private String _master_pass_hash;
|
private String _master_pass_hash;
|
||||||
private String _master_pass_salt;
|
private String _master_pass_salt;
|
||||||
private boolean _restart;
|
private boolean _restart;
|
||||||
private static String _proxy_host;
|
|
||||||
private static int _proxy_port;
|
|
||||||
private static Credentials _proxy_credentials;
|
|
||||||
private static boolean _use_proxy;
|
|
||||||
private MegaProxyServer _mega_proxy_server;
|
private MegaProxyServer _mega_proxy_server;
|
||||||
private int _megacrypter_reverse_port;
|
private int _megacrypter_reverse_port;
|
||||||
private boolean _megacrypter_reverse;
|
private boolean _megacrypter_reverse;
|
||||||
@ -131,7 +135,7 @@ public final class MainPanel {
|
|||||||
trayIcon();
|
trayIcon();
|
||||||
|
|
||||||
} catch (AWTException ex) {
|
} catch (AWTException ex) {
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -139,7 +143,7 @@ public final class MainPanel {
|
|||||||
setupSqliteTables();
|
setupSqliteTables();
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_restart = false;
|
_restart = false;
|
||||||
@ -185,14 +189,14 @@ public final class MainPanel {
|
|||||||
try {
|
try {
|
||||||
_streamserver.start(STREAMER_PORT, "/video");
|
_streamserver.start(STREAMER_PORT, "/video");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
THREAD_POOL.execute(new Runnable() {
|
THREAD_POOL.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
String new_version = MiscTools.checkNewVersion("lYsRWaQB", "uVhntmyKcVECRaOxAbcL4A");
|
String new_version = checkNewVersion("lYsRWaQB", "uVhntmyKcVECRaOxAbcL4A");
|
||||||
|
|
||||||
if (new_version != null) {
|
if (new_version != null) {
|
||||||
|
|
||||||
@ -202,7 +206,7 @@ public final class MainPanel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (_megacrypter_reverse) {
|
if (_megacrypter_reverse) {
|
||||||
_mega_proxy_server = new MegaProxyServer(UUID.randomUUID().toString(), this._megacrypter_reverse_port);
|
_mega_proxy_server = new MegaProxyServer(UUID.randomUUID().toString(), _megacrypter_reverse_port);
|
||||||
_mega_proxy_server.start();
|
_mega_proxy_server.start();
|
||||||
} else {
|
} else {
|
||||||
_mega_proxy_server = null;
|
_mega_proxy_server = null;
|
||||||
@ -221,8 +225,8 @@ public final class MainPanel {
|
|||||||
return _megacrypter_reverse_port;
|
return _megacrypter_reverse_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMega_proxy_server(MegaProxyServer _mega_proxy_server) {
|
public void setMega_proxy_server(MegaProxyServer mega_proxy_server) {
|
||||||
this._mega_proxy_server = _mega_proxy_server;
|
_mega_proxy_server = mega_proxy_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUse_mega_account_down() {
|
public boolean isUse_mega_account_down() {
|
||||||
@ -237,24 +241,8 @@ public final class MainPanel {
|
|||||||
return _restart;
|
return _restart;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRestart(boolean _restart) {
|
public void setRestart(boolean restart) {
|
||||||
this._restart = _restart;
|
_restart = restart;
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isUse_proxy() {
|
|
||||||
return _use_proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getProxy_host() {
|
|
||||||
return _proxy_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getProxy_port() {
|
|
||||||
return _proxy_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Credentials getProxy_credentials() {
|
|
||||||
return _proxy_credentials;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, Object> getElc_accounts() {
|
public HashMap<String, Object> getElc_accounts() {
|
||||||
@ -500,7 +488,7 @@ public final class MainPanel {
|
|||||||
_mega_accounts = selectMegaAccounts();
|
_mega_accounts = selectMegaAccounts();
|
||||||
_elc_accounts = selectELCAccounts();
|
_elc_accounts = selectELCAccounts();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mega_account_down = DBTools.selectSettingValueFromDB("mega_account_down");
|
_mega_account_down = DBTools.selectSettingValueFromDB("mega_account_down");
|
||||||
@ -517,11 +505,11 @@ public final class MainPanel {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
_master_pass_salt = MiscTools.Bin2BASE64(MiscTools.genRandomByteArray(CryptTools.PBKDF2_SALT_BYTE_LENGTH));
|
_master_pass_salt = Bin2BASE64(genRandomByteArray(CryptTools.PBKDF2_SALT_BYTE_LENGTH));
|
||||||
|
|
||||||
DBTools.insertSettingValueInDB("master_pass_salt", _master_pass_salt);
|
DBTools.insertSettingValueInDB("master_pass_salt", _master_pass_salt);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,7 +638,7 @@ public final class MainPanel {
|
|||||||
swingReflectionInvoke("setVisible", getView(), true);
|
swingReflectionInvoke("setVisible", getView(), true);
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,7 +657,7 @@ public final class MainPanel {
|
|||||||
|
|
||||||
} catch (IOException ex1) {
|
} catch (IOException ex1) {
|
||||||
|
|
||||||
getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex1);
|
Logger.getLogger(MainPanel.class.getName()).log(Level.SEVERE, null, ex1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,14 +684,14 @@ public final class MainPanel {
|
|||||||
ArrayList<HashMap<String, Object>> res = selectDownloads();
|
ArrayList<HashMap<String, Object>> res = selectDownloads();
|
||||||
|
|
||||||
for (HashMap<String, Object> o : res) {
|
for (HashMap<String, Object> o : res) {
|
||||||
System.out.println(o);
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String email = (String) o.get("email");
|
String email = (String) o.get("email");
|
||||||
|
|
||||||
MegaAPI ma;
|
MegaAPI ma;
|
||||||
|
|
||||||
if (!tthis.isUse_mega_account_down() || _mega_accounts.get(email) == null || (ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(tthis, getView(), email)) == null) {
|
if (!tthis.isUse_mega_account_down() || _mega_accounts.get(email) == null || (ma = checkMegaAccountLoginAndShowMasterPassDialog(tthis, getView(), email)) == null) {
|
||||||
|
|
||||||
ma = new MegaAPI();
|
ma = new MegaAPI();
|
||||||
}
|
}
|
||||||
@ -721,7 +709,7 @@ public final class MainPanel {
|
|||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conta_downloads > 0) {
|
if (conta_downloads > 0) {
|
||||||
@ -835,7 +823,7 @@ public final class MainPanel {
|
|||||||
|
|
||||||
if (_mega_accounts.get(email) != null) {
|
if (_mega_accounts.get(email) != null) {
|
||||||
|
|
||||||
if ((ma = MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(tthis, getView(), email)) == null) {
|
if ((ma = checkMegaAccountLoginAndShowMasterPassDialog(tthis, getView(), email)) == null) {
|
||||||
ma = new MegaAPI();
|
ma = new MegaAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,7 +839,7 @@ public final class MainPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -865,8 +853,8 @@ public final class MainPanel {
|
|||||||
|
|
||||||
swingReflectionInvoke("setText", getView().getStatus_up_label(), "");
|
swingReflectionInvoke("setText", getView().getStatus_up_label(), "");
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(MainPanel.class.getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import java.util.UUID;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
@ -25,17 +24,10 @@ import static javax.swing.JOptionPane.YES_NO_CANCEL_OPTION;
|
|||||||
import static javax.swing.JOptionPane.showOptionDialog;
|
import static javax.swing.JOptionPane.showOptionDialog;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import static megabasterd.CryptTools.decryptMegaDownloaderLink;
|
import static megabasterd.CryptTools.*;
|
||||||
import static megabasterd.DBTools.deleteELCAccount;
|
import static megabasterd.DBTools.*;
|
||||||
import static megabasterd.DBTools.deleteMegaAccount;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MainPanel.ICON_FILE_MED;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MainPanel.VERSION;
|
|
||||||
import static megabasterd.MiscTools.findAllRegex;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import static megabasterd.MiscTools.genID;
|
|
||||||
import static megabasterd.MiscTools.i32a2bin;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
|
|
||||||
public final class MainPanelView extends javax.swing.JFrame {
|
public final class MainPanelView extends javax.swing.JFrame {
|
||||||
|
|
||||||
@ -519,7 +511,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
urls.add(decryptMegaDownloaderLink(link));
|
urls.add(decryptMegaDownloaderLink(link));
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,7 +524,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
urls.addAll(CryptTools.decryptELC(link, getMain_panel()));
|
urls.addAll(CryptTools.decryptELC(link, getMain_panel()));
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +536,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
for (String link : links) {
|
for (String link : links) {
|
||||||
|
|
||||||
if (MiscTools.findFirstRegex("(?:https?|mega)://[^/]*/(#.*?)?!.+![^\r\n]+", link, 0) != null) {
|
if (findFirstRegex("(?:https?|mega)://[^/]*/(#.*?)?!.+![^\r\n]+", link, 0) != null) {
|
||||||
|
|
||||||
urls.add(link);
|
urls.add(link);
|
||||||
}
|
}
|
||||||
@ -640,7 +632,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
try {
|
try {
|
||||||
deleteMegaAccount(email);
|
deleteMegaAccount(email);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_main_panel.getMega_accounts().remove(email);
|
_main_panel.getMega_accounts().remove(email);
|
||||||
@ -653,7 +645,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
try {
|
try {
|
||||||
deleteELCAccount(host);
|
deleteELCAccount(host);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_main_panel.getElc_accounts().remove(host);
|
_main_panel.getElc_accounts().remove(host);
|
||||||
@ -699,7 +691,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
if (_main_panel.isRestart()) {
|
if (_main_panel.isRestart()) {
|
||||||
|
|
||||||
MiscTools.restartApplication(1);
|
restartApplication(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_main_panel.isMegacrypter_reverse()) {
|
if (_main_panel.isMegacrypter_reverse()) {
|
||||||
@ -718,7 +710,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
_main_panel.getMega_proxy_server().start();
|
_main_panel.getMega_proxy_server().start();
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(MainPanelView.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,7 +721,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
try {
|
try {
|
||||||
_main_panel.getMega_proxy_server().stopServer();
|
_main_panel.getMega_proxy_server().stopServer();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(MainPanelView.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +838,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
String parent_node = (String) ((Map) ((List) res.get("f")).get(0)).get("h");
|
String parent_node = (String) ((Map) ((List) res.get("f")).get(0)).get("h");
|
||||||
|
|
||||||
System.out.println("Dir " + parent_node + " created");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Dir {1} created", new Object[]{Thread.currentThread().getName(), parent_node});
|
||||||
|
|
||||||
ma.shareFolder(parent_node, parent_key, share_key);
|
ma.shareFolder(parent_node, parent_key, share_key);
|
||||||
|
|
||||||
@ -861,8 +853,6 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
String[] dirs = file_path.split("/");
|
String[] dirs = file_path.split("/");
|
||||||
|
|
||||||
System.out.println(file_path);
|
|
||||||
|
|
||||||
MegaDirNode current_node = file_paths;
|
MegaDirNode current_node = file_paths;
|
||||||
|
|
||||||
String file_parent = current_node.getNode_id();
|
String file_parent = current_node.getNode_id();
|
||||||
@ -903,7 +893,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
getLogger(MainPanelView.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,18 +14,9 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import static megabasterd.MiscTools.Bin2UrlBASE64;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.UrlBASE642Bin;
|
import static megabasterd.CryptTools.*;
|
||||||
import static megabasterd.MiscTools.bin2i32a;
|
|
||||||
import static megabasterd.MiscTools.cleanFilename;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import static megabasterd.MiscTools.genID;
|
|
||||||
import static megabasterd.MiscTools.genRandomByteArray;
|
|
||||||
import static megabasterd.MiscTools.getWaitTimeExpBackOff;
|
|
||||||
import static megabasterd.MiscTools.i32a2bin;
|
|
||||||
import static megabasterd.MiscTools.mpi2big;
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
@ -151,7 +142,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
_rsa_priv_key = _extractRSAPrivKey(privk_byte);
|
_rsa_priv_key = _extractRSAPrivKey(privk_byte);
|
||||||
|
|
||||||
byte[] raw_sid = CryptTools.rsaDecrypt(mpi2big(UrlBASE642Bin(csid)), _rsa_priv_key[0], _rsa_priv_key[1], _rsa_priv_key[2]);
|
byte[] raw_sid = rsaDecrypt(mpi2big(UrlBASE642Bin(csid)), _rsa_priv_key[0], _rsa_priv_key[1], _rsa_priv_key[2]);
|
||||||
|
|
||||||
_sid = Bin2UrlBASE64(Arrays.copyOfRange(raw_sid, 0, 43));
|
_sid = Bin2UrlBASE64(Arrays.copyOfRange(raw_sid, 0, 43));
|
||||||
}
|
}
|
||||||
@ -163,9 +154,9 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
_email = email;
|
_email = email;
|
||||||
|
|
||||||
_password_aes = CryptTools.MEGAPrepareMasterKey(bin2i32a(password.getBytes()));
|
_password_aes = MEGAPrepareMasterKey(bin2i32a(password.getBytes()));
|
||||||
|
|
||||||
_user_hash = CryptTools.MEGAUserHash(email.toLowerCase().getBytes(), _password_aes);
|
_user_hash = MEGAUserHash(email.toLowerCase().getBytes(), _password_aes);
|
||||||
|
|
||||||
_realLogin();
|
_realLogin();
|
||||||
}
|
}
|
||||||
@ -220,7 +211,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return quota;
|
return quota;
|
||||||
@ -238,8 +229,6 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String res = _rawRequest(request, url_api);
|
String res = _rawRequest(request, url_api);
|
||||||
|
|
||||||
System.out.println(res);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
HashMap[] res_map = objectMapper.readValue(res, HashMap[].class);
|
HashMap[] res_map = objectMapper.readValue(res, HashMap[].class);
|
||||||
@ -267,7 +256,7 @@ public final class MegaAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException | MegaAPIException ex) {
|
} catch (IOException | MegaAPIException ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -276,7 +265,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String response = null;
|
String response = null;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
|
|
||||||
int error, conta_error = 0;
|
int error, conta_error = 0;
|
||||||
|
|
||||||
@ -296,8 +285,10 @@ public final class MegaAPI {
|
|||||||
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
||||||
|
|
||||||
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
||||||
System.out.println(request + " " + url_api.toString());
|
|
||||||
System.out.println("Failed : HTTP error code : " + httpresponse.getStatusLine().getStatusCode());
|
Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} {1} {2}", new Object[]{Thread.currentThread().getName(), request, url_api.toString()});
|
||||||
|
|
||||||
|
Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), httpresponse.getStatusLine().getStatusCode()});
|
||||||
|
|
||||||
if (httpresponse.getStatusLine().getStatusCode() == 509) {
|
if (httpresponse.getStatusLine().getStatusCode() == 509) {
|
||||||
|
|
||||||
@ -333,7 +324,7 @@ public final class MegaAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
Logger.getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
@ -343,12 +334,12 @@ public final class MegaAPI {
|
|||||||
throw new MegaAPIException(String.valueOf(error));
|
throw new MegaAPIException(String.valueOf(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("MegaAPI ERROR " + String.valueOf(error) + " Waiting for retry...");
|
Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} MegaAPI ERROR {1} Waiting for retry...", new Object[]{Thread.currentThread().getName(), String.valueOf(error)});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(getWaitTimeExpBackOff(conta_error++) * 1000);
|
Thread.sleep(getWaitTimeExpBackOff(conta_error++) * 1000);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -435,7 +426,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String[] file_data = null;
|
String[] file_data = null;
|
||||||
|
|
||||||
HashMap att_map = _decAttr(at, CryptTools.initMEGALinkKey(file_key));
|
HashMap att_map = _decAttr(at, initMEGALinkKey(file_key));
|
||||||
|
|
||||||
if (att_map != null) {
|
if (att_map != null) {
|
||||||
|
|
||||||
@ -463,10 +454,10 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ret = CryptTools.aes_cbc_encrypt(new_attr_byte, key, CryptTools.AES_ZERO_IV);
|
ret = aes_cbc_encrypt(new_attr_byte, key, AES_ZERO_IV);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -476,11 +467,11 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
HashMap res_map = null;
|
HashMap res_map = null;
|
||||||
|
|
||||||
byte[] decrypted_at = null;
|
byte[] decrypted_at;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Cipher decrypter = CryptTools.genDecrypter("AES", "AES/CBC/NoPadding", key, CryptTools.AES_ZERO_IV);
|
Cipher decrypter = genDecrypter("AES", "AES/CBC/NoPadding", key, AES_ZERO_IV);
|
||||||
|
|
||||||
decrypted_at = decrypter.doFinal(UrlBASE642Bin(encAttr));
|
decrypted_at = decrypter.doFinal(UrlBASE642Bin(encAttr));
|
||||||
|
|
||||||
@ -491,7 +482,7 @@ public final class MegaAPI {
|
|||||||
res_map = objectMapper.readValue(att, HashMap.class);
|
res_map = objectMapper.readValue(att, HashMap.class);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +510,7 @@ public final class MegaAPI {
|
|||||||
ul_url = (String) res_map[0].get("p");
|
ul_url = (String) res_map[0].get("p");
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ul_url;
|
return ul_url;
|
||||||
@ -544,7 +535,7 @@ public final class MegaAPI {
|
|||||||
res_map = objectMapper.readValue(res, HashMap[].class);
|
res_map = objectMapper.readValue(res, HashMap[].class);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res_map[0];
|
return res_map[0];
|
||||||
@ -552,12 +543,12 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
public byte[] encryptKey(byte[] a, byte[] key) throws Exception {
|
public byte[] encryptKey(byte[] a, byte[] key) throws Exception {
|
||||||
|
|
||||||
return CryptTools.aes_ecb_encrypt(a, key);
|
return aes_ecb_encrypt(a, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] decryptKey(byte[] a, byte[] key) throws Exception {
|
public byte[] decryptKey(byte[] a, byte[] key) throws Exception {
|
||||||
|
|
||||||
return CryptTools.aes_ecb_decrypt(a, key);
|
return aes_ecb_decrypt(a, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigInteger[] _extractRSAPrivKey(byte[] rsa_data) {
|
private BigInteger[] _extractRSAPrivKey(byte[] rsa_data) {
|
||||||
@ -592,14 +583,12 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String res = _rawRequest(request, url_api);
|
String res = _rawRequest(request, url_api);
|
||||||
|
|
||||||
System.out.println(res);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
res_map = objectMapper.readValue(res, HashMap[].class);
|
res_map = objectMapper.readValue(res, HashMap[].class);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res_map[0];
|
return res_map[0];
|
||||||
@ -624,14 +613,12 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String res = _rawRequest(request, url_api);
|
String res = _rawRequest(request, url_api);
|
||||||
|
|
||||||
System.out.println(res);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
res_map = objectMapper.readValue(res, HashMap[].class);
|
res_map = objectMapper.readValue(res, HashMap[].class);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res_map[0];
|
return res_map[0];
|
||||||
@ -654,8 +641,6 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String res = _rawRequest(request, url_api);
|
String res = _rawRequest(request, url_api);
|
||||||
|
|
||||||
System.out.println(res);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
res_map = objectMapper.readValue(res, List.class);
|
res_map = objectMapper.readValue(res, List.class);
|
||||||
@ -665,7 +650,7 @@ public final class MegaAPI {
|
|||||||
public_link = "https://mega.nz/#!" + file_id + "!" + Bin2UrlBASE64(node_key);
|
public_link = "https://mega.nz/#!" + file_id + "!" + Bin2UrlBASE64(node_key);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return public_link;
|
return public_link;
|
||||||
@ -687,8 +672,6 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String res = _rawRequest(request, url_api);
|
String res = _rawRequest(request, url_api);
|
||||||
|
|
||||||
System.out.println(res);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
res_map = objectMapper.readValue(res, List.class);
|
res_map = objectMapper.readValue(res, List.class);
|
||||||
@ -698,7 +681,7 @@ public final class MegaAPI {
|
|||||||
public_link = "https://mega.nz/#F!" + folder_id + "!" + Bin2UrlBASE64(node_key);
|
public_link = "https://mega.nz/#F!" + folder_id + "!" + Bin2UrlBASE64(node_key);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return public_link;
|
return public_link;
|
||||||
@ -719,7 +702,7 @@ public final class MegaAPI {
|
|||||||
return genRandomByteArray(16);
|
return genRandomByteArray(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shareFolder(String node, byte[] node_key, byte[] share_key) {
|
public String shareFolder(String node, byte[] node_key, byte[] share_key) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -731,17 +714,15 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String request = "[{\"a\":\"s2\",\"n\":\"" + node + "\",\"s\":[{\"u\":\"EXP\",\"r\":0}],\"i\":\"" + _req_id + "\",\"ok\":\"" + ok + "\",\"ha\":\"" + ha + "\",\"cr\":[[\"" + node + "\"],[\"" + node + "\"],[0,0,\"" + enc_nk + "\"]]}]";
|
String request = "[{\"a\":\"s2\",\"n\":\"" + node + "\",\"s\":[{\"u\":\"EXP\",\"r\":0}],\"i\":\"" + _req_id + "\",\"ok\":\"" + ok + "\",\"ha\":\"" + ha + "\",\"cr\":[[\"" + node + "\"],[\"" + node + "\"],[0,0,\"" + enc_nk + "\"]]}]";
|
||||||
|
|
||||||
System.out.println(request);
|
|
||||||
|
|
||||||
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : ""));
|
URL url_api = new URL(API_URL + "/cs?id=" + String.valueOf(_seqno) + (_sid != null ? "&sid=" + _sid : "") + (API_KEY != null ? "&ak=" + API_KEY : ""));
|
||||||
|
|
||||||
String res = _rawRequest(request, url_api);
|
return _rawRequest(request, url_api);
|
||||||
|
|
||||||
System.out.println(res);
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String cryptoHandleauth(String h) {
|
public String cryptoHandleauth(String h) {
|
||||||
@ -753,7 +734,7 @@ public final class MegaAPI {
|
|||||||
ch = Bin2UrlBASE64(encryptKey((h + h).getBytes(), i32a2bin(getMaster_key())));
|
ch = Bin2UrlBASE64(encryptKey((h + h).getBytes(), i32a2bin(getMaster_key())));
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
@ -769,8 +750,6 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
String res = _rawRequest(request, url_api);
|
String res = _rawRequest(request, url_api);
|
||||||
|
|
||||||
System.out.println(res);
|
|
||||||
|
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
HashMap[] res_map = objectMapper.readValue(res, HashMap[].class);
|
HashMap[] res_map = objectMapper.readValue(res, HashMap[].class);
|
||||||
@ -838,7 +817,7 @@ public final class MegaAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MegaAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -15,12 +15,8 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static megabasterd.MiscTools.BASE642Bin;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.Bin2BASE64;
|
import static megabasterd.CryptTools.*;
|
||||||
import static megabasterd.MiscTools.Bin2UrlBASE64;
|
|
||||||
import static megabasterd.MiscTools.cleanFilePath;
|
|
||||||
import static megabasterd.MiscTools.cleanFilename;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
@ -41,7 +37,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
String response = null;
|
String response = null;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
|
|
||||||
HttpPost httppost;
|
HttpPost httppost;
|
||||||
|
|
||||||
@ -57,7 +53,7 @@ public final class MegaCrypterAPI {
|
|||||||
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
try (CloseableHttpResponse httpresponse = httpclient.execute(httppost)) {
|
||||||
|
|
||||||
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
if (httpresponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
|
||||||
System.out.println("Failed : HTTP error code : " + httpresponse.getStatusLine().getStatusCode());
|
Logger.getLogger(MegaCrypterAPI.class.getName()).log(Level.INFO, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), httpresponse.getStatusLine().getStatusCode()});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -102,8 +98,6 @@ public final class MegaCrypterAPI {
|
|||||||
public static String getMegaFileDownloadUrl(String link, String pass_hash, String noexpire_token, String sid, String reverse) throws IOException, MegaCrypterAPIException {
|
public static String getMegaFileDownloadUrl(String link, String pass_hash, String noexpire_token, String sid, String reverse) throws IOException, MegaCrypterAPIException {
|
||||||
String request = "{\"m\":\"dl\", \"link\": \"" + link + "\"" + (noexpire_token != null ? ", \"noexpire\": \"" + noexpire_token + "\"" : "") + (sid != null ? ", \"sid\": \"" + sid + "\"" : "") + (reverse != null ? ", \"reverse\": \"" + reverse + "\"" : "") + "}";
|
String request = "{\"m\":\"dl\", \"link\": \"" + link + "\"" + (noexpire_token != null ? ", \"noexpire\": \"" + noexpire_token + "\"" : "") + (sid != null ? ", \"sid\": \"" + sid + "\"" : "") + (reverse != null ? ", \"reverse\": \"" + reverse + "\"" : "") + "}";
|
||||||
|
|
||||||
System.out.println(request);
|
|
||||||
|
|
||||||
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
||||||
|
|
||||||
String res = MegaCrypterAPI._rawRequest(request, url_api);
|
String res = MegaCrypterAPI._rawRequest(request, url_api);
|
||||||
@ -120,7 +114,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
byte[] iv = BASE642Bin(pass);
|
byte[] iv = BASE642Bin(pass);
|
||||||
|
|
||||||
Cipher decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", BASE642Bin(pass_hash), iv);
|
Cipher decrypter = genDecrypter("AES", "AES/CBC/PKCS5Padding", BASE642Bin(pass_hash), iv);
|
||||||
|
|
||||||
byte[] decrypted_url = decrypter.doFinal(BASE642Bin(dl_url));
|
byte[] decrypted_url = decrypter.doFinal(BASE642Bin(dl_url));
|
||||||
|
|
||||||
@ -136,7 +130,7 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
public static String[] getMegaFileMetadata(String link, MainPanelView panel, String reverse) throws MegaCrypterAPIException, MalformedURLException, IOException {
|
public static String[] getMegaFileMetadata(String link, MainPanelView panel, String reverse) throws MegaCrypterAPIException, MalformedURLException, IOException {
|
||||||
String request = "{\"m\":\"info\", \"link\": \"" + link + "\"" + (reverse != null ? ", \"reverse\": \"" + reverse + "\"" : "") + "}";
|
String request = "{\"m\":\"info\", \"link\": \"" + link + "\"" + (reverse != null ? ", \"reverse\": \"" + reverse + "\"" : "") + "}";
|
||||||
System.out.println(request);
|
|
||||||
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
URL url_api = new URL(findFirstRegex("https?://[^/]+", link, 0) + "/api");
|
||||||
|
|
||||||
String res = MegaCrypterAPI._rawRequest(request, url_api);
|
String res = MegaCrypterAPI._rawRequest(request, url_api);
|
||||||
@ -201,10 +195,6 @@ public final class MegaCrypterAPI {
|
|||||||
pass = (String) pass_val;
|
pass = (String) pass_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("PASS: " + pass);
|
|
||||||
|
|
||||||
System.out.println(noexpire_token);
|
|
||||||
|
|
||||||
if (pass != null) {
|
if (pass != null) {
|
||||||
String[] pass_items = pass.split("#");
|
String[] pass_items = pass.split("#");
|
||||||
|
|
||||||
@ -244,9 +234,9 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
info_key = CryptTools.PBKDF2HMACSHA256(password, salt, (int) Math.pow(2, iterations));
|
info_key = PBKDF2HMACSHA256(password, salt, (int) Math.pow(2, iterations));
|
||||||
|
|
||||||
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
decrypter = genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
||||||
|
|
||||||
bad_pass = !Arrays.equals(info_key, decrypter.doFinal(key_check));
|
bad_pass = !Arrays.equals(info_key, decrypter.doFinal(key_check));
|
||||||
|
|
||||||
@ -272,13 +262,13 @@ public final class MegaCrypterAPI {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
decrypter = genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
||||||
|
|
||||||
byte[] decrypted_key = decrypter.doFinal(BASE642Bin(fkey));
|
byte[] decrypted_key = decrypter.doFinal(BASE642Bin(fkey));
|
||||||
|
|
||||||
fkey = Bin2UrlBASE64(decrypted_key);
|
fkey = Bin2UrlBASE64(decrypted_key);
|
||||||
|
|
||||||
decrypter = CryptTools.genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
decrypter = genDecrypter("AES", "AES/CBC/PKCS5Padding", info_key, iv);
|
||||||
|
|
||||||
byte[] decrypted_name = decrypter.doFinal(BASE642Bin(fname));
|
byte[] decrypted_name = decrypter.doFinal(BASE642Bin(fname));
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package megabasterd;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import static megabasterd.MiscTools.formatBytes;
|
import static megabasterd.MiscTools.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -7,24 +7,17 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import static megabasterd.MiscTools.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thanks to -> https://stackoverflow.com/users/6477541/sarvesh-agarwal
|
* Thanks to -> https://stackoverflow.com/users/6477541/sarvesh-agarwal
|
||||||
*/
|
*/
|
||||||
public class MegaProxyServer extends Thread {
|
public class MegaProxyServer extends Thread {
|
||||||
|
|
||||||
private String _password;
|
private final String _password;
|
||||||
private int _port;
|
private final int _port;
|
||||||
private ServerSocket _serverSocket;
|
private ServerSocket _serverSocket;
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return _password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return _port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MegaProxyServer(String password, int port) {
|
public MegaProxyServer(String password, int port) {
|
||||||
|
|
||||||
super("Server Thread");
|
super("Server Thread");
|
||||||
@ -33,9 +26,17 @@ public class MegaProxyServer extends Thread {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return _password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return _port;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void stopServer() throws IOException {
|
public synchronized void stopServer() throws IOException {
|
||||||
|
|
||||||
this._serverSocket.close();
|
_serverSocket.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,21 +51,22 @@ public class MegaProxyServer extends Thread {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
while ((socket = _serverSocket.accept()) != null) {
|
while ((socket = _serverSocket.accept()) != null) {
|
||||||
(new Handler(socket, this._password)).start();
|
(new Handler(socket, _password)).start();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(); // TODO: implement catch
|
// TODO: implement catch
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(MegaProxyServer.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
if (!_serverSocket.isClosed()) {
|
if (!_serverSocket.isClosed()) {
|
||||||
try {
|
try {
|
||||||
_serverSocket.close();
|
_serverSocket.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(MegaProxyServer.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,127 +77,6 @@ public class MegaProxyServer extends Thread {
|
|||||||
public static final Pattern CONNECT_PATTERN = Pattern.compile("CONNECT (.*mega(?:\\.co)?\\.nz):(443) HTTP/(1\\.[01])", Pattern.CASE_INSENSITIVE);
|
public static final Pattern CONNECT_PATTERN = Pattern.compile("CONNECT (.*mega(?:\\.co)?\\.nz):(443) HTTP/(1\\.[01])", Pattern.CASE_INSENSITIVE);
|
||||||
public static final Pattern AUTH_PATTERN = Pattern.compile("Proxy-Authorization: Basic +(.+)", Pattern.CASE_INSENSITIVE);
|
public static final Pattern AUTH_PATTERN = Pattern.compile("Proxy-Authorization: Basic +(.+)", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
private final Socket clientSocket;
|
|
||||||
private boolean previousWasR = false;
|
|
||||||
private String _password;
|
|
||||||
|
|
||||||
public Handler(Socket clientSocket, String password) {
|
|
||||||
this.clientSocket = clientSocket;
|
|
||||||
this._password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
String request = readLine(clientSocket);
|
|
||||||
System.out.println(request);
|
|
||||||
Matcher matcher = CONNECT_PATTERN.matcher(request);
|
|
||||||
boolean auth_ok = false;
|
|
||||||
|
|
||||||
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(clientSocket.getOutputStream(), "UTF-8");
|
|
||||||
|
|
||||||
if (matcher.matches()) {
|
|
||||||
|
|
||||||
String header;
|
|
||||||
String proxy_auth = null;
|
|
||||||
|
|
||||||
do {
|
|
||||||
header = readLine(clientSocket);
|
|
||||||
|
|
||||||
Matcher matcher_auth = AUTH_PATTERN.matcher(header);
|
|
||||||
|
|
||||||
if (matcher_auth.matches()) {
|
|
||||||
|
|
||||||
proxy_auth = new String(MiscTools.BASE642Bin(matcher_auth.group(1).trim()));
|
|
||||||
|
|
||||||
System.out.println(proxy_auth);
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (!"".equals(header));
|
|
||||||
|
|
||||||
if (proxy_auth != null && proxy_auth.equals("megacrypter:" + this._password)) {
|
|
||||||
final Socket forwardSocket;
|
|
||||||
|
|
||||||
try {
|
|
||||||
forwardSocket = new Socket(matcher.group(1), Integer.parseInt(matcher.group(2)));
|
|
||||||
System.out.println(forwardSocket);
|
|
||||||
} catch (IOException | NumberFormatException e) {
|
|
||||||
e.printStackTrace(); // TODO: implement catch
|
|
||||||
outputStreamWriter.write("HTTP/" + matcher.group(3) + " 502 Bad Gateway\r\n");
|
|
||||||
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
|
||||||
outputStreamWriter.write("\r\n");
|
|
||||||
outputStreamWriter.flush();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
outputStreamWriter.write("HTTP/" + matcher.group(3) + " 200 Connection established\r\n");
|
|
||||||
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
|
||||||
outputStreamWriter.write("\r\n");
|
|
||||||
outputStreamWriter.flush();
|
|
||||||
|
|
||||||
Thread remoteToClient = new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
forwardData(forwardSocket, clientSocket);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
remoteToClient.start();
|
|
||||||
try {
|
|
||||||
if (previousWasR) {
|
|
||||||
int read = clientSocket.getInputStream().read();
|
|
||||||
if (read != -1) {
|
|
||||||
if (read != '\n') {
|
|
||||||
forwardSocket.getOutputStream().write(read);
|
|
||||||
}
|
|
||||||
forwardData(clientSocket, forwardSocket);
|
|
||||||
} else {
|
|
||||||
if (!forwardSocket.isOutputShutdown()) {
|
|
||||||
forwardSocket.shutdownOutput();
|
|
||||||
}
|
|
||||||
if (!clientSocket.isInputShutdown()) {
|
|
||||||
clientSocket.shutdownInput();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
forwardData(clientSocket, forwardSocket);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
remoteToClient.join();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace(); // TODO: implement catch
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
forwardSocket.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
outputStreamWriter.write("HTTP/1.1 403 Unauthorized\r\n");
|
|
||||||
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
|
||||||
outputStreamWriter.write("\r\n");
|
|
||||||
outputStreamWriter.flush();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
outputStreamWriter.write("HTTP/1.1 403 Unauthorized\r\n");
|
|
||||||
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
|
||||||
outputStreamWriter.write("\r\n");
|
|
||||||
outputStreamWriter.flush();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace(); // TODO: implement catch
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
clientSocket.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace(); // TODO: implement catch
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void forwardData(Socket inputSocket, Socket outputSocket) {
|
private static void forwardData(Socket inputSocket, Socket outputSocket) {
|
||||||
try {
|
try {
|
||||||
InputStream inputStream = inputSocket.getInputStream();
|
InputStream inputStream = inputSocket.getInputStream();
|
||||||
@ -224,7 +105,132 @@ public class MegaProxyServer extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace(); // TODO: implement catch
|
// TODO: implement catch
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Socket _clientSocket;
|
||||||
|
private boolean _previousWasR = false;
|
||||||
|
private final String _password;
|
||||||
|
|
||||||
|
public Handler(Socket clientSocket, String password) {
|
||||||
|
_clientSocket = clientSocket;
|
||||||
|
_password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
String request = readLine(_clientSocket);
|
||||||
|
|
||||||
|
Matcher matcher = CONNECT_PATTERN.matcher(request);
|
||||||
|
|
||||||
|
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(_clientSocket.getOutputStream(), "UTF-8");
|
||||||
|
|
||||||
|
if (matcher.matches()) {
|
||||||
|
|
||||||
|
String header;
|
||||||
|
String proxy_auth = null;
|
||||||
|
|
||||||
|
do {
|
||||||
|
header = readLine(_clientSocket);
|
||||||
|
|
||||||
|
Matcher matcher_auth = AUTH_PATTERN.matcher(header);
|
||||||
|
|
||||||
|
if (matcher_auth.matches()) {
|
||||||
|
|
||||||
|
proxy_auth = new String(BASE642Bin(matcher_auth.group(1).trim()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (!"".equals(header));
|
||||||
|
|
||||||
|
if (proxy_auth != null && proxy_auth.equals("megacrypter:" + _password)) {
|
||||||
|
final Socket forwardSocket;
|
||||||
|
|
||||||
|
try {
|
||||||
|
forwardSocket = new Socket(matcher.group(1), Integer.parseInt(matcher.group(2)));
|
||||||
|
|
||||||
|
} catch (IOException | NumberFormatException e) { // TODO: implement catch
|
||||||
|
// TODO: implement catch
|
||||||
|
outputStreamWriter.write("HTTP/" + matcher.group(3) + " 502 Bad Gateway\r\n");
|
||||||
|
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
||||||
|
outputStreamWriter.write("\r\n");
|
||||||
|
outputStreamWriter.flush();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
outputStreamWriter.write("HTTP/" + matcher.group(3) + " 200 Connection established\r\n");
|
||||||
|
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
||||||
|
outputStreamWriter.write("\r\n");
|
||||||
|
outputStreamWriter.flush();
|
||||||
|
|
||||||
|
Thread remoteToClient = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
forwardData(forwardSocket, _clientSocket);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
remoteToClient.start();
|
||||||
|
try {
|
||||||
|
if (_previousWasR) {
|
||||||
|
int read = _clientSocket.getInputStream().read();
|
||||||
|
if (read != -1) {
|
||||||
|
if (read != '\n') {
|
||||||
|
forwardSocket.getOutputStream().write(read);
|
||||||
|
}
|
||||||
|
forwardData(_clientSocket, forwardSocket);
|
||||||
|
} else {
|
||||||
|
if (!forwardSocket.isOutputShutdown()) {
|
||||||
|
forwardSocket.shutdownOutput();
|
||||||
|
}
|
||||||
|
if (!_clientSocket.isInputShutdown()) {
|
||||||
|
_clientSocket.shutdownInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
forwardData(_clientSocket, forwardSocket);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
remoteToClient.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO: implement catch
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
forwardSocket.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
outputStreamWriter.write("HTTP/1.1 403 Unauthorized\r\n");
|
||||||
|
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
||||||
|
outputStreamWriter.write("\r\n");
|
||||||
|
outputStreamWriter.flush();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
outputStreamWriter.write("HTTP/1.1 403 Unauthorized\r\n");
|
||||||
|
outputStreamWriter.write("Proxy-agent: MegaBasterd/0.1\r\n");
|
||||||
|
outputStreamWriter.write("\r\n");
|
||||||
|
outputStreamWriter.flush();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO: implement catch
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
try {
|
||||||
|
_clientSocket.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO: implement catch
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,14 +239,14 @@ public class MegaProxyServer extends Thread {
|
|||||||
int next;
|
int next;
|
||||||
readerLoop:
|
readerLoop:
|
||||||
while ((next = socket.getInputStream().read()) != -1) {
|
while ((next = socket.getInputStream().read()) != -1) {
|
||||||
if (previousWasR && next == '\n') {
|
if (_previousWasR && next == '\n') {
|
||||||
previousWasR = false;
|
_previousWasR = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
previousWasR = false;
|
_previousWasR = false;
|
||||||
switch (next) {
|
switch (next) {
|
||||||
case '\r':
|
case '\r':
|
||||||
previousWasR = true;
|
_previousWasR = true;
|
||||||
break readerLoop;
|
break readerLoop;
|
||||||
case '\n':
|
case '\n':
|
||||||
break readerLoop;
|
break readerLoop;
|
||||||
|
@ -44,7 +44,6 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
@ -83,7 +82,7 @@ public final class MiscTools {
|
|||||||
public static final int EXP_BACKOFF_BASE = 2;
|
public static final int EXP_BACKOFF_BASE = 2;
|
||||||
public static final int EXP_BACKOFF_SECS_RETRY = 1;
|
public static final int EXP_BACKOFF_SECS_RETRY = 1;
|
||||||
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 64;
|
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 64;
|
||||||
public static final Object _password_lock = new Object();
|
public static final Object PASS_LOCK = new Object();
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String, Method> REFLECTION_METHOD_CACHE = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<String, Method> REFLECTION_METHOD_CACHE = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@ -117,7 +116,7 @@ public final class MiscTools {
|
|||||||
ge.registerFont(font);
|
ge.registerFont(font);
|
||||||
|
|
||||||
} catch (FontFormatException | IOException ex) {
|
} catch (FontFormatException | IOException ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
@ -396,9 +395,9 @@ public final class MiscTools {
|
|||||||
|
|
||||||
} catch (SecurityException | IllegalArgumentException | NoSuchMethodException ex) {
|
} catch (SecurityException | IllegalArgumentException | NoSuchMethodException ex) {
|
||||||
|
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
System.out.println("REFLECTION METHOD NOT FOUND -> " + method_name + "#" + obj.getClass().toString() + "#" + String.valueOf(params.length));
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} REFLECTION METHOD NOT FOUND -> {1}#{2}#{3}", new Object[]{Thread.currentThread().getName(), method_name, obj.getClass().toString(), String.valueOf(params.length)});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -478,9 +477,9 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (SecurityException | IllegalArgumentException | NoSuchMethodException ex) {
|
} catch (SecurityException | IllegalArgumentException | NoSuchMethodException ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
System.out.println("REFLECTION METHOD NOT FOUND -> " + method_name + "#" + obj.getClass().toString() + "#" + String.valueOf(params.length));
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} REFLECTION METHOD NOT FOUND -> {1}#{2}#{3}", new Object[]{Thread.currentThread().getName(), method_name, obj.getClass().toString(), String.valueOf(params.length)});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -507,7 +506,7 @@ public final class MiscTools {
|
|||||||
SwingUtilities.invokeAndWait(r);
|
SwingUtilities.invokeAndWait(r);
|
||||||
|
|
||||||
} catch (InterruptedException | InvocationTargetException ex) {
|
} catch (InterruptedException | InvocationTargetException ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -525,7 +524,7 @@ public final class MiscTools {
|
|||||||
try {
|
try {
|
||||||
ret = c.call();
|
ret = c.call();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -537,7 +536,7 @@ public final class MiscTools {
|
|||||||
try {
|
try {
|
||||||
ret = futureTask.get();
|
ret = futureTask.get();
|
||||||
} catch (InterruptedException | ExecutionException ex) {
|
} catch (InterruptedException | ExecutionException ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +566,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
String response = null;
|
String response = null;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
|
|
||||||
HttpGet httpget = new HttpGet(new URI("http://tinyurl.com/api-create.php?url=" + URLEncoder.encode(link.trim(), "UTF-8")));
|
HttpGet httpget = new HttpGet(new URI("http://tinyurl.com/api-create.php?url=" + URLEncoder.encode(link.trim(), "UTF-8")));
|
||||||
|
|
||||||
@ -750,7 +749,7 @@ public final class MiscTools {
|
|||||||
((MutableTreeNode) new_root).setUserObject(((DefaultMutableTreeNode) tree_model.getRoot()).getUserObject());
|
((MutableTreeNode) new_root).setUserObject(((DefaultMutableTreeNode) tree_model.getRoot()).getUserObject());
|
||||||
|
|
||||||
} catch (InstantiationException | IllegalAccessException ex) {
|
} catch (InstantiationException | IllegalAccessException ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TreePath path : paths) {
|
for (TreePath path : paths) {
|
||||||
@ -779,7 +778,7 @@ public final class MiscTools {
|
|||||||
((MutableTreeNode) node).setUserObject(((DefaultMutableTreeNode) path_element).getUserObject());
|
((MutableTreeNode) node).setUserObject(((DefaultMutableTreeNode) path_element).getUserObject());
|
||||||
|
|
||||||
} catch (InstantiationException | IllegalAccessException ex) {
|
} catch (InstantiationException | IllegalAccessException ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -920,7 +919,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
boolean url_ok = false;
|
boolean url_ok = false;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
|
|
||||||
HttpGet httpget = new HttpGet(new URI(string_url + "/0-0"));
|
HttpGet httpget = new HttpGet(new URI(string_url + "/0-0"));
|
||||||
|
|
||||||
@ -932,16 +931,13 @@ public final class MiscTools {
|
|||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
System.out.println(ex.getMessage());
|
|
||||||
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return url_ok;
|
return url_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MiscTools() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String checkNewVersion(String folder_node, String folder_key) {
|
public static String checkNewVersion(String folder_node, String folder_key) {
|
||||||
|
|
||||||
String new_version = null;
|
String new_version = null;
|
||||||
@ -957,7 +953,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
HashMap<String, Object> current_node = (HashMap<String, Object>) o;
|
HashMap<String, Object> current_node = (HashMap<String, Object>) o;
|
||||||
|
|
||||||
new_version = MiscTools.findFirstRegex("([0-9\\.]+)\\.run", (String) current_node.get("name"), 1);
|
new_version = findFirstRegex("([0-9\\.]+)\\.run", (String) current_node.get("name"), 1);
|
||||||
|
|
||||||
if (new_version != null && Double.parseDouble(new_version) > Double.parseDouble(VERSION)) {
|
if (new_version != null && Double.parseDouble(new_version) > Double.parseDouble(VERSION)) {
|
||||||
|
|
||||||
@ -971,7 +967,7 @@ public final class MiscTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new_version;
|
return new_version;
|
||||||
@ -1072,7 +1068,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
cmd.append("-cp ").append(ManagementFactory.getRuntimeMXBean().getClassPath()).append(" ");
|
cmd.append("-cp ").append(ManagementFactory.getRuntimeMXBean().getClassPath()).append(" ");
|
||||||
|
|
||||||
cmd.append(MainPanel.class.getName()).append(" ");
|
cmd.append(MiscTools.class.getName()).append(" ");
|
||||||
|
|
||||||
cmd.append(String.valueOf(delay));
|
cmd.append(String.valueOf(delay));
|
||||||
|
|
||||||
@ -1098,7 +1094,7 @@ public final class MiscTools {
|
|||||||
ma = new MegaAPI();
|
ma = new MegaAPI();
|
||||||
|
|
||||||
String password_aes, user_hash;
|
String password_aes, user_hash;
|
||||||
synchronized (_password_lock) {
|
synchronized (PASS_LOCK) {
|
||||||
|
|
||||||
if (main_panel.getMaster_pass_hash() != null) {
|
if (main_panel.getMaster_pass_hash() != null) {
|
||||||
|
|
||||||
@ -1162,4 +1158,7 @@ public final class MiscTools {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MiscTools() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package megabasterd;
|
package megabasterd;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public final class ProgressMeter implements Runnable, SecureSingleThreadNotifiable {
|
public final class ProgressMeter implements Runnable, SecureSingleThreadNotifiable {
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ public final class ProgressMeter implements Runnable, SecureSingleThreadNotifiab
|
|||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
getLogger(ProgressMeter.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public final class ProgressMeter implements Runnable, SecureSingleThreadNotifiab
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
System.out.println("ProgressMeter hello!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} ProgressMeter hello!", Thread.currentThread().getName());
|
||||||
|
|
||||||
while (!_exit || !_transference.getPartialProgress().isEmpty()) {
|
while (!_exit || !_transference.getPartialProgress().isEmpty()) {
|
||||||
Integer reads;
|
Integer reads;
|
||||||
|
@ -6,10 +6,8 @@ import java.util.Arrays;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.Bin2BASE64;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.HashBin;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -214,7 +212,7 @@ public class SetMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
if (new_pass_textfield.getPassword().length > 0) {
|
if (new_pass_textfield.getPassword().length > 0) {
|
||||||
|
|
||||||
_new_pass = CryptTools.PBKDF2HMACSHA256(new String(new_pass_textfield.getPassword()), MiscTools.BASE642Bin(_salt), CryptTools.PBKDF2_ITERATIONS);
|
_new_pass = CryptTools.PBKDF2HMACSHA256(new String(new_pass_textfield.getPassword()), BASE642Bin(_salt), CryptTools.PBKDF2_ITERATIONS);
|
||||||
|
|
||||||
_new_pass_hash = Bin2BASE64(HashBin("SHA-1", _new_pass));
|
_new_pass_hash = Bin2BASE64(HashBin("SHA-1", _new_pass));
|
||||||
}
|
}
|
||||||
@ -237,7 +235,7 @@ public class SetMasterPasswordDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SetMasterPasswordDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,13 +8,13 @@ import java.security.InvalidKeyException;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
@ -25,15 +25,9 @@ import static javax.swing.JOptionPane.showOptionDialog;
|
|||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import static megabasterd.DBTools.insertSettingValueInDB;
|
import static megabasterd.DBTools.*;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.BASE642Bin;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.Bin2BASE64;
|
|
||||||
import static megabasterd.MiscTools.i32a2bin;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
import static megabasterd.MiscTools.truncateText;
|
|
||||||
|
|
||||||
public final class SettingsDialog extends javax.swing.JDialog {
|
public final class SettingsDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
@ -49,11 +43,11 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getDeleted_mega_accounts() {
|
public Set<String> getDeleted_mega_accounts() {
|
||||||
return _deleted_mega_accounts;
|
return Collections.unmodifiableSet(_deleted_mega_accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getDeleted_elc_accounts() {
|
public Set<String> getDeleted_elc_accounts() {
|
||||||
return _deleted_elc_accounts;
|
return Collections.unmodifiableSet(_deleted_elc_accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRemember_master_pass() {
|
public boolean isRemember_master_pass() {
|
||||||
@ -321,9 +315,9 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
pass = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("password")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
pass = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("password")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] new_row_data = {(String) pair.getKey(), pass};
|
String[] new_row_data = {(String) pair.getKey(), pass};
|
||||||
@ -344,9 +338,9 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
apikey = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("apikey")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
apikey = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("apikey")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] new_row_data = {(String) pair.getKey(), user, apikey};
|
String[] new_row_data = {(String) pair.getKey(), user, apikey};
|
||||||
@ -1238,7 +1232,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private void cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_buttonActionPerformed
|
private void cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_buttonActionPerformed
|
||||||
|
|
||||||
this.setVisible(false);
|
setVisible(false);
|
||||||
}//GEN-LAST:event_cancel_buttonActionPerformed
|
}//GEN-LAST:event_cancel_buttonActionPerformed
|
||||||
|
|
||||||
private void ok_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok_buttonActionPerformed
|
private void ok_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ok_buttonActionPerformed
|
||||||
@ -1380,7 +1374,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
apikey = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin(apikey), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
apikey = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin(apikey), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1462,7 +1456,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(i32a2bin(ma.getPassword_aes()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
password_aes = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(i32a2bin(ma.getPassword_aes()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(MiscTools.UrlBASE642Bin(ma.getUser_hash()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
user_hash = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(UrlBASE642Bin(ma.getUser_hash()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
}
|
}
|
||||||
|
|
||||||
DBTools.insertMegaAccount(email, password, password_aes, user_hash);
|
DBTools.insertMegaAccount(email, password, password_aes, user_hash);
|
||||||
@ -1470,7 +1464,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
email_error.add(email);
|
email_error.add(email);
|
||||||
getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -1486,7 +1480,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
password = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin(password), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
password = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin(password), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1509,7 +1503,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
password_aes = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(i32a2bin(ma.getPassword_aes()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
password_aes = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(i32a2bin(ma.getPassword_aes()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
user_hash = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(MiscTools.UrlBASE642Bin(ma.getUser_hash()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
user_hash = Bin2BASE64(CryptTools.aes_cbc_encrypt_pkcs7(UrlBASE642Bin(ma.getUser_hash()), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
}
|
}
|
||||||
|
|
||||||
DBTools.insertMegaAccount(email, password, password_aes, user_hash);
|
DBTools.insertMegaAccount(email, password, password_aes, user_hash);
|
||||||
@ -1517,7 +1511,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
email_error.add(email);
|
email_error.add(email);
|
||||||
getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1561,15 +1555,15 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
this.setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_ok_buttonActionPerformed
|
}//GEN-LAST:event_ok_buttonActionPerformed
|
||||||
|
|
||||||
@ -1763,7 +1757,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1838,9 +1832,9 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
pass = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("password")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
pass = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("password")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] new_row_data = {(String) pair.getKey(), pass};
|
String[] new_row_data = {(String) pair.getKey(), pass};
|
||||||
@ -1861,9 +1855,9 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
apikey = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("apikey")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
apikey = new String(CryptTools.aes_cbc_decrypt_pkcs7(BASE642Bin((String) data.get("apikey")), _main_panel.getMaster_pass(), CryptTools.AES_ZERO_IV));
|
||||||
|
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | InvalidAlgorithmParameterException | IllegalBlockSizeException | BadPaddingException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] new_row_data = {(String) pair.getKey(), user, apikey};
|
String[] new_row_data = {(String) pair.getKey(), user, apikey};
|
||||||
@ -1930,7 +1924,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
try {
|
try {
|
||||||
DBTools.deleteMegaAccount((String) pair.getKey());
|
DBTools.deleteMegaAccount((String) pair.getKey());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1939,7 +1933,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
try {
|
try {
|
||||||
DBTools.deleteELCAccount((String) pair.getKey());
|
DBTools.deleteELCAccount((String) pair.getKey());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1958,7 +1952,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
|||||||
_main_panel.getElc_accounts().clear();
|
_main_panel.getElc_accounts().clear();
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
Logger.getLogger(SettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -17,12 +17,11 @@ public final class SqliteSingleton {
|
|||||||
|
|
||||||
public static final int VALIDATION_TIMEOUT = 15;
|
public static final int VALIDATION_TIMEOUT = 15;
|
||||||
|
|
||||||
private final ConcurrentHashMap<Thread, Connection> _connections_map;
|
|
||||||
|
|
||||||
public static SqliteSingleton getInstance() {
|
public static SqliteSingleton getInstance() {
|
||||||
|
|
||||||
return LazyHolder.INSTANCE;
|
return LazyHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
private final ConcurrentHashMap<Thread, Connection> _connections_map;
|
||||||
|
|
||||||
private SqliteSingleton() {
|
private SqliteSingleton() {
|
||||||
|
|
||||||
@ -45,7 +44,7 @@ public final class SqliteSingleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (ClassNotFoundException | SQLException ex) {
|
} catch (ClassNotFoundException | SQLException ex) {
|
||||||
getLogger(SqliteSingleton.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
|
@ -11,8 +11,8 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MainPanel.THROTTLE_SLICE_SIZE;
|
import static megabasterd.MiscTools.*;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
@ -34,16 +34,16 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
_exit = false;
|
_exit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExit(boolean _exit) {
|
public void setExit(boolean exit) {
|
||||||
this._exit = _exit;
|
_exit = exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " Worker [" + _id + "]: let's do some work!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: let''s do some work!", new Object[]{Thread.currentThread().getName(), _id});
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = MiscTools.getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
|
|
||||||
String url = _chunkwriter.getUrl();
|
String url = _chunkwriter.getUrl();
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
|
|
||||||
while (!_exit && !_chunkwriter.isExit() && _chunkwriter.getChunk_queue().size() >= StreamChunkWriter.BUFFER_CHUNKS_SIZE) {
|
while (!_exit && !_chunkwriter.isExit() && _chunkwriter.getChunk_queue().size() >= StreamChunkWriter.BUFFER_CHUNKS_SIZE) {
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " Worker [" + _id + "]: El búffer de chunks está lleno. Me duermo.");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: Chunk buffer is full. I pause myself.", new Object[]{Thread.currentThread().getName(), _id});
|
||||||
|
|
||||||
_chunkwriter.secureWait();
|
_chunkwriter.secureWait();
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
|
|
||||||
StreamChunk chunk_stream = new StreamChunk(offset, _chunkwriter.calculateChunkSize(offset), url);
|
StreamChunk chunk_stream = new StreamChunk(offset, _chunkwriter.calculateChunkSize(offset), url);
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " Worker [" + _id + "]: offset: " + offset + " size: " + chunk_stream.getSize());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: offset: {2} size: {3}", new Object[]{Thread.currentThread().getName(), _id, offset, chunk_stream.getSize()});
|
||||||
|
|
||||||
HttpGet httpget = new HttpGet(new URI(chunk_stream.getUrl()));
|
HttpGet httpget = new HttpGet(new URI(chunk_stream.getUrl()));
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
|
|
||||||
if (http_status != HttpStatus.SC_OK) {
|
if (http_status != HttpStatus.SC_OK) {
|
||||||
|
|
||||||
System.out.println("Failed : HTTP error code : " + http_status);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), http_status});
|
||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " Worker [" + _id + "] has downloaded chunk [" + chunk_stream.getOffset() + "]!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}] has downloaded chunk [{2}]!", new Object[]{Thread.currentThread().getName(), _id, chunk_stream.getOffset()});
|
||||||
|
|
||||||
_chunkwriter.getChunk_queue().put(chunk_stream.getOffset(), chunk_stream);
|
_chunkwriter.getChunk_queue().put(chunk_stream.getOffset(), chunk_stream);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
getLogger(ChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -141,16 +141,14 @@ public class StreamChunkDownloader implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
getLogger(ChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (ChunkInvalidException ex) {
|
} catch (ChunkInvalidException | InterruptedException ex) {
|
||||||
Logger.getLogger(StreamChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
Logger.getLogger(StreamChunkDownloader.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_chunkwriter.secureNotifyAll();
|
_chunkwriter.secureNotifyAll();
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " Worker [" + _id + "]: bye bye");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Worker [{1}]: bye bye", new Object[]{Thread.currentThread().getName(), _id});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@ package megabasterd;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.io.PipedOutputStream;
|
import java.io.PipedOutputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static megabasterd.MiscTools.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -54,7 +54,7 @@ public class StreamChunkWriter implements Runnable, SecureMultiThreadNotifiable
|
|||||||
|
|
||||||
public String getUrl() throws IOException, InterruptedException {
|
public String getUrl() throws IOException, InterruptedException {
|
||||||
|
|
||||||
if (!MiscTools.checkMegaDownloadUrl(_url)) {
|
if (!checkMegaDownloadUrl(_url)) {
|
||||||
|
|
||||||
_url = _server.getMegaFileDownloadUrl(_link, (String) _file_info.get("pass_hash"), (String) _file_info.get("noexpiretoken"), _mega_account);
|
_url = _server.getMegaFileDownloadUrl(_link, (String) _file_info.get("pass_hash"), (String) _file_info.get("noexpiretoken"), _mega_account);
|
||||||
_file_info.put("url", _url);
|
_file_info.put("url", _url);
|
||||||
@ -77,7 +77,7 @@ public class StreamChunkWriter implements Runnable, SecureMultiThreadNotifiable
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
System.out.println("StreamChunkWriter: let's do some work! Start: " + _start_offset + " End: " + _end_offset);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} StreamChunkWriter: let''s do some work! Start: {1} End: {2}", new Object[]{Thread.currentThread().getName(), _start_offset, _end_offset});
|
||||||
|
|
||||||
while (!_exit && _bytes_written < _end_offset) {
|
while (!_exit && _bytes_written < _end_offset) {
|
||||||
|
|
||||||
@ -102,13 +102,13 @@ public class StreamChunkWriter implements Runnable, SecureMultiThreadNotifiable
|
|||||||
|
|
||||||
secureNotifyAll();
|
secureNotifyAll();
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " StreamChunkWriter ha escrito " + (_bytes_written) + " / " + _end_offset + " ...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} StreamChunkWriter ha escrito {1} / {2} ...", new Object[]{Thread.currentThread().getName(), _bytes_written, _end_offset});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_exit && _bytes_written < _end_offset) {
|
if (!_exit && _bytes_written < _end_offset) {
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " StreamChunkWriter waiting for offset " + _bytes_written + "...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} StreamChunkWriter waiting for offset {1}...", new Object[]{Thread.currentThread().getName(), _bytes_written});
|
||||||
|
|
||||||
secureWait();
|
secureWait();
|
||||||
}
|
}
|
||||||
@ -116,20 +116,20 @@ public class StreamChunkWriter implements Runnable, SecureMultiThreadNotifiable
|
|||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
System.out.println(ex.getMessage());
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_pipeos.close();
|
_pipeos.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Logger.getLogger(StreamChunkWriter.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit = true;
|
_exit = true;
|
||||||
|
|
||||||
secureNotifyAll();
|
secureNotifyAll();
|
||||||
|
|
||||||
System.out.println(Thread.currentThread().getName() + " StreamChunkWriter: bye bye");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} StreamChunkWriter: bye bye", Thread.currentThread().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long nextOffset() {
|
public long nextOffset() {
|
||||||
@ -149,8 +149,8 @@ public class StreamChunkWriter implements Runnable, SecureMultiThreadNotifiable
|
|||||||
return offset <= _end_offset ? (Math.min(CHUNK_SIZE, _end_offset - offset + 1)) : -1;
|
return offset <= _end_offset ? (Math.min(CHUNK_SIZE, _end_offset - offset + 1)) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExit(boolean _exit) {
|
public void setExit(boolean exit) {
|
||||||
this._exit = _exit;
|
_exit = exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -170,7 +170,7 @@ public class StreamChunkWriter implements Runnable, SecureMultiThreadNotifiable
|
|||||||
try {
|
try {
|
||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(StreamThrottlerSupervisor.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -98,7 +97,7 @@ public final class StreamThrottlerSupervisor implements Runnable, SecureMultiThr
|
|||||||
try {
|
try {
|
||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(StreamThrottlerSupervisor.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +172,7 @@ public final class StreamThrottlerSupervisor implements Runnable, SecureMultiThr
|
|||||||
try {
|
try {
|
||||||
_timer_lock.wait();
|
_timer_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
Logger.getLogger(StreamThrottlerSupervisor.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,12 @@ import java.awt.event.WindowEvent;
|
|||||||
import static java.awt.event.WindowEvent.WINDOW_CLOSING;
|
import static java.awt.event.WindowEvent.WINDOW_CLOSING;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.extractFirstMegaLinkFromString;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.extractStringFromClipboardContents;
|
|
||||||
import static megabasterd.MiscTools.findFirstRegex;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -183,11 +178,11 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (MiscTools.findFirstRegex("://enc", link, 0) != null) {
|
if (findFirstRegex("://enc", link, 0) != null) {
|
||||||
|
|
||||||
link = CryptTools.decryptMegaDownloaderLink(link);
|
link = CryptTools.decryptMegaDownloaderLink(link);
|
||||||
|
|
||||||
} else if (MiscTools.findFirstRegex("://elc", link, 0) != null) {
|
} else if (findFirstRegex("://elc", link, 0) != null) {
|
||||||
|
|
||||||
HashSet links = CryptTools.decryptELC(link, ((MainPanelView) tthis.getParent()).getMain_panel());
|
HashSet links = CryptTools.decryptELC(link, ((MainPanelView) tthis.getParent()).getMain_panel());
|
||||||
|
|
||||||
@ -201,14 +196,14 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
|
|
||||||
error = true;
|
error = true;
|
||||||
|
|
||||||
getLogger(StreamerDialog.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
String data;
|
String data;
|
||||||
|
|
||||||
if (findFirstRegex("://mega(\\.co)?\\.nz/#[^fF]", link, 0) != null || findFirstRegex("https?://[^/]+/![^!]+![0-9a-fA-F]+", link, 0) != null) {
|
if (findFirstRegex("://mega(\\.co)?\\.nz/#[^fF]", link, 0) != null || findFirstRegex("https?://[^/]+/![^!]+![0-9a-fA-F]+", link, 0) != null) {
|
||||||
|
|
||||||
data = MiscTools.Bin2UrlBASE64(((_last_selected_account != null ? _last_selected_account : "") + "|" + link).getBytes());
|
data = Bin2UrlBASE64(((_last_selected_account != null ? _last_selected_account : "") + "|" + link).getBytes());
|
||||||
|
|
||||||
stream_link = "http://localhost:1337/video/" + data;
|
stream_link = "http://localhost:1337/video/" + data;
|
||||||
|
|
||||||
@ -235,8 +230,8 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
_mainPanelView.getMain_panel().getClipboardspy().detachObserver((ClipboardChangeObserver) tthis);
|
_mainPanelView.getMain_panel().getClipboardspy().detachObserver((ClipboardChangeObserver) tthis);
|
||||||
MiscTools.copyTextToClipboard(stream_link);
|
copyTextToClipboard(stream_link);
|
||||||
JOptionPane.showMessageDialog(tthis, "Streaming link was copied to clipboard!\n(Remember to keep MegaBasterd running in background while playing)");
|
JOptionPane.showMessageDialog(tthis, "Streaming link was copied to clipboard!\nRemember to keep MegaBasterd running in background while playing content. (I recommend to use MPLAYER)");
|
||||||
dispose();
|
dispose();
|
||||||
getParent().dispatchEvent(new WindowEvent(tthis, WINDOW_CLOSING));
|
getParent().dispatchEvent(new WindowEvent(tthis, WINDOW_CLOSING));
|
||||||
}
|
}
|
||||||
@ -265,16 +260,16 @@ public final class StreamerDialog extends javax.swing.JDialog implements Clipboa
|
|||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MiscTools.checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
checkMegaAccountLoginAndShowMasterPassDialog(_main_panel, tthis, email);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
||||||
_last_selected_account = "";
|
_last_selected_account = "";
|
||||||
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 1);
|
swingReflectionInvoke("setSelectedIndex", use_mega_account_down_combobox, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
swingReflectionInvokeAndWait("setEnabled", ((StreamerDialog) tthis).getUse_mega_account_down_combobox(), true);
|
swingReflectionInvokeAndWait("setEnabled", tthis.getUse_mega_account_down_combobox(), true);
|
||||||
|
|
||||||
swingReflectionInvokeAndWaitForReturn("setEnabled", ((StreamerDialog) tthis).getDance_button(), true);
|
swingReflectionInvokeAndWaitForReturn("setEnabled", tthis.getDance_button(), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -121,8 +120,8 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMax_running_trans(int _max_running_trans) {
|
public void setMax_running_trans(int max_running_trans) {
|
||||||
this._max_running_trans = _max_running_trans;
|
_max_running_trans = max_running_trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -144,7 +143,7 @@ abstract public class TransferenceManager implements Runnable, SecureSingleThrea
|
|||||||
try {
|
try {
|
||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(TransferenceManager.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,18 +14,9 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.BASE642Bin;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.Bin2BASE64;
|
|
||||||
import static megabasterd.MiscTools.HashString;
|
|
||||||
import static megabasterd.MiscTools.bin2i32a;
|
|
||||||
import static megabasterd.MiscTools.formatBytes;
|
|
||||||
import static megabasterd.MiscTools.i32a2bin;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWaitForReturn;
|
|
||||||
import static megabasterd.MiscTools.truncateText;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -340,7 +331,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +404,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,12 +569,12 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
System.out.println("Lanzando chunkuploader desde startslot()...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Starting chunkuploader from startslot()...", Thread.currentThread().getName());
|
||||||
|
|
||||||
_thread_pool.execute(c);
|
_thread_pool.execute(c);
|
||||||
|
|
||||||
} catch (java.util.concurrent.RejectedExecutionException e) {
|
} catch (java.util.concurrent.RejectedExecutionException e) {
|
||||||
System.out.println(e.getMessage());
|
Logger.getLogger(getClass().getName()).log(Level.INFO, e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -640,7 +631,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
System.out.println("Uploader hello!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Uploader hello!", Thread.currentThread().getName());
|
||||||
|
|
||||||
swingReflectionInvoke("setVisible", getView().getClose_button(), false);
|
swingReflectionInvoke("setVisible", getView().getClose_button(), false);
|
||||||
|
|
||||||
@ -655,7 +646,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
|
|
||||||
DBTools.updateUploadUrl(_file_name, _ma.getEmail(), _ul_url);
|
DBTools.updateUploadUrl(_file_name, _ma.getEmail(), _ul_url);
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +690,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
|
|
||||||
_chunkworkers.add(c);
|
_chunkworkers.add(c);
|
||||||
|
|
||||||
System.out.println("Lanzando chunkuploader" + t + " ...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Starting chunkuploader{1} ...", new Object[]{Thread.currentThread().getName(), t});
|
||||||
|
|
||||||
_thread_pool.execute(c);
|
_thread_pool.execute(c);
|
||||||
}
|
}
|
||||||
@ -736,11 +727,9 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
|
|
||||||
secureWait();
|
secureWait();
|
||||||
|
|
||||||
System.out.println("Uploader llamando a shutdown del pool...");
|
|
||||||
|
|
||||||
_thread_pool.shutdown();
|
_thread_pool.shutdown();
|
||||||
|
|
||||||
System.out.println("Chunkuploaders finished!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Chunkuploaders finished!", Thread.currentThread().getName());
|
||||||
|
|
||||||
getProgress_meter().setExit(true);
|
getProgress_meter().setExit(true);
|
||||||
|
|
||||||
@ -748,22 +737,22 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
System.out.println("Esperando a que todos los hilos terminen...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0}Waiting for all threads to finish...", Thread.currentThread().getName());
|
||||||
|
|
||||||
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
|
_thread_pool.awaitTermination(MAX_WAIT_WORKERS_SHUTDOWN, TimeUnit.SECONDS);
|
||||||
|
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_thread_pool.isTerminated()) {
|
if (!_thread_pool.isTerminated()) {
|
||||||
|
|
||||||
System.out.println("Cerrando thread pool a lo mecagüen...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Closing thread pool in ''mecag\u00fcen'' style...", Thread.currentThread().getName());
|
||||||
|
|
||||||
_thread_pool.shutdownNow();
|
_thread_pool.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Uploader thread pool finished!");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Uploader thread pool finished!", Thread.currentThread().getName());
|
||||||
|
|
||||||
getMain_panel().getGlobal_up_speed().detachTransference(this);
|
getMain_panel().getGlobal_up_speed().detachTransference(this);
|
||||||
|
|
||||||
@ -787,8 +776,6 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
|
|
||||||
upload_res = _ma.finishUploadFile(f.getName(), ul_key, node_key, _file_meta_mac, _completion_handle, _parent_node, i32a2bin(_ma.getMaster_key()), _root_node, _share_key);
|
upload_res = _ma.finishUploadFile(f.getName(), ul_key, node_key, _file_meta_mac, _completion_handle, _parent_node, i32a2bin(_ma.getMaster_key()), _root_node, _share_key);
|
||||||
|
|
||||||
System.out.println(upload_res);
|
|
||||||
|
|
||||||
List files = (List) upload_res.get("f");
|
List files = (List) upload_res.get("f");
|
||||||
|
|
||||||
_fid = (String) ((Map<String, Object>) files.get(0)).get("h");
|
_fid = (String) ((Map<String, Object>) files.get(0)).get("h");
|
||||||
@ -802,7 +789,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
swingReflectionInvoke("setEnabled", getView().getFile_link_button(), true);
|
swingReflectionInvoke("setEnabled", getView().getFile_link_button(), true);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
printStatusOK(_exit_message);
|
printStatusOK(_exit_message);
|
||||||
@ -879,7 +866,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
try {
|
try {
|
||||||
DBTools.deleteUpload(_file_name, _ma.getEmail());
|
DBTools.deleteUpload(_file_name, _ma.getEmail());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -901,7 +888,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
swingReflectionInvoke("setVisible", getView().getRestart_button(), true);
|
swingReflectionInvoke("setVisible", getView().getRestart_button(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Uploader BYE BYE");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Uploader BYE BYE", Thread.currentThread().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pause_worker() {
|
public void pause_worker() {
|
||||||
@ -988,7 +975,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
try {
|
try {
|
||||||
DBTools.deleteUpload(_file_name, _ma.getEmail());
|
DBTools.deleteUpload(_file_name, _ma.getEmail());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
getMain_panel().getUpload_manager().getTransference_running_list().remove(this);
|
getMain_panel().getUpload_manager().getTransference_running_list().remove(this);
|
||||||
|
@ -6,16 +6,12 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
import static megabasterd.CryptTools.genCrypter;
|
import static megabasterd.CryptTools.*;
|
||||||
import static megabasterd.MiscTools.Bin2BASE64;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.HashString;
|
|
||||||
import static megabasterd.MiscTools.bin2i32a;
|
|
||||||
import static megabasterd.MiscTools.i32a2bin;
|
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -61,7 +57,7 @@ public final class UploadMACGenerator implements Runnable, SecureSingleThreadNot
|
|||||||
_secure_notify_lock.wait();
|
_secure_notify_lock.wait();
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
_exit = true;
|
_exit = true;
|
||||||
getLogger(UploadMACGenerator.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +153,7 @@ public final class UploadMACGenerator implements Runnable, SecureSingleThreadNot
|
|||||||
file_mac = bin2i32a(cryptor.doFinal(i32a2bin(file_mac)));
|
file_mac = bin2i32a(cryptor.doFinal(i32a2bin(file_mac)));
|
||||||
|
|
||||||
} catch (IOException | IllegalBlockSizeException | BadPaddingException ex) {
|
} catch (IOException | IllegalBlockSizeException | BadPaddingException ex) {
|
||||||
getLogger(UploadMACGenerator.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
_bytes_read += chunk.getSize();
|
_bytes_read += chunk.getSize();
|
||||||
@ -173,7 +169,7 @@ public final class UploadMACGenerator implements Runnable, SecureSingleThreadNot
|
|||||||
|
|
||||||
temp_file_data = (String.valueOf(_bytes_read) + "|" + Bin2BASE64(i32a2bin(file_mac)));
|
temp_file_data = (String.valueOf(_bytes_read) + "|" + Bin2BASE64(i32a2bin(file_mac)));
|
||||||
|
|
||||||
System.out.println("Macgenerator -> " + temp_file_data + " " + _upload.calculateLastUploadedChunk(_bytes_read) + " " + _last_chunk_id_read);
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Macgenerator -> {1} {2} {3}", new Object[]{Thread.currentThread().getName(), temp_file_data, _upload.calculateLastUploadedChunk(_bytes_read), _last_chunk_id_read});
|
||||||
|
|
||||||
temp_file_out = new FileOutputStream(temp_file);
|
temp_file_out = new FileOutputStream(temp_file);
|
||||||
|
|
||||||
@ -185,7 +181,7 @@ public final class UploadMACGenerator implements Runnable, SecureSingleThreadNot
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!_exit && (!_upload.isStopped() || !_upload.getChunkworkers().isEmpty()) && (_bytes_read < _upload.getFile_size() || (_upload.getFile_size() == 0 && _last_chunk_id_read < 1))) {
|
if (!_exit && (!_upload.isStopped() || !_upload.getChunkworkers().isEmpty()) && (_bytes_read < _upload.getFile_size() || (_upload.getFile_size() == 0 && _last_chunk_id_read < 1))) {
|
||||||
System.out.println(_bytes_read + "/" + _upload.getFile_size() + " METAMAC wait...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} {1}/{2} METAMAC wait...", new Object[]{Thread.currentThread().getName(), _bytes_read, _upload.getFile_size()});
|
||||||
secureWait();
|
secureWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,10 +197,10 @@ public final class UploadMACGenerator implements Runnable, SecureSingleThreadNot
|
|||||||
|
|
||||||
_upload.secureNotify();
|
_upload.secureNotify();
|
||||||
|
|
||||||
System.out.println("MAC GENERATOR BYE BYE...");
|
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} MAC GENERATOR BYE BYE...", Thread.currentThread().getName());
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
getLogger(UploadMACGenerator.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import static java.util.logging.Level.SEVERE;
|
import static java.util.logging.Level.SEVERE;
|
||||||
import static java.util.logging.Logger.getLogger;
|
import java.util.logging.Logger;
|
||||||
import static megabasterd.MiscTools.HashString;
|
import static megabasterd.MiscTools.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -89,7 +89,7 @@ public final class UploadManager extends TransferenceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (UnsupportedEncodingException | NoSuchAlgorithmException ex) {
|
} catch (UnsupportedEncodingException | NoSuchAlgorithmException ex) {
|
||||||
getLogger(UploadManager.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ public final class UploadManager extends TransferenceManager {
|
|||||||
try {
|
try {
|
||||||
DBTools.deleteUploads(delete_up.toArray(new String[delete_up.size()][]));
|
DBTools.deleteUploads(delete_up.toArray(new String[delete_up.size()][]));
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
getLogger(UploadManager.class.getName()).log(SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
secureNotify();
|
secureNotify();
|
||||||
|
@ -7,11 +7,9 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import static megabasterd.MainPanel.THREAD_POOL;
|
import static megabasterd.MainPanel.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvoke;
|
import static megabasterd.MiscTools.*;
|
||||||
import static megabasterd.MiscTools.swingReflectionInvokeAndWait;
|
import static megabasterd.Transference.*;
|
||||||
import static megabasterd.Transference.MAX_WORKERS;
|
|
||||||
import static megabasterd.Transference.MIN_WORKERS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -213,7 +211,7 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
});
|
});
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
@ -329,7 +327,7 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
|
|
||||||
folder_link_button.setText("Please wait...");
|
folder_link_button.setText("Please wait...");
|
||||||
|
|
||||||
MiscTools.copyTextToClipboard(_upload.getFolder_link());
|
copyTextToClipboard(_upload.getFolder_link());
|
||||||
|
|
||||||
folder_link_button.setText("Copy folder link");
|
folder_link_button.setText("Copy folder link");
|
||||||
|
|
||||||
@ -344,7 +342,7 @@ public final class UploadView extends javax.swing.JPanel implements Transference
|
|||||||
|
|
||||||
file_link_button.setText("Please wait...");
|
file_link_button.setText("Please wait...");
|
||||||
|
|
||||||
MiscTools.copyTextToClipboard(_upload.getFile_link());
|
copyTextToClipboard(_upload.getFile_link());
|
||||||
|
|
||||||
file_link_button.setText("Copy file link");
|
file_link_button.setText("Copy file link");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user