Skip to content

Commit

Permalink
[*]优化协议名称逻辑,避免存在首字符为数字的协议名
Browse files Browse the repository at this point in the history
  • Loading branch information
lcvvvv committed Nov 4, 2022
1 parent eb41d44 commit ed5e688
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gonmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gonmap
import (
"log"
"os"
"regexp"
"strings"
"time"
)
Expand Down Expand Up @@ -186,6 +187,8 @@ func GuessProtocol(port int) string {
return protocol
}

var regexpFirstNum = regexp.MustCompile(`^\d`)

func FixProtocol(oldProtocol string) string {
//进行最后输出修饰
if oldProtocol == "ssl/http" {
Expand Down Expand Up @@ -229,6 +232,9 @@ func FixProtocol(oldProtocol string) string {
return oldProtocol[4:] + "-ssl"
}
}
if regexpFirstNum.MatchString(oldProtocol) {
oldProtocol = "S" + oldProtocol
}
oldProtocol = strings.ReplaceAll(oldProtocol, "_", "-")
return oldProtocol
}

0 comments on commit ed5e688

Please sign in to comment.