fix web result protocol output (#577)
测试构建 / 代码检查 (push) Has been cancelled
测试构建 / 单元测试和构建 (push) Has been cancelled
测试构建 / 构建验证 (push) Has been cancelled

This commit is contained in:
ZacharyZcR
2026-05-11 18:37:40 +08:00
parent 5a8583a195
commit 265e855fc3
5 changed files with 84 additions and 15 deletions
+9 -1
View File
@@ -3,6 +3,7 @@ package core
import (
"context"
"fmt"
"net/url"
"os"
"os/signal"
"sync"
@@ -340,9 +341,16 @@ var resultSerializers = map[plugins.ResultType]resultSerializer{
plugins.ResultTypeWeb: {
outputType: output.TypeService,
getStatus: func(_ *plugins.Result, _ *common.HostInfo) string { return "web" },
fillDetail: func(_ *plugins.Result, info *common.HostInfo, d map[string]interface{}) {
fillDetail: func(r *plugins.Result, info *common.HostInfo, d map[string]interface{}) {
d["is_web"] = true
d["port"] = info.Port
if r.Output == "" {
return
}
d["url"] = r.Output
if parsed, err := url.Parse(r.Output); err == nil && (parsed.Scheme == "http" || parsed.Scheme == "https") {
d["protocol"] = parsed.Scheme
}
},
},
}