Skip to content

Commit

Permalink
v0.1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
thalesfsp committed Feb 22, 2022
1 parent 3ef1697 commit d0d053d
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17

- name: Setup golangci-lint
uses: golangci/[email protected]
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Load config from Config file, and from env vars. Use viper for that
- Automatically alocates a random port, if the specified one is in-use

## [0.1.14] - 2022-02-22
## Changed
- Updated dependencies

## [0.1.13] - 2022-02-14
### Changed
- Upgraded PACMan version
Expand Down
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Note: Can't setup upstream, and PAC at the same time.
ProxyLocalhost: proxyLocalhost,
})
if err != nil {
cliLogger.Fatalln(customerror.NewFailedToError("run", "", err))
cliLogger.Fatalln(customerror.NewFailedToError("run", customerror.WithError(err)))
}

p.Run()
Expand Down
32 changes: 27 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
module github.com/saucelabs/forwarder

go 1.16
go 1.17

require (
github.com/eapache/go-resiliency v1.2.0
github.com/elazarl/goproxy v0.0.0-20220115173737-adb46da277ac
github.com/elazarl/goproxy/ext v0.0.0-20220115173737-adb46da277ac
github.com/go-playground/validator/v10 v10.10.0
github.com/saucelabs/customerror v0.0.2
github.com/saucelabs/pacman v0.0.12
github.com/saucelabs/randomness v0.0.4
github.com/saucelabs/sypl v1.5.8
github.com/saucelabs/customerror v1.0.3
github.com/saucelabs/pacman v0.0.13
github.com/saucelabs/randomness v0.0.5
github.com/saucelabs/sypl v1.5.10
github.com/spf13/cobra v1.3.0
)

require (
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 // indirect
github.com/dop251/goja v0.0.0-20211006122547-7efcb634c641 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/saucelabs/lumberjack/v3 v3.0.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
golang.org/x/text v0.3.7 // indirect
)
19 changes: 8 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.9.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
Expand Down Expand Up @@ -346,19 +345,17 @@ github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6po
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig=
github.com/saucelabs/customerror v0.0.1/go.mod h1:2yuCW9Zn8tdbHl1EwRP2waQ0aLXSyc9Ygr5ZDozH9KE=
github.com/saucelabs/customerror v0.0.2 h1:vaSkRQ+yulL/vODN8CFAsqHrZaOo2zjEZbyTGBo4aQ0=
github.com/saucelabs/customerror v0.0.2/go.mod h1:2yuCW9Zn8tdbHl1EwRP2waQ0aLXSyc9Ygr5ZDozH9KE=
github.com/saucelabs/customerror v1.0.3 h1:LfQUuQ9iK6/ExBzRXgLFKx0SLAVmz1s1P2HYXz1JOa8=
github.com/saucelabs/customerror v1.0.3/go.mod h1:16/zfic7+i7QHOi+i7IQC5/6aL4HYOLocOtjXOM0KXY=
github.com/saucelabs/lumberjack/v3 v3.0.2 h1:d2xl3L4gtuwhFOnBEWTcTRxZ64wQWyFfUK8cadpe5NA=
github.com/saucelabs/lumberjack/v3 v3.0.2/go.mod h1:YWvEpPjHrjk7jKET9K4Vphyk6RFlXFD1e/rP60Fr+JA=
github.com/saucelabs/pacman v0.0.12 h1:znbDzxae397HJWYKgL9wtn/5ayqcSXDHTwVMUTXVV4Q=
github.com/saucelabs/pacman v0.0.12/go.mod h1:sCeAjm0QyXSSpqcNyUoGYQuPuqm7c1fGVelv6d9G0BQ=
github.com/saucelabs/randomness v0.0.4 h1:zstiPWKOttu3l1lTCzDenG6QGshB8PvqUMNCLOXezUw=
github.com/saucelabs/randomness v0.0.4/go.mod h1:7G1I9BSE1Tw1/Q8hx5lmLV57Rda0CCXm8BRH/FiWYEw=
github.com/saucelabs/sypl v1.5.3/go.mod h1:ubSLpo9I9awtabutiS6Npjof7s/km+HJ/9aOOPClMW0=
github.com/saucelabs/sypl v1.5.4/go.mod h1:ubSLpo9I9awtabutiS6Npjof7s/km+HJ/9aOOPClMW0=
github.com/saucelabs/sypl v1.5.8 h1:i1BHqq/pq/ZNKHB8Xaww83yITjU8EnDfrcBZegDSWBY=
github.com/saucelabs/pacman v0.0.13 h1:kdHLdZCminN/TGbKgXncZvXATNT7NTbXtVAfJQpVAlQ=
github.com/saucelabs/pacman v0.0.13/go.mod h1:CiqtUweQyceGUDccdu65+LK+UxUzfERJFILMwoyQ5us=
github.com/saucelabs/randomness v0.0.5 h1:IBgMdKOWb4zCKUbQ03tTjIUXZcxG1rT/cH1iggYjCJE=
github.com/saucelabs/randomness v0.0.5/go.mod h1:jleEVfS8aVUKZ6Js4NTnqqM62SyvAaiRs23WEgckP+g=
github.com/saucelabs/sypl v1.5.8/go.mod h1:ubSLpo9I9awtabutiS6Npjof7s/km+HJ/9aOOPClMW0=
github.com/saucelabs/sypl v1.5.10 h1:EptSBygwDminwfyg9SJP81ZwNcazX+1x1P4HWi18nkI=
github.com/saucelabs/sypl v1.5.10/go.mod h1:ubSLpo9I9awtabutiS6Npjof7s/km+HJ/9aOOPClMW0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
Expand Down
6 changes: 3 additions & 3 deletions internal/credential/basicauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

var (
ErrMissingCredential = customerror.NewMissingError("credential", "", nil)
ErrUsernamePasswordRequired = customerror.NewRequiredError("username, and password are", "", nil)
ErrMissingCredential = customerror.NewMissingError("credential")
ErrUsernamePasswordRequired = customerror.NewRequiredError("username, and password are")
)

// BasicAuth is the basic authentication credential definition.
Expand Down Expand Up @@ -58,7 +58,7 @@ func NewBasicAuth(username, password string) (*BasicAuth, error) {
}

if err := validator.New().Struct(bC); err != nil {
return nil, customerror.NewInvalidError("credential", "", err)
return nil, customerror.NewInvalidError("credential", customerror.WithError(err))
}

return bC, nil
Expand Down
10 changes: 5 additions & 5 deletions internal/pac/pac.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

var (
ErrFailedToCreateParser = customerror.NewFailedToError("create PAC parser", "", nil)
ErrFailedToFindParserNil = customerror.NewFailedToError("PAC parser isn't initialized", "", nil)
ErrFailedToFindURL = customerror.NewFailedToError("find URL", "", nil)
ErrFailedToParseURI = customerror.NewFailedToError("parse URI", "", nil)
ErrInvalidParams = customerror.NewInvalidError("params", "", nil)
ErrFailedToCreateParser = customerror.NewFailedToError("create PAC parser")
ErrFailedToFindParserNil = customerror.NewFailedToError("PAC parser isn't initialized")
ErrFailedToFindURL = customerror.NewFailedToError("find URL")
ErrFailedToParseURI = customerror.NewFailedToError("parse URI")
ErrInvalidParams = customerror.NewInvalidError("params")
)

// Type aliasing.
Expand Down
27 changes: 13 additions & 14 deletions pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ const (
)

var (
ErrFailedToAllocatePort = customerror.New("No available port to use", "", http.StatusInternalServerError, nil)
ErrFailedToDialToDNS = customerror.NewFailedToError("dial to DNS", "", nil)
ErrFailedToStartProxy = customerror.NewFailedToError("start proxy", "", nil)
ErrInvalidDNSURI = customerror.NewInvalidError("dns URI", "", nil)
ErrInvalidLocalProxyURI = customerror.NewInvalidError("local proxy URI", "", nil)
ErrInvalidOrParentOrPac = customerror.NewInvalidError("params. Can't set upstream proxy, and PAC at the same time", "", nil)
ErrInvalidPACProxyURI = customerror.NewInvalidError("PAC proxy URI", "", nil)
ErrInvalidPACURI = customerror.NewInvalidError("PAC URI", "", nil)
ErrInvalidProxyParams = customerror.NewInvalidError("params", "", nil)
ErrInvalidUpstreamProxyURI = customerror.NewInvalidError("upstream proxy URI", "", nil)
ErrFailedToAllocatePort = customerror.New("No available port to use", customerror.WithStatusCode(http.StatusInternalServerError))
ErrFailedToDialToDNS = customerror.NewFailedToError("dial to DNS")
ErrFailedToStartProxy = customerror.NewFailedToError("start proxy")
ErrInvalidDNSURI = customerror.NewInvalidError("dns URI")
ErrInvalidLocalProxyURI = customerror.NewInvalidError("local proxy URI")
ErrInvalidOrParentOrPac = customerror.NewInvalidError("params. Can't set upstream proxy, and PAC at the same time")
ErrInvalidPACProxyURI = customerror.NewInvalidError("PAC proxy URI")
ErrInvalidPACURI = customerror.NewInvalidError("PAC URI")
ErrInvalidProxyParams = customerror.NewInvalidError("params")
ErrInvalidUpstreamProxyURI = customerror.NewInvalidError("upstream proxy URI")
)

// LoggingOptions defines logging options.
Expand Down Expand Up @@ -268,7 +268,7 @@ func setupDNS(mutex *sync.RWMutex, dnsURIs []string) error {
if err != nil {
errMsg := fmt.Sprintf("dial to DNS @ %s", parsedDNSURI.String())

logger.Get().Tracelnf(customerror.NewFailedToError(errMsg, "", err).Error())
logger.Get().Tracelnf(customerror.NewFailedToError(errMsg, customerror.WithError(err)).Error())
} else {
logger.Get().Tracelnf("Request resolved by DNS @ %s", parsedDNSURI)

Expand All @@ -279,9 +279,8 @@ func setupDNS(mutex *sync.RWMutex, dnsURIs []string) error {
if finalError != nil {
ErrAllDNSResolversFailed := customerror.New(
"All DNS resolvers failed",
"",
http.StatusInternalServerError,
finalError,
customerror.WithStatusCode(http.StatusInternalServerError),
customerror.WithError(finalError),
)

logger.Get().Traceln(ErrAllDNSResolversFailed)
Expand Down
4 changes: 2 additions & 2 deletions pkg/proxy/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/saucelabs/forwarder/internal/validation"
)

var ErrFailedToCopyOptions = customerror.NewFailedToError("deepCopy options", "", nil)
var ErrFailedToCopyOptions = customerror.NewFailedToError("deepCopy options")

// Loads, validate credential from env var, and set URI's user.
func loadCredentialFromEnvVar(envVar string, uri *url.URL) error {
Expand All @@ -22,7 +22,7 @@ func loadCredentialFromEnvVar(envVar string, uri *url.URL) error {
if err := validation.Get().Var(credentialFromEnvVar, "basicAuth"); err != nil {
errMsg := fmt.Sprintf("env var (%s)", envVar)

return customerror.NewInvalidError(errMsg, "", err)
return customerror.NewInvalidError(errMsg, customerror.WithError(err))
}

cred := strings.Split(credentialFromEnvVar, ":")
Expand Down

0 comments on commit d0d053d

Please sign in to comment.