diff --git a/pkg/ping/ping.go b/pkg/ping/ping.go index 004f5c9..e86fc88 100644 --- a/pkg/ping/ping.go +++ b/pkg/ping/ping.go @@ -10,13 +10,12 @@ import ( ) // Ping ICMP Operation -func Ping(addr string, ip string, srcAddr string, count int, interval time.Duration, timeout time.Duration, icmpID int) (*PingResult, error) { +func Ping(addr string, ip string, srcAddr string, count int, timeout time.Duration, icmpID int) (*PingResult, error) { var out PingResult pingOptions := &PingOptions{} pingOptions.SetCount(count) pingOptions.SetTimeout(timeout) - pingOptions.SetInterval(interval) out, err := runPing(addr, ip, srcAddr, icmpID, pingOptions) if err != nil { @@ -26,11 +25,10 @@ func Ping(addr string, ip string, srcAddr string, count int, interval time.Durat } // PingString ICMP Operation -func PingString(addr string, ip string, srcAddr string, count int, timeout time.Duration, interval time.Duration, icmpID int) (result string, err error) { +func PingString(addr string, ip string, srcAddr string, count int, timeout time.Duration, icmpID int) (result string, err error) { pingOptions := &PingOptions{} pingOptions.SetCount(count) pingOptions.SetTimeout(timeout) - pingOptions.SetInterval(interval) var buffer bytes.Buffer buffer.WriteString(fmt.Sprintf("Start %v, PING %v (%v)\n", time.Now().Format("2006-01-02 15:04:05"), addr, addr)) @@ -57,7 +55,6 @@ func runPing(ipAddr string, ip string, srcAddr string, icmpID int, option *PingO // Avoid collisions/interference caused by multiple coroutines initiating mtr pid := icmpID timeout := option.Timeout() - interval := option.Interval() ttl := defaultTTL pingReturn := PingReturn{} @@ -83,7 +80,6 @@ func runPing(ipAddr string, ip string, srcAddr string, icmpID int, option *PingO pingReturn.success = true seq++ - time.Sleep(interval) } pingResult.Success = pingReturn.success diff --git a/pkg/ping/type.go b/pkg/ping/type.go index 2b28629..11b5824 100644 --- a/pkg/ping/type.go +++ b/pkg/ping/type.go @@ -3,7 +3,6 @@ package ping import "time" const defaultTimeout = 5 * time.Second -const defaultInterval = 10 * time.Millisecond const defaultPackerSize = 56 const defaultCount = 10 const defaultTTL = 128 @@ -42,7 +41,6 @@ type PingReturn struct { type PingOptions struct { count int timeout time.Duration - interval time.Duration packetSize int } @@ -72,19 +70,6 @@ func (options *PingOptions) SetTimeout(timeout time.Duration) { options.timeout = timeout } -// Interval Getter -func (options *PingOptions) Interval() time.Duration { - if options.interval == 0 { - options.interval = defaultInterval - } - return options.interval -} - -// SetInterval Setter -func (options *PingOptions) SetInterval(interval time.Duration) { - options.interval = interval -} - // PacketSize Getter func (options *PingOptions) PacketSize() int { if options.packetSize == 0 { diff --git a/pkg/tcp/tcp.go b/pkg/tcp/tcp.go index f0a75fd..6c54324 100644 --- a/pkg/tcp/tcp.go +++ b/pkg/tcp/tcp.go @@ -7,13 +7,12 @@ import ( ) // Port TCP Operation -func Port(destAddr string, ip string, srcAddr string, port string, interval time.Duration, timeout time.Duration) (*TCPPortReturn, error) { +func Port(destAddr string, ip string, srcAddr string, port string, timeout time.Duration) (*TCPPortReturn, error) { var out TCPPortReturn var d net.Dialer var err error tcpOptions := &TCPPortOptions{} - tcpOptions.SetInterval(interval) tcpOptions.SetTimeout(timeout) out.DestAddr = destAddr diff --git a/pkg/tcp/type.go b/pkg/tcp/type.go index 12e53a4..7053315 100644 --- a/pkg/tcp/type.go +++ b/pkg/tcp/type.go @@ -3,7 +3,6 @@ package tcp import "time" const defaultTimeout = 5 * time.Second -const defaultInterval = 10 * time.Millisecond // TCPPortReturn Calculated results type TCPPortReturn struct { @@ -18,7 +17,6 @@ type TCPPortReturn struct { // TCPPortOptions ICMP Options type TCPPortOptions struct { timeout time.Duration - interval time.Duration } // Timeout Getter @@ -33,16 +31,3 @@ func (options *TCPPortOptions) Timeout() time.Duration { func (options *TCPPortOptions) SetTimeout(timeout time.Duration) { options.timeout = timeout } - -// Interval Getter -func (options *TCPPortOptions) Interval() time.Duration { - if options.interval == 0 { - options.interval = defaultInterval - } - return options.interval -} - -// SetInterval Setter -func (options *TCPPortOptions) SetInterval(interval time.Duration) { - options.interval = interval -} diff --git a/target/target_ping.go b/target/target_ping.go index fb04e7c..4c394bc 100644 --- a/target/target_ping.go +++ b/target/target_ping.go @@ -90,7 +90,7 @@ func (t *PING) Stop() { func (t *PING) ping() { icmpID := int(t.icmpID.Get()) - data, err := ping.Ping(t.host, t.ip, t.srcAddr, t.count, t.interval, t.timeout, icmpID) + data, err := ping.Ping(t.host, t.ip, t.srcAddr, t.count, t.timeout, icmpID) if err != nil { level.Error(t.logger).Log("type", "ICMP", "func", "ping", "msg", fmt.Sprintf("%s", err)) } diff --git a/target/target_tcp.go b/target/target_tcp.go index 2a97b3c..80034c0 100644 --- a/target/target_tcp.go +++ b/target/target_tcp.go @@ -83,7 +83,7 @@ func (t *TCPPort) Stop() { } func (t *TCPPort) portCheck() { - data, err := tcp.Port(t.host, t.ip, t.srcAddr, t.port, t.interval, t.timeout) + data, err := tcp.Port(t.host, t.ip, t.srcAddr, t.port, t.timeout) if err != nil { level.Error(t.logger).Log("type", "TCP", "func", "port", "msg", fmt.Sprintf("%s", err)) }