rework shared config structs

main
Ben Grewell 4 years ago
parent a8e4e5c15e
commit dcfd84cf13

@ -2,7 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="fc2840de-29dc-4fca-8e0e-a283562f60ca" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/report.go" beforeDir="false" afterPath="$PROJECT_DIR$/report.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/client.go" beforeDir="false" afterPath="$PROJECT_DIR$/client.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/reporter_linux.go" beforeDir="false" afterPath="$PROJECT_DIR$/reporter_linux.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/server.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/shared.go" beforeDir="false" afterPath="$PROJECT_DIR$/shared.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

@ -21,7 +21,9 @@ func NewClient(host string) *Client {
streams := 1
c := &Client{
options: &ClientOptions{
JSON: &json,
SharedOptions: SharedOptions{
JSON: &json,
},
Proto: &proto,
TimeSec: &time,
Length: &length,
@ -54,8 +56,6 @@ type ClientOptions struct {
ZeroCopy *bool
OmitSec *int
Prefix *string
JSON *bool
LogFile *string
IncludeServer *bool
}
@ -86,6 +86,18 @@ func (c *Client) commandString() (cmd string, err error) {
}
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 {
fmt.Fprintf(&builder, " -u")
}
@ -176,6 +188,39 @@ func (c *Client) SetHost(host string) {
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 {
if c.options.Proto == nil {
return PROTO_TCP

@ -101,15 +101,15 @@ func (r *Reporter) runLogProcessor() {
omitted = true
}
report := &StreamIntervalReport{
Socket: stream,
StartInterval: float32(start),
EndInterval: float32(end),
Seconds: float32(end - start),
Bytes: int(transferedBytes),
BitsPerSecond: float64(rate),
Retransmissions: retrans,
Socket: stream,
StartInterval: float32(start),
EndInterval: float32(end),
Seconds: float32(end - start),
Bytes: int(transferedBytes),
BitsPerSecond: float64(rate),
Retransmissions: retrans,
CongestionWindow: int(cwnd),
Omitted: omitted,
Omitted: omitted,
}
r.ReportingChannel <- report
}

@ -9,7 +9,14 @@ import (
)
func NewServer() *Server {
s := &Server{}
defaultPort := 5201
defaultInterval := 1
s := &Server{
SharedOptions: SharedOptions{
Port: &defaultPort,
Interval: &defaultInterval,
},
}
s.Id = uuid.New().String()
return s
}

@ -17,6 +17,8 @@ type SharedOptions struct {
Port *int
Format *rune
Interval *int
JSON *bool
LogFile *string
}
type DebugScanner struct {

Loading…
Cancel
Save