|
|
@ -21,7 +21,9 @@ func NewClient(host string) *Client {
|
|
|
|
streams := 1
|
|
|
|
streams := 1
|
|
|
|
c := &Client{
|
|
|
|
c := &Client{
|
|
|
|
options: &ClientOptions{
|
|
|
|
options: &ClientOptions{
|
|
|
|
JSON: &json,
|
|
|
|
SharedOptions: SharedOptions{
|
|
|
|
|
|
|
|
JSON: &json,
|
|
|
|
|
|
|
|
},
|
|
|
|
Proto: &proto,
|
|
|
|
Proto: &proto,
|
|
|
|
TimeSec: &time,
|
|
|
|
TimeSec: &time,
|
|
|
|
Length: &length,
|
|
|
|
Length: &length,
|
|
|
@ -54,8 +56,6 @@ type ClientOptions struct {
|
|
|
|
ZeroCopy *bool
|
|
|
|
ZeroCopy *bool
|
|
|
|
OmitSec *int
|
|
|
|
OmitSec *int
|
|
|
|
Prefix *string
|
|
|
|
Prefix *string
|
|
|
|
JSON *bool
|
|
|
|
|
|
|
|
LogFile *string
|
|
|
|
|
|
|
|
IncludeServer *bool
|
|
|
|
IncludeServer *bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -86,6 +86,18 @@ func (c *Client) commandString() (cmd string, err error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Fprintf(&builder, "%s -c %s", binaryLocation, c.Host())
|
|
|
|
fmt.Fprintf(&builder, "%s -c %s", binaryLocation, c.Host())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if c.options.Port != nil {
|
|
|
|
|
|
|
|
fmt.Fprintf(&builder, " -p %d", c.Port())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if c.options.Format != nil || *c.options.Format != ' ' {
|
|
|
|
|
|
|
|
fmt.Fprintf(&builder, " -f %c", c.Format())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if c.options.Interval != nil {
|
|
|
|
|
|
|
|
fmt.Fprintf(&builder, " -i %d", c.Interval())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if c.options.Proto != nil && *c.options.Proto == PROTO_UDP {
|
|
|
|
if c.options.Proto != nil && *c.options.Proto == PROTO_UDP {
|
|
|
|
fmt.Fprintf(&builder, " -u")
|
|
|
|
fmt.Fprintf(&builder, " -u")
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -176,6 +188,39 @@ func (c *Client) SetHost(host string) {
|
|
|
|
c.options.Host = &host
|
|
|
|
c.options.Host = &host
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) Port() int {
|
|
|
|
|
|
|
|
if c.options.Port == nil {
|
|
|
|
|
|
|
|
return 5201
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return *c.options.Port
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) SetPort(port int) {
|
|
|
|
|
|
|
|
c.options.Port = &port
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) Format() rune {
|
|
|
|
|
|
|
|
if c.options.Format == nil {
|
|
|
|
|
|
|
|
return ' '
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return *c.options.Format
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) SetFormat(format rune) {
|
|
|
|
|
|
|
|
c.options.Format = &format
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) Interval() int {
|
|
|
|
|
|
|
|
if c.options.Interval == nil {
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return *c.options.Interval
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) SetInterval(interval int) {
|
|
|
|
|
|
|
|
c.options.Interval = &interval
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) Proto() Protocol {
|
|
|
|
func (c *Client) Proto() Protocol {
|
|
|
|
if c.options.Proto == nil {
|
|
|
|
if c.options.Proto == nil {
|
|
|
|
return PROTO_TCP
|
|
|
|
return PROTO_TCP
|
|
|
|