fix:“RawConn 不稳定导致连接被误杀

This commit is contained in:
nnbcccscdscdsc
2026-03-23 22:04:09 +08:00
parent 32e77df476
commit ce84ddb591
3 changed files with 43 additions and 2 deletions

View File

@@ -97,7 +97,7 @@ func main() {
}
log.Printf("sent file %s to %s", *filePath, *targetPeer)
}
//交互式模式:如果启用了交互式模式,则启动一个 REPL 循环,允许用户在命令行输入多条发送文本或文件的命令,直到用户输入退出命令或接收循环发生错误。如果没有启用交互式模式,则等待接收循环结束,如果接收循环发生错误,则打印错误日志。
if *interactive {
if err := runInteractiveShell(client, os.Stdin, os.Stdout, receiveErr); err != nil {
log.Printf("interactive shell ended: %v", err)
@@ -110,6 +110,7 @@ func main() {
}
}
// 在终端面板中打印报错和交互消息
func runInteractiveShell(client *peerpkg.Client, in io.Reader, out io.Writer, receiveErr <-chan error) error {
printInteractiveHelp(out)
lines, inputErr := readInteractiveLines(in, out, fmt.Sprintf("%s> ", client.ID()))