ping
This commit is contained in:
parent
aefdb4d724
commit
5f0c3e9fc6
|
@ -38,6 +38,7 @@ func processPrepacket(service *omd.Service, pingOption ounp.Option, matchCtx *os
|
|||
|
||||
LOOP:
|
||||
for indexR := 0; indexR < pingOption.GetRetry(); indexR++ {
|
||||
startTime := time.Now()
|
||||
matchCtx.InitAttribute()
|
||||
conn, err := getConnection(service, pingOption)
|
||||
if nil != err {
|
||||
|
@ -128,8 +129,9 @@ LOOP:
|
|||
conn.Close()
|
||||
|
||||
if isMatched {
|
||||
elapsed := time.Since(startTime)
|
||||
pingResult.Responses[indexR] = &ounp.PingResponse{
|
||||
Time: 0,
|
||||
Time: float32(elapsed),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +149,7 @@ func processPostpacket(service *omd.Service, pingOption ounp.Option, matchCtx *o
|
|||
|
||||
LOOP:
|
||||
for indexR := 0; indexR < pingOption.GetRetry(); indexR++ {
|
||||
startTime := time.Now()
|
||||
matchCtx.InitAttribute()
|
||||
packetCount := _matcher.PacketCount(matchCtx)
|
||||
|
||||
|
@ -215,8 +218,9 @@ LOOP:
|
|||
conn.Close()
|
||||
|
||||
if isMatched {
|
||||
elapsed := time.Since(startTime)
|
||||
pingResult.Responses[indexR] = &ounp.PingResponse{
|
||||
Time: 0,
|
||||
Time: float32(elapsed),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ func Test_processPrepacket(t *testing.T) {
|
|||
args args
|
||||
want ounp.Result
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -97,7 +97,7 @@ func Test_processPostpacket(t *testing.T) {
|
|||
args args
|
||||
want ounp.Result
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
@ -119,7 +119,7 @@ func Test_getConnection(t *testing.T) {
|
|||
want net.Conn
|
||||
wantErr bool
|
||||
}{
|
||||
// TODO: Add test cases.
|
||||
// TODO: Add test cases.
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user