Commit 3976f673 by 钱炳权

exception is changed

parent f9e51c78
...@@ -2,16 +2,20 @@ package com.example.fuzzControll.controller; ...@@ -2,16 +2,20 @@ package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.service.GetServerMessageService; import com.example.fuzzControll.service.GetServerMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
/** /**
* kitty服务器信息 * kitty服务器信息
*/ */
@RestController @RestController
@RequestMapping("/kittyServer") @RequestMapping("/kittyServer")
@Slf4j
public class KittyServerMessageController { public class KittyServerMessageController {
@Autowired @Autowired
GetServerMessageService getServerMessageService; GetServerMessageService getServerMessageService;
...@@ -23,6 +27,7 @@ public class KittyServerMessageController { ...@@ -23,6 +27,7 @@ public class KittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getStats()); return AjaxResult.success(getServerMessageService.getStats());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("stats信息获取失败!"); return AjaxResult.error("stats信息获取失败!");
} }
} }
...@@ -34,6 +39,7 @@ public class KittyServerMessageController { ...@@ -34,6 +39,7 @@ public class KittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getTemplateInfo()); return AjaxResult.success(getServerMessageService.getTemplateInfo());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("templateInfo信息获取失败!"); return AjaxResult.error("templateInfo信息获取失败!");
} }
} }
...@@ -45,6 +51,7 @@ public class KittyServerMessageController { ...@@ -45,6 +51,7 @@ public class KittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getStages()); return AjaxResult.success(getServerMessageService.getStages());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("stages信息获取失败!"); return AjaxResult.error("stages信息获取失败!");
} }
} }
...@@ -56,6 +63,7 @@ public class KittyServerMessageController { ...@@ -56,6 +63,7 @@ public class KittyServerMessageController {
try { try {
return AjaxResult.success(getServerMessageService.getReport()); return AjaxResult.success(getServerMessageService.getReport());
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("report信息获取失败!"); return AjaxResult.error("report信息获取失败!");
} }
} }
......
...@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
...@@ -32,7 +33,7 @@ public class SeedFileController { ...@@ -32,7 +33,7 @@ public class SeedFileController {
try { try {
files = service.getSeedFiles(); files = service.getSeedFiles();
} catch (Exception e) { } catch (Exception e) {
log.error(e.toString()); log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("种子文件获取失败!"); return AjaxResult.error("种子文件获取失败!");
} }
return AjaxResult.success(files); return AjaxResult.success(files);
...@@ -46,7 +47,7 @@ public class SeedFileController { ...@@ -46,7 +47,7 @@ public class SeedFileController {
try { try {
service.delFile(fileName); service.delFile(fileName);
} catch (Exception e) { } catch (Exception e) {
log.error(e.toString()); log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("种子文件删除失败!"); return AjaxResult.error("种子文件删除失败!");
} }
return AjaxResult.success("种子文件删除成功!"); return AjaxResult.success("种子文件删除成功!");
...@@ -59,7 +60,7 @@ public class SeedFileController { ...@@ -59,7 +60,7 @@ public class SeedFileController {
try { try {
service.upload(file); service.upload(file);
} catch (Exception e) { } catch (Exception e) {
log.error(e.toString()); log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("种子文件upload失败!"); return AjaxResult.error("种子文件upload失败!");
} }
return AjaxResult.success("种子文件upload成功!"); return AjaxResult.success("种子文件upload成功!");
......
...@@ -3,15 +3,19 @@ package com.example.fuzzControll.controller; ...@@ -3,15 +3,19 @@ package com.example.fuzzControll.controller;
import com.example.fuzzControll.pojo.vo.AjaxResult; import com.example.fuzzControll.pojo.vo.AjaxResult;
import com.example.fuzzControll.pojo.vo.CmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.service.TestService; import com.example.fuzzControll.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
/** /**
* aflnet测试控制 * aflnet测试控制
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/test") @RequestMapping("/test")
public class TestControler { public class TestControler {
...@@ -31,6 +35,7 @@ public class TestControler { ...@@ -31,6 +35,7 @@ public class TestControler {
} }
}).start(); }).start();
} catch (Exception e) { } catch (Exception e) {
log.error(Arrays.toString(e.getStackTrace()));
return AjaxResult.error("测试启动失败!"); return AjaxResult.error("测试启动失败!");
} }
return AjaxResult.success("测试启动成功!"); return AjaxResult.success("测试启动成功!");
......
...@@ -32,6 +32,9 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -32,6 +32,9 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
} }
public String parseParameters(TestEntity testEntity) { public String parseParameters(TestEntity testEntity) {
if(testEntity==null){
throw new FuzzException("testEntity is null!");
}
switch (testEntity.getTestClassName().toLowerCase()) { switch (testEntity.getTestClassName().toLowerCase()) {
case "arp": case "arp":
return arpCmd(testEntity); return arpCmd(testEntity);
...@@ -645,7 +648,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -645,7 +648,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
return ""; return "";
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HDLC; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HDLC;
} }
//todo need change
private String ftpCmd(TestEntity testEntity) { private String ftpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ftp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ftp"))
return ""; return "";
...@@ -656,6 +659,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -656,6 +659,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
target_port = testEntity.getParamJson()[1]; target_port = testEntity.getParamJson()[1];
} catch (Exception e) { } catch (Exception e) {
log.error("ftp参数解析失败!"); log.error("ftp参数解析失败!");
throw new FuzzException("count of params is not match!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FTP + target_host + " " + target_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FTP + target_host + " " + target_port;
} }
...@@ -670,6 +674,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -670,6 +674,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
target_port = testEntity.getParamJson()[1]; target_port = testEntity.getParamJson()[1];
} catch (Exception e) { } catch (Exception e) {
log.error("frp参数解析失败!"); log.error("frp参数解析失败!");
throw new FuzzException("count of params is not match!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FRP + target_host + " " + target_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FRP + target_host + " " + target_port;
} }
...@@ -684,6 +689,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -684,6 +689,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
dst_port = testEntity.getParamJson()[1]; dst_port = testEntity.getParamJson()[1];
} catch (Exception e) { } catch (Exception e) {
log.error("dns参数解析失败!"); log.error("dns参数解析失败!");
throw new FuzzException("count of params is not match!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DNS + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DNS + dst_ip + " " + dst_port;
} }
...@@ -698,6 +704,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -698,6 +704,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
dst_port = testEntity.getParamJson()[1]; dst_port = testEntity.getParamJson()[1];
} catch (Exception e) { } catch (Exception e) {
log.error("dhcp参数解析失败!"); log.error("dhcp参数解析失败!");
throw new FuzzException("count of params is not match!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DHCP + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DHCP + dst_ip + " " + dst_port;
} }
...@@ -716,11 +723,12 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -716,11 +723,12 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
dst_port = testEntity.getParamJson()[3]; dst_port = testEntity.getParamJson()[3];
} catch (Exception e) { } catch (Exception e) {
log.error("bgp参数解析失败!"); log.error("bgp参数解析失败!");
throw new FuzzException("count of params is not match!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.BGP + src_ip + " " + src_port + " " + dst_ip + " " + dst_port; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.BGP + src_ip + " " + src_port + " " + dst_ip + " " + dst_port;
} }
public String arpCmd(TestEntity testEntity) { public String arpCmd(TestEntity testEntity) throws FuzzException{
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "arp")) if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "arp"))
return ""; return "";
String dst_mac = null; String dst_mac = null;
...@@ -730,6 +738,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -730,6 +738,7 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
src_mac = testEntity.getParamJson()[1]; src_mac = testEntity.getParamJson()[1];
} catch (Exception e) { } catch (Exception e) {
log.error("arp参数解析失败!"); log.error("arp参数解析失败!");
throw new FuzzException("count of params is not match!");
} }
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ARP + dst_mac + " " + src_mac; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ARP + dst_mac + " " + src_mac;
} }
......
...@@ -3,6 +3,8 @@ package com.example.fuzzControll.service.impl; ...@@ -3,6 +3,8 @@ package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.conf.KittyProperties;
import com.example.fuzzControll.constents.CmdConstent; import com.example.fuzzControll.constents.CmdConstent;
import com.example.fuzzControll.exception.AflnetException;
import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.pojo.vo.CmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.service.TestService; import com.example.fuzzControll.service.TestService;
import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.CmdTools;
...@@ -17,7 +19,7 @@ public class TestServiceImpl implements TestService { ...@@ -17,7 +19,7 @@ public class TestServiceImpl implements TestService {
//todo 不同服务不同端口 //todo 不同服务不同端口
@Override @Override
public void testStart(CmdStartParams cmdStartParams) { public void testStart(CmdStartParams cmdStartParams) throws AflnetException {
TestControlTools.setIsRunning(true); TestControlTools.setIsRunning(true);
String cmd = cmdTools.parse(cmdStartParams); String cmd = cmdTools.parse(cmdStartParams);
String finalCmd = CmdConstent.RUN_AFLNET + cmd + kittyProperties.getAflnetPath()+"live555/testProgs/testOnDemandRTSPServer 8554"; String finalCmd = CmdConstent.RUN_AFLNET + cmd + kittyProperties.getAflnetPath()+"live555/testProgs/testOnDemandRTSPServer 8554";
......
...@@ -3,6 +3,7 @@ package com.example.fuzzControll.tools; ...@@ -3,6 +3,7 @@ package com.example.fuzzControll.tools;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.example.fuzzControll.conf.SpringContextUtil; import com.example.fuzzControll.conf.SpringContextUtil;
import com.example.fuzzControll.controller.WebSocket; import com.example.fuzzControll.controller.WebSocket;
import com.example.fuzzControll.exception.AflnetException;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.CmdException;
import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.exception.FuzzException;
import com.example.fuzzControll.pojo.vo.CmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
...@@ -217,7 +218,10 @@ public class CmdTools { ...@@ -217,7 +218,10 @@ public class CmdTools {
return returnEntity; return returnEntity;
} }
public String parse(CmdStartParams cmdStartParams) { public String parse(CmdStartParams cmdStartParams) throws AflnetException{
if(cmdStartParams==null){
throw new AflnetException("CmdStartParams is null!");
}
StringBuilder cmd = new StringBuilder(); StringBuilder cmd = new StringBuilder();
if (cmdStartParams.getNetinfo() != "") { if (cmdStartParams.getNetinfo() != "") {
cmd.append(" -N " + cmdStartParams.getNetinfo()); cmd.append(" -N " + cmdStartParams.getNetinfo());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment