Skip to content

Commit

Permalink
Merge 91b9568 into 4db2113
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Dec 5, 2019
2 parents 4db2113 + 91b9568 commit a8d836c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/ndt7-client
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ the API, but we'll try not to.

## Installing

You need Go >= 1.11. We use modules. Make sure Go knows that:
You need Go >= 1.12. We use modules. Make sure Go knows that:

```bash
export GO111MODULE=on
Expand Down
12 changes: 10 additions & 2 deletions cmd/ndt7-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
//
// Usage:
//
// ndt7-client [-batch] [-hostname <name>] [-no-verify] [-timeout <string>]
// ndt7-client [-batch] [-hostname <name>] [-no-verify]
// [-scheme <scheme>] [-timeout <string>]
//
// The `-batch` flag causes the command to emit JSON messages on the
// standard output, thus allowing for easy machine parsing. The default
Expand All @@ -14,6 +15,10 @@
//
// The `-no-verify` flag allows to skip TLS certificate verification.
//
// The `-scheme <scheme>` flag allows to override the default scheme, i.e.,
// "wss", with another scheme. The only other supported scheme is "ws"
// and causes ndt7 to run unencrypted.
//
// The `-timeout <string>` flag specifies the time after which the
// whole test is interrupted. The `<string>` is a string suitable to
// be passed to time.ParseDuration, e.g., "15s". The default is a large
Expand Down Expand Up @@ -90,7 +95,9 @@ var (
flagBatch = flag.Bool("batch", false, "emit JSON events on stdout")
flagNoVerify = flag.Bool("no-verify", false, "skip TLS certificate verification")
flagHostname = flag.String("hostname", "", "optional ndt7 server hostname")
flagTimeout = flag.Duration(
flagScheme = flag.String(
"scheme", "wss", `use "wss" for encrypted ndt7, "ws" for cleartext ndt7`)
flagTimeout = flag.Duration(
"timeout", defaultTimeout, "time after which the test is aborted")
)

Expand Down Expand Up @@ -160,6 +167,7 @@ func main() {
defer cancel()
var r runner
r.client = ndt7.NewClient(clientName, clientVersion)
r.client.Scheme = *flagScheme
r.client.Dialer.TLSClientConfig = &tls.Config{
InsecureSkipVerify: *flagNoVerify,
}
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/m-lab/ndt7-client-go
go 1.12

require (
github.com/gorilla/websocket v1.4.0
github.com/m-lab/ndt-server v0.13.2
github.com/m-lab/tcp-info v1.1.0
github.com/gorilla/websocket v1.4.1
github.com/m-lab/ndt-server v0.13.4
github.com/m-lab/tcp-info v1.3.0
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/m-lab/ndt-server v0.13.2 h1:ISasCjeOXaKcHjRo//Q2A2THbwoC2Pp01d8a2OnPC6Y=
github.com/m-lab/ndt-server v0.13.2/go.mod h1:ZLVRCEbCBkhh0pwNjnLpwaZnHOHGEH76H/fzIIVFRWw=
github.com/m-lab/tcp-info v1.1.0 h1:+IzCxTd/IVRjt+EXyi4Nj1bIhuX/iftbQCFB2itrB8M=
github.com/m-lab/tcp-info v1.1.0/go.mod h1:bkvI4qbjB6QVC2tsLSHqf5OnIYcmuLEVjo7+8YA56Kg=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/m-lab/ndt-server v0.13.4 h1:0rjWbZsor6/CRxOMlWxWEq1I7GUWrNCTM6//OFNC3Yo=
github.com/m-lab/ndt-server v0.13.4/go.mod h1:ZLVRCEbCBkhh0pwNjnLpwaZnHOHGEH76H/fzIIVFRWw=
github.com/m-lab/tcp-info v1.3.0 h1:bL8ElOp5Sxc5e1W86swMv5zjh6/y1Y9qT7eEOgJnzq4=
github.com/m-lab/tcp-info v1.3.0/go.mod h1:bkvI4qbjB6QVC2tsLSHqf5OnIYcmuLEVjo7+8YA56Kg=
21 changes: 13 additions & 8 deletions ndt7.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ const DefaultWebSocketHandshakeTimeout = 7 * time.Second

// Client is a ndt7 client.
type Client struct {
// ClientName is the name of the software running ndt7 tests. It's set by
// NewClient; you may want to change this value.
ClientName string

// ClientVersion is the version of the software running ndt7 tests. It's
// set by NewClient; you may want to change this value.
ClientVersion string

// Dialer is the optional websocket Dialer. It's set to its
// default value by NewClient; you may override it.
Dialer websocket.Dialer
Expand All @@ -67,13 +75,9 @@ type Client struct {
// defaults in NewClient and you may override it.
MLabNSClient *mlabns.Client

// ClientName is the name of the software running ndt7 tests. It's set by
// NewClient; you may want to change this value.
ClientName string

// ClientVersion is the version of the software running ndt7 tests. It's
// set by NewClient; you may want to change this value.
ClientVersion string
// Scheme is the scheme to use. It's set to "wss" by NewClient,
// change it to "ws" for unencrypted ndt7.
Scheme string

// connect is the function for connecting a specific
// websocket cnnection. It's set to its default value by
Expand Down Expand Up @@ -122,6 +126,7 @@ func NewClient(clientName, clientVersion string) *Client {
"ndt7", makeUserAgent(clientName, clientVersion),
),
upload: upload.Run,
Scheme: "wss",
}
}

Expand All @@ -133,7 +138,7 @@ func (c *Client) discoverServer(ctx context.Context) (string, error) {
// doConnect establishes a websocket connection.
func (c *Client) doConnect(ctx context.Context, URLPath string) (*websocket.Conn, error) {
URL := url.URL{}
URL.Scheme = "wss"
URL.Scheme = c.Scheme
URL.Host = c.FQDN
URL.Path = URLPath
q := URL.Query()
Expand Down

0 comments on commit a8d836c

Please sign in to comment.