Skip to content

Commit

Permalink
finalspeed 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wntr committed Mar 20, 2016
1 parent f2a6067 commit 55184e8
Show file tree
Hide file tree
Showing 18 changed files with 442 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/.idea/
/out/
/*.sh
/fortest/
Binary file added img/offline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 34 additions & 11 deletions src/net/fs/cap/CapEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,19 @@ public class CapEnv {

boolean detect_by_tcp=true;

public boolean tcpEnable=true;
public boolean tcpEnable=false;

public boolean fwSuccess=true;

boolean ppp=false;

{
capEnv=this;
}

public CapEnv(boolean isClient){
public CapEnv(boolean isClient,boolean fwSuccess){
this.client=isClient;
this.fwSuccess=fwSuccess;
tcpManager=new TunManager(this);
}

Expand Down Expand Up @@ -161,13 +164,25 @@ public void run(){
long t=System.currentTimeMillis();
while(true){
if(System.currentTimeMillis()-t>5*1000){
MLog.info("休眠恢复");
MLog.println("重新初始化接口");
try {
initInterface();
} catch (Exception e1) {
e1.printStackTrace();
for(int i=0;i<10;i++){
MLog.info("休眠恢复... "+(i+1));
try {
boolean success=initInterface();
if(success){
MLog.info("休眠恢复成功 "+(i+1));
break;
}
} catch (Exception e1) {
e1.printStackTrace();
}

try {
Thread.sleep(5*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

}
t=System.currentTimeMillis();
try {
Expand All @@ -178,7 +193,7 @@ public void run(){
}
}
};
//systemSleepScanThread.start();
systemSleepScanThread.start();
}

PromiscuousMode getMode(PcapNetworkInterface pi){
Expand All @@ -192,7 +207,8 @@ PromiscuousMode getMode(PcapNetworkInterface pi){
return mode;
}

void initInterface() throws Exception{
boolean initInterface() throws Exception{
boolean success=false;
detectInterface();
List<PcapNetworkInterface> allDevs = Pcaps.findAllDevs();
MLog.println("Network Interface List: ");
Expand All @@ -213,7 +229,11 @@ void initInterface() throws Exception{
if(nif.getDescription()!=null){
desString=nif.getDescription();
}
success=true;
MLog.info("Selected Network Interface:\n"+" "+desString+" "+nif.getName());
if(fwSuccess){
tcpEnable=true;
}
}else {
tcpEnable=false;
MLog.info("Select Network Interface failed,can't use TCP protocal!\n");
Expand Down Expand Up @@ -253,7 +273,10 @@ public void run(){
thread.start();
}

MLog.info("FinalSpeed server start success.");
if(!client){
MLog.info("FinalSpeed server start success.");
}
return success;

}

Expand Down
2 changes: 1 addition & 1 deletion src/net/fs/cap/CapServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CapServer {
CapServer(){
CapEnv capEnv=null;
try {
capEnv=new CapEnv(false);
capEnv=new CapEnv(false,true);
capEnv.init();
} catch (Exception e) {
e.printStackTrace();
Expand Down
10 changes: 10 additions & 0 deletions src/net/fs/client/ClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class ClientConfig {
String remoteAddress;

String protocal="tcp";

boolean autoStart=false;

public String getServerAddress() {
return serverAddress;
Expand Down Expand Up @@ -91,5 +93,13 @@ public String getProtocal() {
public void setProtocal(String protocal) {
this.protocal = protocal;
}

public boolean isAutoStart() {
return autoStart;
}

public void setAutoStart(boolean autoStart) {
this.autoStart = autoStart;
}

}
Loading

0 comments on commit 55184e8

Please sign in to comment.