feat: tcpdump 时过滤掉 vnc 数据包
1. 项目启动时从 ./lib/droidvnc-np-defaults.json 读取 vnc port 2. 不论是否输入package name 全部过滤掉 vnc 流量 3. 结束捕包时删除 pcap 文件
This commit is contained in:
@@ -150,25 +150,32 @@ public class APIController {
|
||||
throw new APIException(result.output());
|
||||
}
|
||||
|
||||
if (returnFile) {
|
||||
// response pcap file
|
||||
File tempFile = T.FileUtil.file(Constant.TEMP_PATH, id + ".pcap");
|
||||
try {
|
||||
String filePath = result.output();
|
||||
if (T.StrUtil.isEmpty(filePath)) {
|
||||
throw new APIException(RCode.NOT_EXISTS);
|
||||
String filePath = result.output();
|
||||
try {
|
||||
if (returnFile) {
|
||||
// response pcap file
|
||||
File tempFile = T.FileUtil.file(Constant.TEMP_PATH, id + ".pcap");
|
||||
try {
|
||||
if (T.StrUtil.isEmpty(filePath)) {
|
||||
throw new APIException(RCode.NOT_EXISTS);
|
||||
}
|
||||
AdbUtil.CommandResult pulled = adbUtil.pull(filePath, tempFile.getAbsolutePath());
|
||||
if (0 != pulled.exitCode()) {
|
||||
throw new APIException(pulled.output());
|
||||
}
|
||||
T.ResponseUtil.downloadFile(response, tempFile.getName(), T.FileUtil.readBytes(tempFile));
|
||||
} finally {
|
||||
T.FileUtil.del(tempFile);
|
||||
}
|
||||
AdbUtil.CommandResult pulled = adbUtil.pull(filePath, tempFile.getAbsolutePath());
|
||||
if (0 != pulled.exitCode()) {
|
||||
throw new APIException(pulled.output());
|
||||
}
|
||||
T.ResponseUtil.downloadFile(response, tempFile.getName(), T.FileUtil.readBytes(tempFile));
|
||||
} finally {
|
||||
T.FileUtil.del(tempFile);
|
||||
} else {
|
||||
// response taskid
|
||||
response.getWriter().write(T.JSONUtil.toJsonStr(R.ok().putData("id", id)));
|
||||
}
|
||||
} finally {
|
||||
if (T.StrUtil.isNotEmpty(filePath)) {
|
||||
// remove pcap file
|
||||
adbUtil.execShellCommand(String.format("shell rm -rf %s", filePath));
|
||||
}
|
||||
} else {
|
||||
// response taskid
|
||||
response.getWriter().write(T.JSONUtil.toJsonStr(R.ok().putData("id", id)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user