Commit 71336f1f by 钱炳权

项目分离成功,可以成功跑通所有测试

parent 97a834df
...@@ -96,6 +96,12 @@ ...@@ -96,6 +96,12 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.24</version> <version>1.18.24</version>
</dependency> </dependency>
<!--WebSocket核心依赖包-->
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.3.8</version>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
...@@ -141,6 +147,18 @@ ...@@ -141,6 +147,18 @@
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
<!-- 配置java版本 不配置的话默认父类配置的是1.7-->
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build> </build>
</project> </project>
...@@ -6,10 +6,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients; ...@@ -6,10 +6,9 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication @SpringBootApplication
@EnableFeignClients @EnableFeignClients
public class FuzzControlApplication { public class FuzzIntegration {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(FuzzControlApplication.class, args); SpringApplication.run(FuzzIntegration.class, args);
} }
} }
package com.example.fuzzControll.conf;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component("PathProperties")
@ConfigurationProperties(prefix = "path")
public class PathProperties {
String webSocketUri;
public String getWebSocketUri() {
return webSocketUri;
}
public void setWebSocketUri(String webSocketUri) {
this.webSocketUri = webSocketUri;
}
}
package com.example.fuzzControll.controller; package com.example.fuzzControll.controller;
import com.example.fuzzControll.exception.AflnetException; import com.example.fuzzControll.exception.AflnetException;
import com.example.fuzzControll.exception.BaseException;
import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.CmdException;
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;
...@@ -39,8 +40,10 @@ public class TestControler { ...@@ -39,8 +40,10 @@ public class TestControler {
} }
}); });
alfnet.start(); alfnet.start();
} catch (AflnetException | CmdException e) { } catch (Exception e) {
log.error(e.getDefaultMessage()); if(e instanceof AflnetException||e instanceof CmdException){
log.error(((BaseException)e).getDefaultMessage());
}
return AjaxResult.error("测试启动失败!"); return AjaxResult.error("测试启动失败!");
} }
return AjaxResult.success("测试已启动!"); return AjaxResult.success("测试已启动!");
......
package com.example.fuzzControll.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author
*/
@Component("WebSocket")
@ServerEndpoint("/websocket/testResult/{name}")
@Slf4j
public class WebSocket {
private Session session; //与某个客户端连接对话,通过此对客户端发送消息
private static final ConcurrentHashMap<String, WebSocket> WEBSOCKET_CONCURRENTHASHMAP = new ConcurrentHashMap<String, WebSocket>(); //存放所有连接的客户端
@OnOpen
public void onOpen(Session session, @PathParam(value = "name") String name) {
this.session = session; //默认客户端,没有重名
WEBSOCKET_CONCURRENTHASHMAP.put(name, this);
log.info("Websocket is connected! The man is {}.There are {} people in the connection ",name,WEBSOCKET_CONCURRENTHASHMAP.size());
}
@OnClose
public void onClose() {
for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {
if (this == WEBSOCKET_CONCURRENTHASHMAP.get(name)) {
WEBSOCKET_CONCURRENTHASHMAP.remove(name);
break;
}
}
log.info("Websocket is closed! There are {} people in the connection ",WEBSOCKET_CONCURRENTHASHMAP.size());
}
@OnError
public void onError(Session session, Throwable throwable) {
System.out.println("error:");
throwable.printStackTrace();
}
@OnMessage
public void onMessage(Session session, String message) {
System.out.println("【webSocket接收成功】内容为:" + message); //此处可以指定发送,或者群发,或者xxxx的
if (message.indexOf("name:") == 0) {
String name = message.substring(message.indexOf("name") + 5, message.indexOf(";"));
for (String senderStr : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {//获取sender的Stirng
if (WEBSOCKET_CONCURRENTHASHMAP.get(senderStr).getSession() == session) {
appointSending(senderStr, name, message.substring(message.indexOf(";") + 1));
}
}
} else {
groupSending(message, session);
}
}
public void groupSending(String message, Session exIncludeSession) {
for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {
try {
if (exIncludeSession == WEBSOCKET_CONCURRENTHASHMAP.get(name).session) {
continue;
}
WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(name + ":" + message);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void appointSending(String sender, String name, String message) {
try {
// WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message);
WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message);
} catch (IOException e) {
e.printStackTrace();
}
}
public Session getSession() {
return session;
}
}
\ No newline at end of file
package com.example.fuzzControll.controller;
import com.example.fuzzControll.service.websocketClientService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/websocket")
public class WebsocketController {
@Autowired
websocketClientService websocketClientService;
@RequestMapping(value = "/connect", method = RequestMethod.GET)
public void connect(){
try {
websocketClientService.connect();
} catch (Exception e) {
e.printStackTrace();
}
log.info("Connect success!");
}
@RequestMapping(value = "/disConnect", method = RequestMethod.GET)
public void disConnect(){
try {
websocketClientService.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
log.info("Disconnect success!");
}
}
package com.example.fuzzControll.service.impl;
import com.example.fuzzControll.conf.PathProperties;
import com.example.fuzzControll.service.websocketClientService;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.net.URI;
import java.net.URISyntaxException;
@Slf4j
@Service("websocketClientService")
public class websocketClientServiceImpl implements websocketClientService {
public static WebSocketClient webSocketClient = null;
@Autowired
PathProperties properties;
@Override
public void connect() {
try {
webSocketClient = new WebSocketClient(new URI(properties.getWebSocketUri()+"fuzzIntegration")) {
@Override
public void onOpen(ServerHandshake serverHandshake) {
log.info("connect...");
}
@Override
public void onMessage(String s) {
log.info("get message:{}", s);
}
@Override
public void onClose(int i, String s, boolean b) {
log.info("disconnect code:{} reason:{} {}", i, s, b);
}
@Override
public void onError(Exception e) {
log.info("connect error!");
}
};
webSocketClient.connect();
}catch (URISyntaxException e){
e.printStackTrace();
}
}
@Override
public void disconnect() {
try {
webSocketClient.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
package com.example.fuzzControll.service;
import org.java_websocket.client.WebSocketClient;
public interface websocketClientService {
void connect();
void disconnect();
}
package com.example.fuzzControll.tools; 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.controller.WebSocket;
import com.example.fuzzControll.exception.AflnetException; 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.pojo.vo.CmdStartParams; import com.example.fuzzControll.pojo.vo.CmdStartParams;
import com.example.fuzzControll.pojo.vo.TestReturnEntity; import com.example.fuzzControll.pojo.vo.TestReturnEntity;
import com.example.fuzzControll.service.impl.websocketClientServiceImpl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock;
//todo need modify //todo need modify
@Slf4j @Slf4j
public class CmdTools { public class CmdTools {
Boolean send = false; Boolean send = false;
WebSocket socket = (WebSocket) SpringContextUtil.getBean("WebSocket");
Boolean show = true; Boolean show = true;
...@@ -134,7 +130,7 @@ public class CmdTools { ...@@ -134,7 +130,7 @@ public class CmdTools {
if (send) { if (send) {
String data = JSONObject.toJSONString(returnEntity); String data = JSONObject.toJSONString(returnEntity);
try { try {
socket.appointSending("backend", "web", data); websocketClientServiceImpl.webSocketClient.send(data);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
} }
......
...@@ -34,4 +34,5 @@ spring: ...@@ -34,4 +34,5 @@ spring:
nacos: nacos:
discovery: discovery:
server-addr: http://192.168.50.247:8848 server-addr: http://192.168.50.247:8848
path:
webSocketUri: "ws://192.168.50.247:8101/websocket/testResult/"
...@@ -5,6 +5,6 @@ spring: ...@@ -5,6 +5,6 @@ spring:
active: dev #默认为开发环境 active: dev #默认为开发环境
server: server:
port: 8101 port: 8102
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,12 +3,11 @@ package com.example.fuzzbackendmaster; ...@@ -3,12 +3,11 @@ package com.example.fuzzbackendmaster;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
@EnableFeignClients
@SpringBootApplication @SpringBootApplication
public class FuzzbackendmasterApplication { @EnableFeignClients
public class FuzzBackendMaster {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(FuzzbackendmasterApplication.class, args); SpringApplication.run(FuzzBackendMaster.class, args);
} }
} }
/********************************************************************
* 版权所有(C)2023,中国电子科技集团公司第五十研究所。 *
* 文件名称: SpringContextUtil.java//文件名称
* 文件标识: QN2.489.437
* 内容摘要: 获取spring上下文//简要描述本文件的内容,包括主要模块、函数及其功能的说明
* 其它说明: 无
* 当前版本: V1.00.00
* 作者: 张思湛 中国电子科技集团公司电子科学研究院
* 完成日期: 2023年9月18日
* 修改记录1: // 修改历史记录,包括修改日期、修改者及修改内容
* 修改日期:
* 版本号:
* 修改人:
* 修改内容:
* 修改记录2: ……
********************************************************************/
package com.example.fuzzbackendmaster.conf;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class SpringContextUtil implements ApplicationContextAware {
private static ApplicationContext applicationContext;
public SpringContextUtil() {
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (SpringContextUtil.applicationContext == null) {
SpringContextUtil.applicationContext = applicationContext;
}
}
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static Object getBean(Class<?> requiredType) {
return applicationContext.getBean(requiredType);
}
}
package com.example.fuzzbackendmaster.conf;
package com.example.fuzzControll.conf;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter; import org.springframework.web.socket.server.standard.ServerEndpointExporter;
@Configuration @Configuration
public class WebSocketConfig { public class WebsocketConf {
@Bean @Bean
public ServerEndpointExporter serverEndpointExporter() { public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter(); return new ServerEndpointExporter();
} }
} }
\ No newline at end of file
//package com.example.fuzzbackendmaster.controller; package com.example.fuzzbackendmaster.controller;
//
//
//import com.example.fuzzbackendmaster.exception.ServerException; import com.example.fuzzbackendmaster.pojo.vo.AjaxResult;
//import com.example.fuzzbackendmaster.pojo.vo.AjaxResult; import com.example.fuzzbackendmaster.service.FuzzIntegrationFileApi;
//import com.example.fuzzbackendmaster.service.KittyServerMessageApi; import lombok.extern.slf4j.Slf4j;
//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.beans.factory.annotation.Qualifier; import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RestController;
// /**
// * kitty服务器信息
// */
///** @RestController
// * kitty服务器信息 @RequestMapping("/kittyServer")
// */ @Slf4j
//@RestController public class KittyServerMessageController {
//@RequestMapping("/kittyServer")
//@Slf4j @Autowired
//public class KittyServerMessageController { FuzzIntegrationFileApi fuzzIntegrationFileApi;
//
// @Autowired /**
// KittyServerMessageApi kittyServerMessageApi; * 获取服务器stats信息
// /** */
// * 获取服务器stats信息 @RequestMapping(value = "/stats", method = RequestMethod.GET)
// */ public AjaxResult getStats() {
// @RequestMapping(value = "/stats", method = RequestMethod.GET) return fuzzIntegrationFileApi.getStats();
// public AjaxResult getStats( ) { }
// try {
// return AjaxResult.success(kittyServerMessageApi.getStats()); /**
// } catch (ServerException e) { * 获取服务器templateInfo信息
// log.error(e.getDefaultMessage()); */
// return AjaxResult.error("stats信息获取失败!"); @RequestMapping(value = "/templateInfo", method = RequestMethod.GET)
// } public AjaxResult getTemplateInfo() {
// } return fuzzIntegrationFileApi.getTemplateInfo();
// /** }
// * 获取服务器templateInfo信息
// */ /**
// @RequestMapping(value = "/templateInfo", method = RequestMethod.GET) * 获取服务器stages信息
// public AjaxResult getTemplateInfo( ) { */
// try { @RequestMapping(value = "/stages", method = RequestMethod.GET)
// return AjaxResult.success(getServerMessageService.getTemplateInfo()); public AjaxResult getStages() {
// } catch (ServerException e) { return fuzzIntegrationFileApi.getStages();
// log.error(e.getDefaultMessage()); }
// return AjaxResult.error("templateInfo信息获取失败!");
// } /**
// } * 获取服务器report信息
// /** */
// * 获取服务器stages信息 //todo 了解该功能使用方式
// */ @RequestMapping(value = "/report", method = RequestMethod.GET)
// @RequestMapping(value = "/stages", method = RequestMethod.GET) public AjaxResult getReport() {
// public AjaxResult getStages( ) { return fuzzIntegrationFileApi.getReport();
// try { }
// return AjaxResult.success(getServerMessageService.getStages()); }
// } catch (ServerException e) { \ No newline at end of file
// log.error(e.getDefaultMessage());
// return AjaxResult.error("stages信息获取失败!");
// }
// }
// /**
// * 获取服务器report信息
// */
// @RequestMapping(value = "/report", method = RequestMethod.GET)
// public AjaxResult getReport( ) {
// try {
// return AjaxResult.success(getServerMessageService.getReport());
// } catch (ServerException e) {
// log.error(e.getDefaultMessage());
// return AjaxResult.error("report信息获取失败!");
// }
// }
//}
...@@ -29,6 +29,7 @@ public class SeedFileController { ...@@ -29,6 +29,7 @@ public class SeedFileController {
*/ */
@RequestMapping(value = "/list", method = RequestMethod.GET) @RequestMapping(value = "/list", method = RequestMethod.GET)
public AjaxResult list() { public AjaxResult list() {
return fuzzIntegrationFileApi.list(); return fuzzIntegrationFileApi.list();
} }
......
package com.example.fuzzbackendmaster.controller; package com.example.fuzzbackendmaster.controller;
import com.example.fuzzbackendmaster.exception.AflnetException;
import com.example.fuzzbackendmaster.pojo.vo.AjaxResult; import com.example.fuzzbackendmaster.pojo.vo.AjaxResult;
import com.example.fuzzbackendmaster.pojo.vo.CmdStartParams; import com.example.fuzzbackendmaster.pojo.vo.CmdStartParams;
import com.example.fuzzbackendmaster.service.FuzzIntegrationFileApi; import com.example.fuzzbackendmaster.service.FuzzIntegrationFileApi;
...@@ -17,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -17,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping("/test") @RequestMapping("/test")
public class TestControler { public class TestController {
@Autowired @Autowired
FuzzIntegrationFileApi fuzzIntegrationFileApi; FuzzIntegrationFileApi fuzzIntegrationFileApi;
...@@ -25,7 +24,9 @@ public class TestControler { ...@@ -25,7 +24,9 @@ public class TestControler {
* 测试启动 * 测试启动
*/ */
@RequestMapping(value = "/testStart", method = RequestMethod.POST) @RequestMapping(value = "/testStart", method = RequestMethod.POST)
public AjaxResult list(@RequestBody final CmdStartParams cmdStartParams) { public AjaxResult testStart(@RequestBody final CmdStartParams cmdStartParams) {
//启动时就开始连接
fuzzIntegrationFileApi.connect();
return fuzzIntegrationFileApi.testStart(cmdStartParams); return fuzzIntegrationFileApi.testStart(cmdStartParams);
} }
...@@ -34,6 +35,8 @@ public class TestControler { ...@@ -34,6 +35,8 @@ public class TestControler {
*/ */
@RequestMapping(value = "/testStop", method = RequestMethod.GET) @RequestMapping(value = "/testStop", method = RequestMethod.GET)
public AjaxResult testStop() { public AjaxResult testStop() {
//停止时就开始关闭
fuzzIntegrationFileApi.disconnect();
return fuzzIntegrationFileApi.testStop(); return fuzzIntegrationFileApi.testStop();
} }
......
//package com.example.fuzzbackendmaster.controller; package com.example.fuzzbackendmaster.controller;
//
//
//import lombok.extern.slf4j.Slf4j; import com.example.fuzzbackendmaster.conf.SpringContextUtil;
//import org.springframework.stereotype.Component; import com.example.fuzzbackendmaster.service.FuzzIntegrationFileApi;
// import lombok.extern.slf4j.Slf4j;
//import javax.websocket.*; import org.springframework.beans.factory.annotation.Autowired;
//import javax.websocket.server.PathParam; import org.springframework.beans.factory.annotation.Qualifier;
//import javax.websocket.server.ServerEndpoint; import org.springframework.messaging.handler.annotation.SendTo;
//import java.io.IOException; import org.springframework.stereotype.Component;
//import java.util.concurrent.ConcurrentHashMap; import org.springframework.stereotype.Service;
// import org.springframework.web.bind.annotation.RestController;
///** import org.springframework.web.socket.client.WebSocketClient;
// * @author
// */ import javax.websocket.*;
//@Component("WebSocket") import javax.websocket.server.PathParam;
//@ServerEndpoint("/websocket/testResult/{name}") import javax.websocket.server.ServerEndpoint;
//@Slf4j import java.io.IOException;
//public class WebSocket { import java.net.URI;
// import java.util.concurrent.ConcurrentHashMap;
// private Session session; //与某个客户端连接对话,通过此对客户端发送消息
// private static final ConcurrentHashMap<String, WebSocket> WEBSOCKET_CONCURRENTHASHMAP = new ConcurrentHashMap<String, WebSocket>(); //存放所有连接的客户端 /**
// * @author
// */
// @OnOpen
// public void onOpen(Session session, @PathParam(value = "name") String name) { @Component
// this.session = session; //默认客户端,没有重名 @ServerEndpoint("/websocket/testResult/{name}")
// WEBSOCKET_CONCURRENTHASHMAP.put(name, this); @Slf4j
// log.info("Websocket is connected! The man is {}.There are {} people in the connection ",name,WEBSOCKET_CONCURRENTHASHMAP.size()); public class WebSocket {
// } private Session session; //与某个客户端连接对话,通过此对客户端发送消息
// private static final ConcurrentHashMap<String, WebSocket> WEBSOCKET_CONCURRENTHASHMAP = new ConcurrentHashMap<String, WebSocket>(); //存放所有连接的客户端
//
// @OnClose private static FuzzIntegrationFileApi fuzzIntegrationFileApi;
// public void onClose() {
// @Autowired
// for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) { public void setOrderService(FuzzIntegrationFileApi fuzzIntegrationFileApi) {
// WebSocket.fuzzIntegrationFileApi = fuzzIntegrationFileApi;
// if (this == WEBSOCKET_CONCURRENTHASHMAP.get(name)) { }
//
// WEBSOCKET_CONCURRENTHASHMAP.remove(name);
// break; @OnOpen
// } public void onOpen(Session session, @PathParam(value = "name") String name) {
// } this.session = session; //默认客户端,没有重名
// WEBSOCKET_CONCURRENTHASHMAP.put(name, this);
// log.info("Websocket is closed! There are {} people in the connection ",WEBSOCKET_CONCURRENTHASHMAP.size()); log.info("Websocket is connected! The man is {}.There are {} people in the connection ", name, WEBSOCKET_CONCURRENTHASHMAP.size());
// } }
//
// @OnError
// public void onError(Session session, Throwable throwable) { @OnClose
// public void onClose() {
// System.out.println("error:");
// throwable.printStackTrace(); for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {
// }
// if (this == WEBSOCKET_CONCURRENTHASHMAP.get(name)) {
// @OnMessage
// public void onMessage(Session session, String message) { WEBSOCKET_CONCURRENTHASHMAP.remove(name);
// break;
// System.out.println("【webSocket接收成功】内容为:" + message); //此处可以指定发送,或者群发,或者xxxx的 }
// }
// if (message.indexOf("name:") == 0) {
// log.info("Websocket is closed! There are {} people in the connection ", WEBSOCKET_CONCURRENTHASHMAP.size());
// String name = message.substring(message.indexOf("name") + 5, message.indexOf(";")); }
//
// @OnError
// for (String senderStr : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {//获取sender的Stirng public void onError(Session session, Throwable throwable) {
//
// if (WEBSOCKET_CONCURRENTHASHMAP.get(senderStr).getSession() == session) { System.out.println("error:");
// throwable.printStackTrace();
// appointSending(senderStr, name, message.substring(message.indexOf(";") + 1)); }
// }
// } @OnMessage
// } else { // @SendTo("")
// public void onMessage(Session session, String message) {
// groupSending(message, session); for (String senderStr : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {//获取sender的Stirng
// } if (WEBSOCKET_CONCURRENTHASHMAP.get(senderStr).getSession() == session) {
// } appointSending("fuzzMaster", "web", message.substring(message.indexOf(";") + 1));
// }
// }
// public void groupSending(String message, Session exIncludeSession) { }
//
// for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {
// public void groupSending(String message, Session exIncludeSession) {
// try {
// if (exIncludeSession == WEBSOCKET_CONCURRENTHASHMAP.get(name).session) { for (String name : WEBSOCKET_CONCURRENTHASHMAP.keySet()) {
// continue;
// } try {
// if (exIncludeSession == WEBSOCKET_CONCURRENTHASHMAP.get(name).session) {
// WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(name + ":" + message); continue;
// } catch (IOException e) { }
// e.printStackTrace();
// } WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(name + ":" + message);
// } } catch (IOException e) {
// } e.printStackTrace();
// }
// }
// public void appointSending(String sender, String name, String message) { }
// try {
//// WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message);
// WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message); public void appointSending(String sender, String name, String message) {
// try {
// } catch (IOException e) { // WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(sender + ":" + message);
// e.printStackTrace(); WEBSOCKET_CONCURRENTHASHMAP.get(name).session.getBasicRemote().sendText(message);
// }
// } } catch (IOException e) {
// e.printStackTrace();
// public Session getSession() { }
// return session; }
// }
//} public Session getSession() {
\ No newline at end of file return session;
}
}
\ No newline at end of file
...@@ -6,17 +6,17 @@ import com.example.fuzzbackendmaster.pojo.vo.TestEntity; ...@@ -6,17 +6,17 @@ import com.example.fuzzbackendmaster.pojo.vo.TestEntity;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
@Component
@FeignClient(value = "fuzz-backend-integration") @FeignClient(value = "fuzz-backend-integration")
public interface FuzzIntegrationFileApi { public interface FuzzIntegrationFileApi {
/** /**
* seedFlole * seedFlole
*
*/ */
@RequestMapping(value = "/seedFile/list", method = RequestMethod.GET) @RequestMapping(value = "/seedFile/list", method = RequestMethod.GET)
AjaxResult list(); AjaxResult list();
...@@ -26,9 +26,9 @@ public interface FuzzIntegrationFileApi { ...@@ -26,9 +26,9 @@ public interface FuzzIntegrationFileApi {
@RequestMapping(value = "/seedFile/delete", method = RequestMethod.GET, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @RequestMapping(value = "/seedFile/delete", method = RequestMethod.GET, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
AjaxResult delFile(@RequestPart("fileName") String fileName); AjaxResult delFile(@RequestPart("fileName") String fileName);
/** /**
* testclass * testclass
*
*/ */
@RequestMapping(value = "/testClass/protocolTemplate", method = RequestMethod.POST) @RequestMapping(value = "/testClass/protocolTemplate", method = RequestMethod.POST)
AjaxResult protocolTemplate(@RequestBody TestEntity testEntity); AjaxResult protocolTemplate(@RequestBody TestEntity testEntity);
...@@ -43,11 +43,28 @@ public interface FuzzIntegrationFileApi { ...@@ -43,11 +43,28 @@ public interface FuzzIntegrationFileApi {
AjaxResult vulnerability(@RequestBody TestEntity testEntity); AjaxResult vulnerability(@RequestBody TestEntity testEntity);
/** /**
*
* Aflnet * Aflnet
*/ */
@RequestMapping(value = "/test/testStop", method = RequestMethod.GET) @RequestMapping(value = "/test/testStop", method = RequestMethod.GET)
AjaxResult testStop(); AjaxResult testStop();
@RequestMapping(value = "/test/testStart", method = RequestMethod.POST) @RequestMapping(value = "/test/testStart", method = RequestMethod.POST)
AjaxResult testStart(@RequestBody final CmdStartParams cmdStartParams); AjaxResult testStart(@RequestBody final CmdStartParams cmdStartParams);
@RequestMapping(value = "/kittyServer/stats", method = RequestMethod.GET)
AjaxResult getStats();
@RequestMapping(value = "/kittyServer/templateInfo", method = RequestMethod.GET)
AjaxResult getTemplateInfo();
@RequestMapping(value = "/kittyServer/stages", method = RequestMethod.GET)
AjaxResult getStages();
@RequestMapping(value = "/kittyServer/report", method = RequestMethod.GET)
AjaxResult getReport();
/**
* websocket
*/
@RequestMapping(value = "/websocket/connect", method = RequestMethod.GET)
void connect();
@RequestMapping(value = "/websocket/disConnect", method = RequestMethod.GET)
void disconnect();
} }
...@@ -5,6 +5,6 @@ spring: ...@@ -5,6 +5,6 @@ spring:
active: dev #默认为开发环境 active: dev #默认为开发环境
server: server:
port: 8102 port: 8101
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
var ws1 = null; var ws1 = null;
var ws2 = null; var ws2 = null;
function myFunction() { function myFunction() {
ws1 = new WebSocket("ws://localhost:8200/websocket/testResult/" + "web"); ws1 = new WebSocket("ws://192.168.50.247:8101/websocket/testResult/web");
ws1.onmessage = function (evt) { ws1.onmessage = function (evt) {
console.log(evt); console.log(evt);
var received_msg =JSON.parse(evt.data) ; var received_msg =JSON.parse(evt.data) ;
......
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