diff --git a/Dockerfile b/Dockerfile index 9aa71af..661f255 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ WORKDIR /src ADD . . RUN CGO_LDFLAGS="$(pkg-config --libs opencv4)" \ - CGO_ENABLED=1 CGO_CPPFLAGS=${CGO_CPPFLAGS} CGO_CXXFLAGS=${CGO_CXXFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -mod vendor -a ./cmd/rc-camera/ + CGO_ENABLED=1 CGO_CPPFLAGS=${CGO_CPPFLAGS} CGO_CXXFLAGS=${CGO_CXXFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -a ./cmd/rc-camera/ diff --git a/Makefile b/Makefile index f6e5ba1..3f114c6 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ .PHONY: test docker DOCKER_IMG = cyrilix/robocar-camera +TAG = latest test: - go test -mod vendor ./cmd/rc-camera ./camera + go test ./... docker: - docker buildx build . --platform linux/arm/7,linux/arm64,linux/amd64 -t ${DOCKER_IMG} --push + docker buildx build . --platform linux/arm/7,linux/arm64,linux/amd64 -t ${DOCKER_IMG}:${TAG} --push diff --git a/go.mod b/go.mod index 1469a7e..fdf7d20 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cyrilix/robocar-camera -go 1.13 +go 1.14 require ( github.com/cyrilix/robocar-base v0.1.0 @@ -9,5 +9,4 @@ require ( github.com/golang/protobuf v1.3.4 github.com/sirupsen/logrus v1.4.2 gocv.io/x/gocv v0.21.0 - golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect ) diff --git a/rc-camera b/rc-camera new file mode 100755 index 0000000..bb2cd38 Binary files /dev/null and b/rc-camera differ diff --git a/vendor/golang.org/x/net/internal/socks/socks.go b/vendor/golang.org/x/net/internal/socks/socks.go index 97db234..d93e699 100644 --- a/vendor/golang.org/x/net/internal/socks/socks.go +++ b/vendor/golang.org/x/net/internal/socks/socks.go @@ -127,7 +127,7 @@ type Dialer struct { // establishing the transport connection. ProxyDial func(context.Context, string, string) (net.Conn, error) - // AuthMethods specifies the list of request authentication + // AuthMethods specifies the list of request authention // methods. // If empty, SOCKS client requests only AuthMethodNotRequired. AuthMethods []AuthMethod @@ -224,7 +224,6 @@ func (d *Dialer) Dial(network, address string) (net.Conn, error) { return nil, &net.OpError{Op: d.cmd.String(), Net: network, Source: proxy, Addr: dst, Err: err} } if _, err := d.DialWithConn(context.Background(), c, network, address); err != nil { - c.Close() return nil, err } return c, nil diff --git a/vendor/golang.org/x/net/proxy/dial.go b/vendor/golang.org/x/net/proxy/dial.go deleted file mode 100644 index 811c2e4..0000000 --- a/vendor/golang.org/x/net/proxy/dial.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package proxy - -import ( - "context" - "net" -) - -// A ContextDialer dials using a context. -type ContextDialer interface { - DialContext(ctx context.Context, network, address string) (net.Conn, error) -} - -// Dial works like DialContext on net.Dialer but using a dialer returned by FromEnvironment. -// -// The passed ctx is only used for returning the Conn, not the lifetime of the Conn. -// -// Custom dialers (registered via RegisterDialerType) that do not implement ContextDialer -// can leak a goroutine for as long as it takes the underlying Dialer implementation to timeout. -// -// A Conn returned from a successful Dial after the context has been cancelled will be immediately closed. -func Dial(ctx context.Context, network, address string) (net.Conn, error) { - d := FromEnvironment() - if xd, ok := d.(ContextDialer); ok { - return xd.DialContext(ctx, network, address) - } - return dialContext(ctx, d, network, address) -} - -// WARNING: this can leak a goroutine for as long as the underlying Dialer implementation takes to timeout -// A Conn returned from a successful Dial after the context has been cancelled will be immediately closed. -func dialContext(ctx context.Context, d Dialer, network, address string) (net.Conn, error) { - var ( - conn net.Conn - done = make(chan struct{}, 1) - err error - ) - go func() { - conn, err = d.Dial(network, address) - close(done) - if conn != nil && ctx.Err() != nil { - conn.Close() - } - }() - select { - case <-ctx.Done(): - err = ctx.Err() - case <-done: - } - return conn, err -} diff --git a/vendor/golang.org/x/net/proxy/direct.go b/vendor/golang.org/x/net/proxy/direct.go index 3d66bde..4c5ad88 100644 --- a/vendor/golang.org/x/net/proxy/direct.go +++ b/vendor/golang.org/x/net/proxy/direct.go @@ -5,27 +5,14 @@ package proxy import ( - "context" "net" ) type direct struct{} -// Direct implements Dialer by making network connections directly using net.Dial or net.DialContext. +// Direct is a direct proxy: one that makes network connections directly. var Direct = direct{} -var ( - _ Dialer = Direct - _ ContextDialer = Direct -) - -// Dial directly invokes net.Dial with the supplied parameters. func (direct) Dial(network, addr string) (net.Conn, error) { return net.Dial(network, addr) } - -// DialContext instantiates a net.Dialer and invokes its DialContext receiver with the supplied parameters. -func (direct) DialContext(ctx context.Context, network, addr string) (net.Conn, error) { - var d net.Dialer - return d.DialContext(ctx, network, addr) -} diff --git a/vendor/golang.org/x/net/proxy/per_host.go b/vendor/golang.org/x/net/proxy/per_host.go index 573fe79..0689bb6 100644 --- a/vendor/golang.org/x/net/proxy/per_host.go +++ b/vendor/golang.org/x/net/proxy/per_host.go @@ -5,7 +5,6 @@ package proxy import ( - "context" "net" "strings" ) @@ -42,20 +41,6 @@ func (p *PerHost) Dial(network, addr string) (c net.Conn, err error) { return p.dialerForRequest(host).Dial(network, addr) } -// DialContext connects to the address addr on the given network through either -// defaultDialer or bypass. -func (p *PerHost) DialContext(ctx context.Context, network, addr string) (c net.Conn, err error) { - host, _, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - d := p.dialerForRequest(host) - if x, ok := d.(ContextDialer); ok { - return x.DialContext(ctx, network, addr) - } - return dialContext(ctx, d, network, addr) -} - func (p *PerHost) dialerForRequest(host string) Dialer { if ip := net.ParseIP(host); ip != nil { for _, net := range p.bypassNetworks { diff --git a/vendor/golang.org/x/net/proxy/proxy.go b/vendor/golang.org/x/net/proxy/proxy.go index 9ff4b9a..553ead7 100644 --- a/vendor/golang.org/x/net/proxy/proxy.go +++ b/vendor/golang.org/x/net/proxy/proxy.go @@ -15,7 +15,6 @@ import ( ) // A Dialer is a means to establish a connection. -// Custom dialers should also implement ContextDialer. type Dialer interface { // Dial connects to the given address via the proxy. Dial(network, addr string) (c net.Conn, err error) @@ -26,30 +25,21 @@ type Auth struct { User, Password string } -// FromEnvironment returns the dialer specified by the proxy-related -// variables in the environment and makes underlying connections -// directly. +// FromEnvironment returns the dialer specified by the proxy related variables in +// the environment. func FromEnvironment() Dialer { - return FromEnvironmentUsing(Direct) -} - -// FromEnvironmentUsing returns the dialer specify by the proxy-related -// variables in the environment and makes underlying connections -// using the provided forwarding Dialer (for instance, a *net.Dialer -// with desired configuration). -func FromEnvironmentUsing(forward Dialer) Dialer { allProxy := allProxyEnv.Get() if len(allProxy) == 0 { - return forward + return Direct } proxyURL, err := url.Parse(allProxy) if err != nil { - return forward + return Direct } - proxy, err := FromURL(proxyURL, forward) + proxy, err := FromURL(proxyURL, Direct) if err != nil { - return forward + return Direct } noProxy := noProxyEnv.Get() @@ -57,7 +47,7 @@ func FromEnvironmentUsing(forward Dialer) Dialer { return proxy } - perHost := NewPerHost(proxy, forward) + perHost := NewPerHost(proxy, Direct) perHost.AddFromString(noProxy) return perHost } @@ -89,13 +79,8 @@ func FromURL(u *url.URL, forward Dialer) (Dialer, error) { } switch u.Scheme { - case "socks5", "socks5h": - addr := u.Hostname() - port := u.Port() - if port == "" { - port = "1080" - } - return SOCKS5("tcp", net.JoinHostPort(addr, port), auth, forward) + case "socks5": + return SOCKS5("tcp", u.Host, auth, forward) } // If the scheme doesn't match any of the built-in schemes, see if it diff --git a/vendor/golang.org/x/net/proxy/socks5.go b/vendor/golang.org/x/net/proxy/socks5.go index c91651f..56345ec 100644 --- a/vendor/golang.org/x/net/proxy/socks5.go +++ b/vendor/golang.org/x/net/proxy/socks5.go @@ -17,14 +17,8 @@ import ( func SOCKS5(network, address string, auth *Auth, forward Dialer) (Dialer, error) { d := socks.NewDialer(network, address) if forward != nil { - if f, ok := forward.(ContextDialer); ok { - d.ProxyDial = func(ctx context.Context, network string, address string) (net.Conn, error) { - return f.DialContext(ctx, network, address) - } - } else { - d.ProxyDial = func(ctx context.Context, network string, address string) (net.Conn, error) { - return dialContext(ctx, forward, network, address) - } + d.ProxyDial = func(_ context.Context, network string, address string) (net.Conn, error) { + return forward.Dial(network, address) } } if auth != nil { diff --git a/vendor/golang.org/x/net/websocket/websocket.go b/vendor/golang.org/x/net/websocket/websocket.go index 6c45c73..1f4f7be 100644 --- a/vendor/golang.org/x/net/websocket/websocket.go +++ b/vendor/golang.org/x/net/websocket/websocket.go @@ -5,11 +5,11 @@ // Package websocket implements a client and server for the WebSocket protocol // as specified in RFC 6455. // -// This package currently lacks some features found in alternative -// and more actively maintained WebSocket packages: +// This package currently lacks some features found in an alternative +// and more actively maintained WebSocket package: // // https://godoc.org/github.com/gorilla/websocket -// https://godoc.org/nhooyr.io/websocket +// package websocket // import "golang.org/x/net/websocket" import ( diff --git a/vendor/modules.txt b/vendor/modules.txt index f0272d4..16c8896 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,21 +1,27 @@ # github.com/cyrilix/robocar-base v0.1.0 +## explicit github.com/cyrilix/robocar-base/cli github.com/cyrilix/robocar-base/service # github.com/cyrilix/robocar-protobuf/go v1.0.0 +## explicit github.com/cyrilix/robocar-protobuf/go/events # github.com/eclipse/paho.mqtt.golang v1.2.0 +## explicit github.com/eclipse/paho.mqtt.golang github.com/eclipse/paho.mqtt.golang/packets # github.com/golang/protobuf v1.3.4 +## explicit github.com/golang/protobuf/proto github.com/golang/protobuf/ptypes/timestamp # github.com/konsorten/go-windows-terminal-sequences v1.0.1 github.com/konsorten/go-windows-terminal-sequences # github.com/sirupsen/logrus v1.4.2 +## explicit github.com/sirupsen/logrus # gocv.io/x/gocv v0.21.0 +## explicit gocv.io/x/gocv -# golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 +# golang.org/x/net v0.0.0-20180906233101-161cd47e91fd golang.org/x/net/internal/socks golang.org/x/net/proxy golang.org/x/net/websocket