~egtann/srp

e5fb8b44e56d3e68bf20bab27ffdbd21f83acad0 — Evan Tann 1 year, 4 months ago 59e0e09
update errors to go1.13 fmt
3 files changed, 22 insertions(+), 11 deletions(-)

M go.mod
M go.sum
M proxy.go
M go.mod => go.mod +4 -2
@@ 1,9 1,11 @@
module github.com/egtann/srp

go 1.12
go 1.13

require (
	github.com/hashicorp/go-cleanhttp v0.5.1
	github.com/rs/xid v1.2.1
	golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480
	golang.org/x/crypto v0.0.0-20190907121410-71b5226ff739
	golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 // indirect
	golang.org/x/text v0.3.2 // indirect
)

M go.sum => go.sum +12 -3
@@ 2,6 2,15 @@ github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVo
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480 h1:O5YqonU5IWby+w98jVUG9h7zlCWCcH4RHyPVReBmhzk=
golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190907121410-71b5226ff739 h1:Gc7JIyxvWgD6m+QmVryY0MstDORNYididDGxgZ6Tnpk=
golang.org/x/crypto v0.0.0-20190907121410-71b5226ff739/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

M proxy.go => proxy.go +6 -6
@@ 115,7 115,7 @@ func newRegistry(r io.Reader) (Registry, error) {
	reg := Registry{}
	err = json.Unmarshal(byt, &reg)
	if err != nil {
		return nil, fmt.Errorf("unmarshal config: %s", err)
		return nil, fmt.Errorf("unmarshal config: %w", err)
	}
	for host, v := range reg {
		if len(v.Backends) == 0 {


@@ 130,7 130,7 @@ func newRegistry(r io.Reader) (Registry, error) {
func NewRegistry(filename string) (Registry, error) {
	fi, err := os.Open(filename)
	if err != nil {
		return nil, fmt.Errorf("read file %s: %s", filename, err)
		return nil, fmt.Errorf("read file %s: %w", filename, err)
	}
	defer fi.Close()
	return newRegistry(fi)


@@ 258,17 258,17 @@ func ping(job *healthCheck) error {
	target := "http://" + job.ip + job.healthPath
	req, err := http.NewRequest("GET", target, nil)
	if err != nil {
		return fmt.Errorf("new request: %s", err)
		return fmt.Errorf("new request: %w", err)
	}
	req.Header.Add("X-Role", "srp")
	client := cleanhttp.DefaultClient()
	client.Timeout = 10 * time.Second
	resp, err := client.Do(req)
	if err != nil {
		return fmt.Errorf("do: %s", err)
		return fmt.Errorf("do: %w", err)
	}
	if err = resp.Body.Close(); err != nil {
		return fmt.Errorf("close resp body: %s", err)
		return fmt.Errorf("close resp body: %w", err)
	}
	if resp.StatusCode != http.StatusOK {
		return fmt.Errorf("expected status code 200, got %d",


@@ 310,7 310,7 @@ func retryDial(network string, endpoints []string, tries int) (net.Conn, error) 
			return conn, nil
		}
	}
	return nil, fmt.Errorf("failed dial: %s", err.Error())
	return nil, fmt.Errorf("failed dial: %w", err)
}

func min(i1, i2 int) int {