mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-29 21:10:18 +02:00
2.43
This commit is contained in:
parent
05efe13751
commit
19507d8b84
@ -95,7 +95,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
int reads, conta_error, http_status;
|
int reads, conta_error, http_status;
|
||||||
InputStream is;
|
InputStream is;
|
||||||
boolean error;
|
boolean error, error509;
|
||||||
String current_proxy = null;
|
String current_proxy = null;
|
||||||
CloseableHttpClient httpclient = null;
|
CloseableHttpClient httpclient = null;
|
||||||
|
|
||||||
@ -106,17 +106,18 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
error509 = false;
|
||||||
|
|
||||||
while (!_exit && !_download.isStopped()) {
|
while (!_exit && !_download.isStopped()) {
|
||||||
|
|
||||||
if (_download.isUse_smart_proxy() && !MainPanel.isUse_smart_proxy()) {
|
if (_download.isUse_smart_proxy() && !_download.getMain_panel().isUse_smart_proxy()) {
|
||||||
|
|
||||||
_download.setUse_smart_proxy(false);
|
_download.setUse_smart_proxy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpclient == null || error || (MainPanel.isUse_smart_proxy() && _download.isUse_smart_proxy())) {
|
if (httpclient == null || error || (_download.getMain_panel().isUse_smart_proxy() && _download.isUse_smart_proxy())) {
|
||||||
|
|
||||||
if (error && !_download.isUse_smart_proxy()) {
|
if (error509 && !_download.isUse_smart_proxy()) {
|
||||||
_download.setUse_smart_proxy(true);
|
_download.setUse_smart_proxy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +130,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
_download.getExcluded_proxies().add(current_proxy);
|
_download.getExcluded_proxies().add(current_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_proxy = MainPanel.getProxy_manager().getRandomProxy(_download.getExcluded_proxies());
|
current_proxy = _download.getMain_panel().getProxy_manager().getRandomProxy(_download.getExcluded_proxies());
|
||||||
|
|
||||||
if (httpclient != null) {
|
if (httpclient != null) {
|
||||||
try {
|
try {
|
||||||
@ -157,6 +158,8 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
HttpGet httpget = new HttpGet(new URI(chunk.getUrl()));
|
HttpGet httpget = new HttpGet(new URI(chunk.getUrl()));
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
|
error509 = false;
|
||||||
|
|
||||||
try (CloseableHttpResponse httpresponse = httpclient.execute(httpget)) {
|
try (CloseableHttpResponse httpresponse = httpclient.execute(httpget)) {
|
||||||
|
|
||||||
@ -168,8 +171,13 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
if (http_status != HttpStatus.SC_OK) {
|
if (http_status != HttpStatus.SC_OK) {
|
||||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), 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;
|
||||||
|
|
||||||
|
if(http_status == 509)
|
||||||
|
{
|
||||||
|
error509 = true;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -218,7 +226,7 @@ public class ChunkDownloader implements Runnable, SecureSingleThreadNotifiable {
|
|||||||
|
|
||||||
_download.getView().updateSlotsStatus();
|
_download.getView().updateSlotsStatus();
|
||||||
|
|
||||||
if (!MainPanel.isUse_smart_proxy()) {
|
if (!_download.getMain_panel().isUse_smart_proxy()) {
|
||||||
Thread.sleep(getWaitTimeExpBackOff(conta_error) * 1000);
|
Thread.sleep(getWaitTimeExpBackOff(conta_error) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import static megabasterd.MainPanel.*;
|
import static megabasterd.MainPanel.*;
|
||||||
@ -31,8 +30,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
String current_proxy = null;
|
String current_proxy = null;
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
int reads, conta_error, http_status = 200;
|
int reads, conta_error, http_status = 200;
|
||||||
boolean error;
|
boolean error,error509;
|
||||||
ArrayList<String> excluded = new ArrayList<>();
|
|
||||||
HttpGet httpget = null;
|
HttpGet httpget = null;
|
||||||
CloseableHttpResponse httpresponse = null;
|
CloseableHttpResponse httpresponse = null;
|
||||||
CloseableHttpClient httpclient = null;
|
CloseableHttpClient httpclient = null;
|
||||||
@ -43,19 +41,21 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
conta_error = 0;
|
conta_error = 0;
|
||||||
|
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
|
error509 = false;
|
||||||
|
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
|
|
||||||
while (!isExit() && !getDownload().isStopped()) {
|
while (!isExit() && !getDownload().isStopped()) {
|
||||||
|
|
||||||
if (this.getDownload().isUse_smart_proxy() && !MainPanel.isUse_smart_proxy()) {
|
if (this.getDownload().isUse_smart_proxy() && !this.getDownload().getMain_panel().isUse_smart_proxy()) {
|
||||||
|
|
||||||
this.getDownload().setUse_smart_proxy(false);
|
this.getDownload().setUse_smart_proxy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (httpclient == null || worker_url == null || error || (MainPanel.isUse_smart_proxy() && this.getDownload().isUse_smart_proxy())) {
|
if (httpclient == null || worker_url == null || error || (this.getDownload().getMain_panel().isUse_smart_proxy() && this.getDownload().isUse_smart_proxy())) {
|
||||||
|
|
||||||
if (error && !this.getDownload().isUse_smart_proxy()) {
|
if (error509 && !this.getDownload().isUse_smart_proxy()) {
|
||||||
this.getDownload().setUse_smart_proxy(true);
|
this.getDownload().setUse_smart_proxy(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} Worker mono: excluding proxy -> {1}", new Object[]{Thread.currentThread().getName(), current_proxy});
|
Logger.getLogger(getClass().getName()).log(Level.WARNING, "{0} Worker mono: excluding proxy -> {1}", new Object[]{Thread.currentThread().getName(), current_proxy});
|
||||||
|
|
||||||
excluded.add(current_proxy);
|
this.getDownload().getExcluded_proxies().add(current_proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_proxy = MainPanel.getProxy_manager().getRandomProxy(excluded);
|
current_proxy = this.getDownload().getMain_panel().getProxy_manager().getRandomProxy(this.getDownload().getExcluded_proxies());
|
||||||
|
|
||||||
if (httpclient != null) {
|
if (httpclient != null) {
|
||||||
try {
|
try {
|
||||||
@ -115,6 +115,11 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
Logger.getLogger(getClass().getName()).log(Level.INFO, "{0} Failed : HTTP error code : {1}", new Object[]{Thread.currentThread().getName(), 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;
|
||||||
|
|
||||||
|
if(http_status == 509)
|
||||||
|
{
|
||||||
|
error509 = true;
|
||||||
|
}
|
||||||
|
|
||||||
getDownload().rejectChunkId(chunk.getId());
|
getDownload().rejectChunkId(chunk.getId());
|
||||||
|
|
||||||
@ -124,7 +129,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
setError_wait(true);
|
setError_wait(true);
|
||||||
|
|
||||||
if (!MainPanel.isUse_smart_proxy()) {
|
if (!this.getDownload().getMain_panel().isUse_smart_proxy()) {
|
||||||
Thread.sleep(getWaitTimeExpBackOff(conta_error) * 1000);
|
Thread.sleep(getWaitTimeExpBackOff(conta_error) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +178,7 @@ public class ChunkDownloaderMono extends ChunkDownloader {
|
|||||||
|
|
||||||
setError_wait(true);
|
setError_wait(true);
|
||||||
|
|
||||||
if (!MainPanel.isUse_smart_proxy()) {
|
if (!this.getDownload().getMain_panel().isUse_smart_proxy()) {
|
||||||
Thread.sleep(getWaitTimeExpBackOff(conta_error) * 1000);
|
Thread.sleep(getWaitTimeExpBackOff(conta_error) * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
private final MegaAPI _ma;
|
private final MegaAPI _ma;
|
||||||
private volatile boolean _use_smart_proxy;
|
private volatile boolean _use_smart_proxy;
|
||||||
private volatile int _last_proxy_list_hashcode;
|
private volatile int _last_proxy_list_hashcode;
|
||||||
private final ArrayList<String> _excluded_proxies;
|
private final ConcurrentLinkedQueue<String> _excluded_proxies;
|
||||||
private final Object _watchdog_lock;
|
private final Object _watchdog_lock;
|
||||||
|
|
||||||
public Download(MainPanel main_panel, MegaAPI ma, String url, String download_path, String file_name, String file_key, Long file_size, String file_pass, String file_noexpire, boolean use_slots, int slots, boolean restart) {
|
public Download(MainPanel main_panel, MegaAPI ma, String url, String download_path, String file_name, String file_key, Long file_size, String file_pass, String file_noexpire, boolean use_slots, int slots, boolean restart) {
|
||||||
@ -122,7 +122,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
_use_slots = use_slots;
|
_use_slots = use_slots;
|
||||||
_use_smart_proxy = false;
|
_use_smart_proxy = false;
|
||||||
_watchdog_lock = new Object();
|
_watchdog_lock = new Object();
|
||||||
_excluded_proxies = new ArrayList<>();
|
_excluded_proxies = new ConcurrentLinkedQueue<>();
|
||||||
_last_proxy_list_hashcode = -1;
|
_last_proxy_list_hashcode = -1;
|
||||||
_slots = slots;
|
_slots = slots;
|
||||||
_restart = restart;
|
_restart = restart;
|
||||||
@ -134,7 +134,6 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
_partialProgressQueue = new ConcurrentLinkedQueue<>();
|
_partialProgressQueue = new ConcurrentLinkedQueue<>();
|
||||||
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
|
_rejectedChunkIds = new ConcurrentLinkedQueue<>();
|
||||||
_thread_pool = newCachedThreadPool();
|
_thread_pool = newCachedThreadPool();
|
||||||
|
|
||||||
_view = new DownloadView(this);
|
_view = new DownloadView(this);
|
||||||
_progress_meter = new ProgressMeter(this);
|
_progress_meter = new ProgressMeter(this);
|
||||||
}
|
}
|
||||||
@ -146,7 +145,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
public void setUse_smart_proxy(boolean _use_smart_proxy) {
|
public void setUse_smart_proxy(boolean _use_smart_proxy) {
|
||||||
|
|
||||||
if (_use_smart_proxy) {
|
if (_use_smart_proxy) {
|
||||||
swingReflectionInvoke("setForeground", this.getView().getSpeed_label(), Color.ORANGE);
|
swingReflectionInvoke("setForeground", this.getView().getSpeed_label(), Color.DARK_GRAY);
|
||||||
} else {
|
} else {
|
||||||
swingReflectionInvoke("setForeground", this.getView().getSpeed_label(), new Color(0, 128, 255));
|
swingReflectionInvoke("setForeground", this.getView().getSpeed_label(), new Color(0, 128, 255));
|
||||||
}
|
}
|
||||||
@ -154,7 +153,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
this._use_smart_proxy = _use_smart_proxy;
|
this._use_smart_proxy = _use_smart_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getExcluded_proxies() {
|
public ConcurrentLinkedQueue<String> getExcluded_proxies() {
|
||||||
return _excluded_proxies;
|
return _excluded_proxies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1380,7 +1379,7 @@ public final class Download implements Transference, Runnable, SecureSingleThrea
|
|||||||
|
|
||||||
_use_smart_proxy = false;
|
_use_smart_proxy = false;
|
||||||
|
|
||||||
int proxy_list_hashcode = MainPanel.getProxy_manager().getProxy_list().hashCode();
|
int proxy_list_hashcode = getMain_panel().getProxy_manager().getProxy_list().hashCode();
|
||||||
|
|
||||||
if (_last_proxy_list_hashcode != proxy_list_hashcode) {
|
if (_last_proxy_list_hashcode != proxy_list_hashcode) {
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
<Component id="dance_button" min="-2" max="-2" attributes="0"/>
|
<Component id="dance_button" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="links_label" pref="669" max="32767" attributes="0"/>
|
<Component id="links_label" pref="764" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="dlc_button" min="-2" max="-2" attributes="0"/>
|
<Component id="dlc_button" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -184,7 +184,7 @@ public final class LinkGrabberDialog extends javax.swing.JDialog implements Clip
|
|||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(dance_button))
|
.addComponent(dance_button))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(links_label, javax.swing.GroupLayout.DEFAULT_SIZE, 669, Short.MAX_VALUE)
|
.addComponent(links_label, javax.swing.GroupLayout.DEFAULT_SIZE, 764, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(dlc_button))
|
.addComponent(dlc_button))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
@ -45,7 +45,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
|||||||
*/
|
*/
|
||||||
public final class MainPanel {
|
public final class MainPanel {
|
||||||
|
|
||||||
public static final String VERSION = "2.42";
|
public static final String VERSION = "2.43";
|
||||||
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;
|
||||||
@ -58,9 +58,7 @@ public final class MainPanel {
|
|||||||
private static int _proxy_port;
|
private static int _proxy_port;
|
||||||
private static Credentials _proxy_credentials;
|
private static Credentials _proxy_credentials;
|
||||||
private static boolean _use_proxy;
|
private static boolean _use_proxy;
|
||||||
private static boolean _use_smart_proxy;
|
|
||||||
private static String _use_smart_proxy_url;
|
|
||||||
private static SmartMegaProxyManager _proxy_manager;
|
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
|
|
||||||
@ -86,27 +84,12 @@ public final class MainPanel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUse_proxy() {
|
|
||||||
return _use_proxy;
|
|
||||||
}
|
private volatile boolean _use_smart_proxy;
|
||||||
|
private volatile String _use_smart_proxy_url;
|
||||||
public static String getProxy_host() {
|
private volatile SmartMegaProxyManager _proxy_manager;
|
||||||
return _proxy_host;
|
private volatile MainPanelView _view;
|
||||||
}
|
|
||||||
|
|
||||||
public static int getProxy_port() {
|
|
||||||
return _proxy_port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Credentials getProxy_credentials() {
|
|
||||||
return _proxy_credentials;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUse_smart_proxy_url() {
|
|
||||||
return _use_smart_proxy_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
private volatile MainPanelView _view; //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;
|
||||||
private final UploadManager _upload_manager;
|
private final UploadManager _upload_manager;
|
||||||
@ -172,9 +155,7 @@ public final class MainPanel {
|
|||||||
|
|
||||||
_use_smart_proxy = false;
|
_use_smart_proxy = false;
|
||||||
|
|
||||||
_use_smart_proxy_url = "";
|
_use_smart_proxy_url = null;
|
||||||
|
|
||||||
_proxy_manager = null;
|
|
||||||
|
|
||||||
loadUserSettings();
|
loadUserSettings();
|
||||||
|
|
||||||
@ -226,24 +207,45 @@ public final class MainPanel {
|
|||||||
_mega_proxy_server = null;
|
_mega_proxy_server = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_use_smart_proxy) {
|
if (_use_smart_proxy) {
|
||||||
|
|
||||||
_proxy_manager = new SmartMegaProxyManager(_use_smart_proxy_url);
|
_proxy_manager = new SmartMegaProxyManager(_use_smart_proxy_url);
|
||||||
|
|
||||||
THREAD_POOL.execute(_proxy_manager);
|
THREAD_POOL.execute(_proxy_manager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUse_smart_proxy() {
|
public void setProxy_manager(SmartMegaProxyManager _proxy_manager) {
|
||||||
|
this._proxy_manager = _proxy_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 static boolean isUse_proxy() {
|
||||||
|
return _use_proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUse_smart_proxy() {
|
||||||
return _use_smart_proxy;
|
return _use_smart_proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SmartMegaProxyManager getProxy_manager() {
|
public String getUse_smart_proxy_url() {
|
||||||
return _proxy_manager;
|
return _use_smart_proxy_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setProxy_manager(SmartMegaProxyManager proxy_manager) {
|
public SmartMegaProxyManager getProxy_manager() {
|
||||||
_proxy_manager = proxy_manager;
|
return _proxy_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MegaProxyServer getMega_proxy_server() {
|
public MegaProxyServer getMega_proxy_server() {
|
||||||
@ -321,7 +323,15 @@ public final class MainPanel {
|
|||||||
|
|
||||||
public MainPanelView getView() {
|
public MainPanelView getView() {
|
||||||
|
|
||||||
return _view;
|
while (_view == null) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(250);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
Logger.getLogger(Upload.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlobalSpeedMeter getGlobal_dl_speed() {
|
public GlobalSpeedMeter getGlobal_dl_speed() {
|
||||||
|
@ -734,27 +734,27 @@ public final class MainPanelView extends javax.swing.JFrame {
|
|||||||
_main_panel.setMega_proxy_server(null);
|
_main_panel.setMega_proxy_server(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainPanel.isUse_smart_proxy()) {
|
if (this.getMain_panel().isUse_smart_proxy()) {
|
||||||
|
|
||||||
if (MainPanel.getProxy_manager() == null) {
|
if (this.getMain_panel().getProxy_manager() == null) {
|
||||||
|
|
||||||
MainPanel.setProxy_manager(new SmartMegaProxyManager(MainPanel.getUse_smart_proxy_url()));
|
this.getMain_panel().setProxy_manager(new SmartMegaProxyManager(this.getMain_panel().getUse_smart_proxy_url()));
|
||||||
|
|
||||||
THREAD_POOL.execute(MainPanel.getProxy_manager());
|
THREAD_POOL.execute(this.getMain_panel().getProxy_manager());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
MainPanel.getProxy_manager().setProxy_list_url(MainPanel.getUse_smart_proxy_url());
|
this.getMain_panel().getProxy_manager().setProxy_list_url(this.getMain_panel().getUse_smart_proxy_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (MainPanel.getProxy_manager() != null) {
|
} else if (this.getMain_panel().getProxy_manager() != null) {
|
||||||
|
|
||||||
MainPanel.getProxy_manager().setExit(true);
|
this.getMain_panel().getProxy_manager().setExit(true);
|
||||||
|
|
||||||
synchronized (MainPanel.getProxy_manager().getRefresh_lock()) {
|
synchronized (this.getMain_panel().getProxy_manager().getRefresh_lock()) {
|
||||||
MainPanel.getProxy_manager().getRefresh_lock().notify();
|
this.getMain_panel().getProxy_manager().getRefresh_lock().notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainPanel.setProxy_manager(null);
|
this.getMain_panel().setProxy_manager(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ public final class MegaAPI {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (URISyntaxException ex) {
|
||||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,10 +358,6 @@ public final class MegaAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} while (error != 0);
|
} while (error != 0);
|
||||||
|
|
||||||
} catch (MegaAPIException | IOException exception) {
|
|
||||||
|
|
||||||
throw exception;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_seqno++;
|
_seqno++;
|
||||||
|
@ -86,9 +86,7 @@ public final class MiscTools {
|
|||||||
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 16;
|
public static final int EXP_BACKOFF_MAX_WAIT_TIME = 16;
|
||||||
public static final Object PASS_LOCK = new Object();
|
public static final Object PASS_LOCK = new Object();
|
||||||
public static final int HTTP_TIMEOUT = 30;
|
public static final int HTTP_TIMEOUT = 30;
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String, Method> REFLECTION_METHOD_CACHE = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<String, Method> REFLECTION_METHOD_CACHE = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private static final Comparator<DefaultMutableTreeNode> TREE_NODE_COMPARATOR = new Comparator< DefaultMutableTreeNode>() {
|
private static final Comparator<DefaultMutableTreeNode> TREE_NODE_COMPARATOR = new Comparator< DefaultMutableTreeNode>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,15 +47,18 @@ public class SmartMegaProxyManager implements Runnable {
|
|||||||
|
|
||||||
public synchronized String getRandomProxy() {
|
public synchronized String getRandomProxy() {
|
||||||
|
|
||||||
if (_proxy_list.size() > 0) {
|
synchronized (_refresh_lock) {
|
||||||
|
|
||||||
|
if (_proxy_list.size() > 0) {
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|
||||||
return (String) _proxy_list.toArray()[random.nextInt(_proxy_list.size())];
|
return (String) _proxy_list.toArray()[random.nextInt(_proxy_list.size())];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +66,11 @@ public class SmartMegaProxyManager implements Runnable {
|
|||||||
_proxy_list_url = proxy_list_url;
|
_proxy_list_url = proxy_list_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String getRandomProxy(ArrayList<String> excluded) {
|
public String getRandomProxy(ConcurrentLinkedQueue<String> excluded) {
|
||||||
|
|
||||||
if (_proxy_list.size() > 0) {
|
synchronized (_refresh_lock) {
|
||||||
|
|
||||||
|
if (_proxy_list.size() > 0) {
|
||||||
|
|
||||||
if (excluded.size() > 0) {
|
if (excluded.size() > 0) {
|
||||||
|
|
||||||
@ -101,48 +106,52 @@ public class SmartMegaProxyManager implements Runnable {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentLinkedQueue<String> getProxy_list() {
|
public ConcurrentLinkedQueue<String> getProxy_list() {
|
||||||
return _proxy_list;
|
return _proxy_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void _refreshProxyList() {
|
private void _refreshProxyList() {
|
||||||
|
|
||||||
String data;
|
String data;
|
||||||
|
|
||||||
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
try (CloseableHttpClient httpclient = getApacheKissHttpClient()) {
|
||||||
|
|
||||||
|
if(this._proxy_list_url!=null && this._proxy_list_url.length()>0)
|
||||||
|
{
|
||||||
|
HttpGet httpget = new HttpGet(new URI(this._proxy_list_url));
|
||||||
|
|
||||||
HttpGet httpget = new HttpGet(new URI(this._proxy_list_url));
|
try (CloseableHttpResponse httpresponse = httpclient.execute(httpget)) {
|
||||||
|
|
||||||
try (CloseableHttpResponse httpresponse = httpclient.execute(httpget)) {
|
InputStream is = httpresponse.getEntity().getContent();
|
||||||
|
|
||||||
InputStream is = httpresponse.getEntity().getContent();
|
try (ByteArrayOutputStream byte_res = new ByteArrayOutputStream()) {
|
||||||
|
|
||||||
try (ByteArrayOutputStream byte_res = new ByteArrayOutputStream()) {
|
byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE];
|
||||||
|
|
||||||
byte[] buffer = new byte[MainPanel.DEFAULT_BYTE_BUFFER_SIZE];
|
int reads;
|
||||||
|
|
||||||
int reads;
|
while ((reads = is.read(buffer)) != -1) {
|
||||||
|
|
||||||
while ((reads = is.read(buffer)) != -1) {
|
byte_res.write(buffer, 0, reads);
|
||||||
|
}
|
||||||
|
|
||||||
byte_res.write(buffer, 0, reads);
|
data = new String(byte_res.toByteArray());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data = new String(byte_res.toByteArray());
|
String[] proxy_list = data.split("\n");
|
||||||
|
|
||||||
|
if (proxy_list.length > 0) {
|
||||||
|
|
||||||
|
_proxy_list.clear();
|
||||||
|
|
||||||
|
this._proxy_list.addAll(Arrays.asList(proxy_list));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] proxy_list = data.split("\n");
|
|
||||||
|
|
||||||
if (proxy_list.length > 0) {
|
|
||||||
|
|
||||||
_proxy_list.clear();
|
|
||||||
|
|
||||||
this._proxy_list.addAll(Arrays.asList(proxy_list));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
Logger.getLogger(SmartMegaProxyManager.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(SmartMegaProxyManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (IOException | URISyntaxException ex) {
|
} catch (IOException | URISyntaxException ex) {
|
||||||
@ -156,13 +165,13 @@ public class SmartMegaProxyManager implements Runnable {
|
|||||||
Logger.getLogger(SmartMegaProxyManager.class.getName()).log(Level.INFO, "{0} Smart Proxy Manager: hello!", new Object[]{Thread.currentThread().getName()});
|
Logger.getLogger(SmartMegaProxyManager.class.getName()).log(Level.INFO, "{0} Smart Proxy Manager: hello!", new Object[]{Thread.currentThread().getName()});
|
||||||
|
|
||||||
while (!_exit) {
|
while (!_exit) {
|
||||||
|
|
||||||
this._refreshProxyList();
|
|
||||||
|
|
||||||
Logger.getLogger(SmartMegaProxyManager.class.getName()).log(Level.INFO, "{0} Smart Proxy Manager: proxy list refreshed ({1})", new Object[]{Thread.currentThread().getName(), _proxy_list.size()});
|
|
||||||
|
|
||||||
synchronized (_refresh_lock) {
|
synchronized (_refresh_lock) {
|
||||||
|
|
||||||
|
this._refreshProxyList();
|
||||||
|
|
||||||
|
Logger.getLogger(SmartMegaProxyManager.class.getName()).log(Level.INFO, "{0} Smart Proxy Manager: proxy list refreshed ({1})", new Object[]{Thread.currentThread().getName(), _proxy_list.size()});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_refresh_lock.wait(1000 * REFRESH_PROXY_LIST_TIMEOUT);
|
_refresh_lock.wait(1000 * REFRESH_PROXY_LIST_TIMEOUT);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
|
@ -623,7 +623,7 @@ public final class Upload implements Transference, Runnable, SecureSingleThreadN
|
|||||||
printStatus("Starting upload, please wait...");
|
printStatus("Starting upload, please wait...");
|
||||||
|
|
||||||
if (!_exit) {
|
if (!_exit) {
|
||||||
if (_ul_url == null) {
|
if (_ul_url == null || _restart) {
|
||||||
|
|
||||||
int conta_error = 0;
|
int conta_error = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user