diff --git a/core/emetric/tcpstat.go b/core/emetric/tcpstat.go index 19b46c3..b49ec05 100644 --- a/core/emetric/tcpstat.go +++ b/core/emetric/tcpstat.go @@ -219,7 +219,7 @@ func (st tcpConnectionState) String() string { // 只解析IPV4 // 34190A0A:3D2D func parseIpV4(s string) (string, error) { - if len(s) == 13 { + if len(s) != 13 { return "", fmt.Errorf("not ipv4") } hexIP := s[:len(s)-5] diff --git a/core/emetric/tcpstat_test.go b/core/emetric/tcpstat_test.go index 363be41..aa395d5 100644 --- a/core/emetric/tcpstat_test.go +++ b/core/emetric/tcpstat_test.go @@ -12,5 +12,5 @@ func Test_parsePort(t *testing.T) { //assert.Equal(t, 6379, got) got1, err1 := parseIpV4("95141EAC:18EB") assert.Equal(t, nil, err1) - assert.Equal(t, 6379, string(got1)) + assert.Equal(t, "172.30.20.149:6379", string(got1)) }