From af610e4416d631e1d296826047c45d492f7027a3 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 25 Oct 2023 20:05:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20UPF=E8=84=9A=E6=9C=AC=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=BC=BA=E5=A4=B1expect=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/trace/tcpdump.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/trace/tcpdump.go b/features/trace/tcpdump.go index 5f13fcad..914dc7c0 100644 --- a/features/trace/tcpdump.go +++ b/features/trace/tcpdump.go @@ -272,7 +272,7 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) { if body.RunType == "start_str" { fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId) filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId) - scriptStr := "#!/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" + scriptStr := "#!/bin/expect\n#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127 capCmdStr := fmt.Sprintf("%s file %s", body.Cmd, filePcapName) @@ -303,7 +303,7 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) { if body.RunType == "stop_str" { fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId) filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId) - scriptStr := "#!/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" + scriptStr := "#!/bin/expect\n#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127 capCmdStr := body.Cmd From 36fcdb985dfad6f9e0b109ae2c75a38436fe216f Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 25 Oct 2023 20:19:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20UPF=E8=84=9A=E6=9C=AC=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=BC=BA=E5=A4=B1expect=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- features/trace/tcpdump.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/trace/tcpdump.go b/features/trace/tcpdump.go index 914dc7c0..2e985686 100644 --- a/features/trace/tcpdump.go +++ b/features/trace/tcpdump.go @@ -272,7 +272,7 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) { if body.RunType == "start_str" { fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId) filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId) - scriptStr := "#!/bin/expect\n#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" + scriptStr := "#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127 capCmdStr := fmt.Sprintf("%s file %s", body.Cmd, filePcapName) @@ -303,7 +303,7 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) { if body.RunType == "stop_str" { fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId) filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId) - scriptStr := "#!/bin/expect\n#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" + scriptStr := "#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\"" writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127 capCmdStr := body.Cmd