@@ -126,7 +141,7 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -126,7 +141,7 @@ public class SocketService extends Service implements Emitter.Listener {
longendTime=System.nanoTime();
longendTime=System.nanoTime();
longduration=(endTime-startTime)/1000000-120;
longduration=(endTime-startTime)/1000000-120;
proxy.setDur(duration);
proxy.setDur(duration);
proxy.setConnect(true);
proxy.setConnect(1);
subscriber.onNext(proxy);
subscriber.onNext(proxy);
subscriber.onCompleted();
subscriber.onCompleted();
...
@@ -137,7 +152,7 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -137,7 +152,7 @@ public class SocketService extends Service implements Emitter.Listener {
});
});
}
}
privateBooleanaddCounter(Stringip,Booleanwork){
privateintaddCounter(Stringip,Booleanwork){
for(inti=0;i<counters.size();i++){
for(inti=0;i<counters.size();i++){
if(counters.get(i).getIp().equals(ip)){
if(counters.get(i).getIp().equals(ip)){
...
@@ -145,11 +160,16 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -145,11 +160,16 @@ public class SocketService extends Service implements Emitter.Listener {
if(work){
if(work){
counters.get(i).setCount(0);
counters.get(i).setCount(0);
returntrue;
return1;
}else{
}else{
counters.get(i).setCountPlus();
counters.get(i).setCountPlus();
returncounters.get(i).getCount()<=5;
if(counters.get(i).getCount()<appRetry)
//comment new 2 ->0
return2;
else
return0;
}
}
}
}
...
@@ -160,7 +180,9 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -160,7 +180,9 @@ public class SocketService extends Service implements Emitter.Listener {
Countercounter=newCounter(ip,work?0:1);
Countercounter=newCounter(ip,work?0:1);
counters.add(counter);
counters.add(counter);
returntrue;
if(work)
return1;
return2;
}
}
...
@@ -193,15 +215,15 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -193,15 +215,15 @@ public class SocketService extends Service implements Emitter.Listener {
.subscribeOn(Schedulers.newThread())
.subscribeOn(Schedulers.newThread())
.concatMap(proxy->getPingServerObservable(proxy)
.concatMap(proxy->getPingServerObservable(proxy)
.subscribeOn(Schedulers.newThread())
.subscribeOn(Schedulers.newThread())
.timeout(10,TimeUnit.SECONDS)
.timeout(appSec,TimeUnit.SECONDS)
.onErrorResumeNext(throwable->{
.onErrorResumeNext(throwable->{
ConnectionsManager.setCaller(null);
ConnectionsManager.setCaller(null);
if(!addCounter(proxy.getIp(),false)){
if(addCounter(proxy.getIp(),false)==0){
proxy.setConnect(false);
proxy.setConnect(0);
Log.e("Proxy Connect","IP Not Work :"+proxy.getIp()+" "+Constants.TYPE);
Log.e("Proxy Connect","IP Not Work :"+proxy.getIp()+" "+Constants.TYPE);
}else{
}else{
proxy.setConnect(true);
proxy.setConnect(2);
Log.e("Proxy Connect","IP So So :"+proxy.getIp()+" "+Constants.TYPE);
Log.e("Proxy Connect","IP So So :"+proxy.getIp()+" "+Constants.TYPE);
}
}
...
@@ -228,32 +250,34 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -228,32 +250,34 @@ public class SocketService extends Service implements Emitter.Listener {
publicvoidonNext(List<Proxy>proxyList){
publicvoidonNext(List<Proxy>proxyList){
intw=0;
intw=0;
intn=0;
intn=0;
intsoso=0;
List<Proxy>notWork=newArrayList<>();
List<Proxy>notWork=newArrayList<>();
for(Proxyproxy:proxyList){
for(Proxyproxy:proxyList){
if(proxy.getConnect())
if(proxy.getConnect()==1)
w++;
w++;
elseif(proxy.getConnect()==2)
soso++;
else{
else{
notWork.add(proxy);
notWork.add(proxy);
n++;
n++;
Log.e("Status",proxy.getInstance());
}
}
}
}
work=false;
work=false;
Log.e("Status Proxy Result :","Task Check Finished for "+proxyList.size()+" Ips And "+w+" Ips Work and "+n+" IPS not work"+" "+Constants.TYPE);
Log.e("Status Proxy Result :","Task Check Finished for "+proxyList.size()+" Ips And "+w+" Ips Work and "+soso+" IPS So "+n+"IPS not work "+Constants.TYPE);