Skip to content

Commit

Permalink
Add tests around DialTimeout and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
film42 committed Jul 22, 2017
1 parent 61826d4 commit b4815ff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ $ docker run -p 26000:26000 -d film42/turbulence:latest --config test/config.jso
Usage of ./turbulence:
-config string
config file
-dial-timeout int
timeout for connecting to an upstream server in seconds (default 30)
-password string
password for proxy authentication
-port int
listen port (default 25000)
-strip-proxy-headers
strip proxy headers from http requests (default true)
-use-incoming-local-addr
Attempt to use the local address of the incoming connection when connecting upstream (default true)
attempt to use the local address of the incoming connection when connecting upstream (default true)
-username string
username for proxy authentication
```
Expand All @@ -48,6 +50,7 @@ example config:
"port": 9000,
"strip_proxy_headers": true,
"use_incoming_local_addr": true,
"dial_timeout": 30,
"credentials": [
{
"username": "ron.swanson",
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Config struct {
StripProxyHeaders bool `json:"strip_proxy_headers"`
Port int
UseIncomingLocalAddr bool `json:"use_incoming_local_addr"`
DialTimeout int
DialTimeout int `json:"dial_timeout"`
}

func (config *Config) AuthenticationRequired() bool {
Expand Down
4 changes: 4 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func TestLoadingConfigFromFile(t *testing.T) {
t.Fatal("Expected port to be 26000 but found:", sampleConfig.Port)
}

if sampleConfig.DialTimeout != 10 {
t.Fatal("Expected port to be 10 but found:", sampleConfig.DialTimeout)
}

if !sampleConfig.StripProxyHeaders {
t.Fatal("Expected sampleConfig.StripProxyHeaders to be true")
}
Expand Down
1 change: 1 addition & 0 deletions test/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"port": 26000,
"strip_proxy_headers": true,
"use_incoming_local_addr": false,
"dial_timeout": 10,
"credentials": [
{
"username": "login",
Expand Down

0 comments on commit b4815ff

Please sign in to comment.