added ping raw string
This commit is contained in:
parent
54f395b764
commit
56b9d39ba9
|
@ -31,6 +31,7 @@ type Summary interface {
|
|||
type Result interface {
|
||||
GetResponses() map[int]Response
|
||||
GetSummary() Summary
|
||||
GetRaw() []string
|
||||
}
|
||||
|
||||
type PingOption struct {
|
||||
|
@ -107,6 +108,7 @@ func (s *PingSummary) GetAvgTime() float32 {
|
|||
type PingResult struct {
|
||||
Responses map[int]Response `json:"responses,omitempty"`
|
||||
Summary Summary `json:"summary,omitempty"`
|
||||
Raw []string `json:"raw,omitempty"`
|
||||
}
|
||||
|
||||
func (r *PingResult) GetResponses() map[int]Response {
|
||||
|
@ -115,6 +117,9 @@ func (r *PingResult) GetResponses() map[int]Response {
|
|||
func (r *PingResult) GetSummary() Summary {
|
||||
return r.Summary
|
||||
}
|
||||
func (r *PingResult) GetRaw() []string {
|
||||
return r.Raw
|
||||
}
|
||||
|
||||
// $ ping 192.168.1.1 -c 7 -i 1 -w 0.3
|
||||
// PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
|
||||
|
@ -131,11 +136,13 @@ func parseLinuxPing(output []byte) (Result, error) {
|
|||
result := &PingResult{
|
||||
Responses: make(map[int]Response, 0),
|
||||
Summary: &PingSummary{},
|
||||
Raw: make([]string, 0),
|
||||
}
|
||||
lines := strings.Split(string(output), "\n")
|
||||
|
||||
LOOP:
|
||||
for _, line := range lines {
|
||||
result.Raw = append(result.Raw, line)
|
||||
fields := strings.Fields(line)
|
||||
switch len(fields) {
|
||||
case 5:
|
||||
|
@ -255,12 +262,14 @@ func parseWindowsPing(output []byte) (Result, error) {
|
|||
result := &PingResult{
|
||||
Responses: make(map[int]Response, 0),
|
||||
Summary: &PingSummary{},
|
||||
Raw: make([]string, 0),
|
||||
}
|
||||
lines := strings.Split(string(output), "\n")
|
||||
|
||||
seq := 1
|
||||
LOOP:
|
||||
for _, line := range lines {
|
||||
result.Raw = append(result.Raw, line)
|
||||
fields := strings.Fields(line)
|
||||
switch len(fields) {
|
||||
case 3:
|
||||
|
@ -374,11 +383,13 @@ func parseDarwinPing(output []byte) (Result, error) {
|
|||
result := &PingResult{
|
||||
Responses: make(map[int]Response, 0),
|
||||
Summary: &PingSummary{},
|
||||
Raw: make([]string, 0),
|
||||
}
|
||||
lines := strings.Split(string(output), "\n")
|
||||
|
||||
LOOP:
|
||||
for _, line := range lines {
|
||||
result.Raw = append(result.Raw, line)
|
||||
fields := strings.Fields(line)
|
||||
switch len(fields) {
|
||||
case 5:
|
||||
|
|
Loading…
Reference in New Issue
Block a user