Skip to content

Commit ed5e688

Browse files
committed
[*]优化协议名称逻辑,避免存在首字符为数字的协议名
1 parent eb41d44 commit ed5e688

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

gonmap.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gonmap
33
import (
44
"log"
55
"os"
6+
"regexp"
67
"strings"
78
"time"
89
)
@@ -186,6 +187,8 @@ func GuessProtocol(port int) string {
186187
return protocol
187188
}
188189

190+
var regexpFirstNum = regexp.MustCompile(`^\d`)
191+
189192
func FixProtocol(oldProtocol string) string {
190193
//进行最后输出修饰
191194
if oldProtocol == "ssl/http" {
@@ -229,6 +232,9 @@ func FixProtocol(oldProtocol string) string {
229232
return oldProtocol[4:] + "-ssl"
230233
}
231234
}
235+
if regexpFirstNum.MatchString(oldProtocol) {
236+
oldProtocol = "S" + oldProtocol
237+
}
232238
oldProtocol = strings.ReplaceAll(oldProtocol, "_", "-")
233239
return oldProtocol
234240
}

0 commit comments

Comments
 (0)