diff --git a/pom.xml b/pom.xml
index c4dd00b..7ac2eb9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,7 @@
**/application-*.yml
**/logback-spring.xml
+ **/token.auth
lib/*.*
diff --git a/src/main/java/net/geedge/api/controller/APIController.java b/src/main/java/net/geedge/api/controller/APIController.java
index 58e8c73..f1b4be1 100644
--- a/src/main/java/net/geedge/api/controller/APIController.java
+++ b/src/main/java/net/geedge/api/controller/APIController.java
@@ -127,6 +127,11 @@ public class APIController {
return R.ok();
}
+ @GetMapping("/pcap")
+ public R listTcpdump() {
+ return R.ok().putData("records", adbUtil.listTcpdump());
+ }
+
@PostMapping("/pcap")
public R startTcpdump(@RequestParam(required = false, defaultValue = "") String packageName) {
AdbUtil.CommandResult result = adbUtil.startTcpdump(packageName);
@@ -149,7 +154,10 @@ public class APIController {
// response pcap file
File tempFile = T.FileUtil.file(Constant.TEMP_PATH, id + ".pcap");
try {
- String filePath = "/data/local/tmp/" + id + ".pcap";
+ String filePath = result.output();
+ 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());
@@ -163,4 +171,15 @@ public class APIController {
response.getWriter().write(T.JSONUtil.toJsonStr(R.ok().putData("id", id)));
}
}
+
+ @PostMapping("/shell")
+ public R execShellCmd(@RequestBody Map requestBody) {
+ String cmd = T.MapUtil.getStr(requestBody, "cmd", "");
+ if (T.StrUtil.isEmpty(cmd)) {
+ return R.error(RCode.BAD_REQUEST);
+ }
+
+ Integer timeout = T.MapUtil.getInt(requestBody, "timeout", 10);
+ return R.ok().putData("result", adbUtil.execShellCommand(cmd, timeout));
+ }
}
\ No newline at end of file
diff --git a/src/main/java/net/geedge/api/util/AdbUtil.java b/src/main/java/net/geedge/api/util/AdbUtil.java
index beba56e..71d4adb 100644
--- a/src/main/java/net/geedge/api/util/AdbUtil.java
+++ b/src/main/java/net/geedge/api/util/AdbUtil.java
@@ -482,6 +482,7 @@ public class AdbUtil {
* iptables -F
* iptables -X
*/
+ @Deprecated
private void cleanIptables() {
// Delete all rules in chain or all chains
CommandExec.exec(AdbCommandBuilder.builder()
@@ -497,17 +498,47 @@ public class AdbUtil {
);
}
+ /**
+ * list tcpdump
+ */
+ public List