diff --git a/CMakeLists.txt b/CMakeLists.txt index d796dc0..f61eb56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # Project version number set(PRJ_VERSION_MAJOR 9) -set(PRJ_VERSION_MINOR 44) +set(PRJ_VERSION_MINOR 45) if(WIN32 AND NOT DEFINED ENV{MSYSTEM}) message(FATAL_ERROR "Currently unsuppored environment. Use MINGW for Windows builds. CMake willl exit now.") @@ -48,9 +48,11 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-lib if(CMAKE_BUILD_TYPE STREQUAL "Debug") message(STATUS "** Debug mode") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -D_XML_DEBUG") + set(TEST_RUN_ARGS "-v") else() set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s") + set(GO_MOD_ARGS "-mod=vendor") endif() find_package(Git REQUIRED) @@ -150,43 +152,7 @@ install(FILES ${MYSQL_LIB_DIR}/../share/english/errmsg.sys DESTINATION ${PROJECT # go targets are always out of date, "go build" will figure it out ######################################################################################################## -find_package(Go 1.11 REQUIRED) - -set(GODEP_REQ_VER "0.5.0") -find_package(Godep "${GODEP_REQ_VER}") -if(NOT GODEP_FOUND) - set(G_TAG "v${GODEP_REQ_VER}") - set(G_ARCH "linux-amd64") - set(G_SHA256 "287b08291e14f1fae8ba44374b26a2b12eb941af3497ed0ca649253e21ba2f83") - - message(STATUS "Installing godep (ver ${G_TAG}) into ${PROJECT_BINARY_DIR}") - file(DOWNLOAD "https://github.com/golang/dep/releases/download/${G_TAG}/dep-${G_ARCH}" ${PROJECT_BINARY_DIR}/dep - INACTIVITY_TIMEOUT 60 - TIMEOUT 300 - STATUS DOWNLOAD_RES - EXPECTED_HASH SHA256=${G_SHA256}) - list(GET DOWNLOAD_RES 0 RES) - list(GET DOWNLOAD_RES 1 MSG) - if(RES) - message(FATAL_ERROR, "${MSG}") - endif() - execute_process(COMMAND sh -c "chmod +x ${PROJECT_BINARY_DIR}/dep" WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) - - if(EXISTS ${PROJECT_BINARY_DIR}/dep) - set(GODEP_FOUND true) - set(GODEP_EXECUTABLE ${PROJECT_BINARY_DIR}/dep) - set(GODEP_VERSION ${GODEP_REQ_VER}) - else() - message(FATAL_ERROR "Unable to obtain and install requred version of go dep. Exiting...") - endif() - - message(STATUS "Vendoring for go") - set(ENV{GOPATH} ${PROJECT_SOURCE_DIR}) - if(NOT EXISTS ${PROJECT_SOURCE_DIR}/src/inpxcreator/Gopkg.toml) - message(FATAL_ERROR "Unable to find Gopkg.toml. Exiting...") - endif() - execute_process(COMMAND ${GODEP_EXECUTABLE} ensure -vendor-only WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator") -endif() +find_package(Go 1.13 REQUIRED) if(CMAKE_CROSSCOMPILING) # Set Go target environments @@ -203,9 +169,10 @@ configure_file("${PROJECT_SOURCE_DIR}/cmake/version.go.in" "${PROJECT_SOURCE_DIR add_custom_target(bin_libget2 ALL DEPENDS gen_git_ver - COMMAND GOPATH=${PROJECT_SOURCE_DIR} GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH} + COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH} ${GO_EXECUTABLE} build -o ${PROJECT_BINARY_DIR}/libget2${CMAKE_EXECUTABLE_SUFFIX} -ldflags='-X main.LastGitCommit=\$\(shell cat ${PROJECT_BINARY_DIR}/inpxc_git_ver\)' + ${GO_MOD_ARGS} inpxcreator/cmd/libget2 COMMENT "Building libget2..." WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator") @@ -213,10 +180,43 @@ install(PROGRAMS ${PROJECT_BINARY_DIR}/libget2${CMAKE_EXECUTABLE_SUFFIX} DESTINA add_custom_target(bin_libmerge ALL DEPENDS gen_git_ver - COMMAND GOPATH=${PROJECT_SOURCE_DIR} GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH} + COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on GOOS=${CROSS_GOOS} GOARCH=${CROSS_GOARCH} ${GO_EXECUTABLE} build -o ${PROJECT_BINARY_DIR}/libmerge${CMAKE_EXECUTABLE_SUFFIX} -ldflags='-X main.LastGitCommit=\$\(shell cat ${PROJECT_BINARY_DIR}/inpxc_git_ver\)' + ${GO_MOD_ARGS} inpxcreator/cmd/libmerge COMMENT "Building libmerge..." WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator") install(PROGRAMS ${PROJECT_BINARY_DIR}/libmerge${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${DEST_DIR} CONFIGURATIONS Release) + +######################################################################################################## +# Go dependency management +######################################################################################################## + +add_custom_target(deps_print + SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod + COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod graph + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator" + COMMENT "Printing dependencies (go mod graph)" + VERBATIM) + +add_custom_target(deps_tidy + SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod + COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod tidy + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator" + COMMENT "Cleaning dependencies (go mod tidy)" + VERBATIM) + +add_custom_target(deps_verify + SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod + COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod verify + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator" + COMMENT "Verifying dependencies (go mod verify)" + VERBATIM) + +add_custom_target(deps_vendor + SOURCES ${PROJECT_SOURCE_DIR}/src/inpxcreator/go.mod + COMMAND GOPATH=${PROJECT_SOURCE_DIR} GO111MODULE=on ${GO_EXECUTABLE} mod vendor + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/src/inpxcreator" + COMMENT "Creating vendor directory (go mod vendor)" + VERBATIM) diff --git a/docker/Dockerfile.build b/docker/Dockerfile.build old mode 100644 new mode 100755 index 0158027..bd82bea --- a/docker/Dockerfile.build +++ b/docker/Dockerfile.build @@ -1,7 +1,7 @@ FROM ubuntu:16.04 RUN apt-get -qqy update &&\ -apt-get -qqy install wget curl build-essential git git-extras automake pkg-config libcurl4-openssl-dev zlib1g-dev libaio-dev libboost-all-dev p7zip-full gdb mingw-w64 binutils-mingw-w64 mingw-w64-tools libz-mingw-w64-dev +apt-get -qqy install tzdata wget curl build-essential git git-extras automake pkg-config libcurl4-openssl-dev zlib1g-dev libaio-dev libboost-all-dev p7zip-full gdb mingw-w64 binutils-mingw-w64 mingw-w64-tools libz-mingw-w64-dev WORKDIR /root/ @@ -76,9 +76,9 @@ RUN ./get-maria.sh # ---------- download golang -RUN curl -LO https://dl.google.com/go/go1.12.2.linux-amd64.tar.gz \ - && tar -xvf go1.12.2.linux-amd64.tar.gz \ - && rm go1.12.2.linux-amd64.tar.gz \ +RUN curl -LO https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz \ + && tar -xvf go1.13.1.linux-amd64.tar.gz \ + && rm go1.13.1.linux-amd64.tar.gz \ && sed -i -e '$a export PATH=$PATH:/root/go/bin' .bashrc \ && sed -i -e '$a export GOROOT=/root/go' .bashrc diff --git a/src/inpxcreator/Gopkg.lock b/src/inpxcreator/Gopkg.lock deleted file mode 100644 index 850d494..0000000 --- a/src/inpxcreator/Gopkg.lock +++ /dev/null @@ -1,31 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:40e195917a951a8bf867cd05de2a46aaf1806c50cf92eebf4c16f78cd196f747" - name = "github.com/pkg/errors" - packages = ["."] - pruneopts = "UT" - revision = "645ef00459ed84a119197bfb8d8205042c6df63d" - version = "v0.8.0" - -[[projects]] - branch = "master" - digest = "1:3fa70ba3ba75f47646d2a6ff518f46f3c4a215912eb6f9c26b6e956918038f01" - name = "golang.org/x/net" - packages = [ - "internal/socks", - "proxy", - ] - pruneopts = "UT" - revision = "146acd28ed5894421fb5aac80ca93bc1b1f46f87" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = [ - "github.com/pkg/errors", - "golang.org/x/net/proxy", - ] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/src/inpxcreator/Gopkg.toml b/src/inpxcreator/Gopkg.toml deleted file mode 100644 index 0a6d380..0000000 --- a/src/inpxcreator/Gopkg.toml +++ /dev/null @@ -1,38 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[[constraint]] - name = "github.com/pkg/errors" - version = "0.8.0" - -[[constraint]] - branch = "master" - name = "golang.org/x/net" - -[prune] - go-tests = true - unused-packages = true diff --git a/src/inpxcreator/cmd/libget2/main.go b/src/inpxcreator/cmd/libget2/main.go index c2f9a39..7309091 100644 --- a/src/inpxcreator/cmd/libget2/main.go +++ b/src/inpxcreator/cmd/libget2/main.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "strconv" "strings" "time" @@ -440,7 +441,7 @@ func main() { log.SetPrefix("\n*** ") flag.Usage = func() { - fmt.Fprintf(os.Stderr, "\nTool to download library updates\nVersion %s %s\n\n", misc.GetVersion(), LastGitCommit) + fmt.Fprintf(os.Stderr, "\nTool to download library updates\nVersion %s (%s) %s\n\n", misc.GetVersion(), runtime.Version(), LastGitCommit) fmt.Fprintf(os.Stderr, "Usage: %s [options]\n\n", os.Args[0]) flag.PrintDefaults() } diff --git a/src/inpxcreator/cmd/libmerge/main.go b/src/inpxcreator/cmd/libmerge/main.go index 99d3564..5290942 100644 --- a/src/inpxcreator/cmd/libmerge/main.go +++ b/src/inpxcreator/cmd/libmerge/main.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "regexp" + "runtime" "sort" "strconv" "strings" @@ -158,7 +159,7 @@ func main() { var code int flag.Usage = func() { - fmt.Fprintf(os.Stderr, "\nTool to merge library updates\nVersion %s %s\n\n", misc.GetVersion(), LastGitCommit) + fmt.Fprintf(os.Stderr, "\nTool to merge library updates\nVersion %s (%s) %s\n\n", misc.GetVersion(), runtime.Version(), LastGitCommit) fmt.Fprintf(os.Stderr, "Usage: %s [options]\n\n", os.Args[0]) flag.PrintDefaults() } @@ -218,7 +219,11 @@ func main() { } else { merge.begin, merge.end = last.begin, last.end if verbose { - fmt.Printf("Merge archive: %s - from %d to %d size %d\n", "**new**", merge.begin, merge.end, last.info.Size()) + var sz int64 + if last.info != nil { + sz = last.info.Size() + } + fmt.Printf("Merge archive: %s - from %d to %d size %d\n", "**new**", merge.begin, merge.end, sz) } } diff --git a/src/inpxcreator/go.mod b/src/inpxcreator/go.mod new file mode 100644 index 0000000..b87d4ed --- /dev/null +++ b/src/inpxcreator/go.mod @@ -0,0 +1,8 @@ +module inpxcreator + +go 1.13 + +require ( + github.com/pkg/errors v0.8.1 + golang.org/x/net v0.0.0-20191003171128-d98b1b443823 +) diff --git a/src/inpxcreator/go.sum b/src/inpxcreator/go.sum new file mode 100644 index 0000000..302668f --- /dev/null +++ b/src/inpxcreator/go.sum @@ -0,0 +1,7 @@ +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20191003171128-d98b1b443823 h1:Ypyv6BNJh07T1pUSrehkLemqPKXhus2MkfktJ91kRh4= +golang.org/x/net v0.0.0-20191003171128-d98b1b443823/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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/src/inpxcreator/vendor/github.com/pkg/errors/.travis.yml b/src/inpxcreator/vendor/github.com/pkg/errors/.travis.yml index 588ceca..d4b9266 100644 --- a/src/inpxcreator/vendor/github.com/pkg/errors/.travis.yml +++ b/src/inpxcreator/vendor/github.com/pkg/errors/.travis.yml @@ -1,10 +1,14 @@ language: go go_import_path: github.com/pkg/errors go: - - 1.4.3 - - 1.5.4 - - 1.6.2 - - 1.7.1 + - 1.4.x + - 1.5.x + - 1.6.x + - 1.7.x + - 1.8.x + - 1.9.x + - 1.10.x + - 1.11.x - tip script: diff --git a/src/inpxcreator/vendor/github.com/pkg/errors/README.md b/src/inpxcreator/vendor/github.com/pkg/errors/README.md index 273db3c..6483ba2 100644 --- a/src/inpxcreator/vendor/github.com/pkg/errors/README.md +++ b/src/inpxcreator/vendor/github.com/pkg/errors/README.md @@ -1,4 +1,4 @@ -# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) +# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) Package errors provides simple error handling primitives. @@ -47,6 +47,6 @@ We welcome pull requests, bug fixes and issue reports. With that said, the bar f Before proposing a change, please discuss your change by raising an issue. -## Licence +## License BSD-2-Clause diff --git a/src/inpxcreator/vendor/github.com/pkg/errors/errors.go b/src/inpxcreator/vendor/github.com/pkg/errors/errors.go index 842ee80..7421f32 100644 --- a/src/inpxcreator/vendor/github.com/pkg/errors/errors.go +++ b/src/inpxcreator/vendor/github.com/pkg/errors/errors.go @@ -6,7 +6,7 @@ // return err // } // -// which applied recursively up the call stack results in error reports +// which when applied recursively up the call stack results in error reports // without context or debugging information. The errors package allows // programmers to add context to the failure path in their code in a way // that does not destroy the original value of the error. @@ -15,16 +15,17 @@ // // The errors.Wrap function returns a new error that adds context to the // original error by recording a stack trace at the point Wrap is called, -// and the supplied message. For example +// together with the supplied message. For example // // _, err := ioutil.ReadAll(r) // if err != nil { // return errors.Wrap(err, "read failed") // } // -// If additional control is required the errors.WithStack and errors.WithMessage -// functions destructure errors.Wrap into its component operations of annotating -// an error with a stack trace and an a message, respectively. +// If additional control is required, the errors.WithStack and +// errors.WithMessage functions destructure errors.Wrap into its component +// operations: annotating an error with a stack trace and with a message, +// respectively. // // Retrieving the cause of an error // @@ -38,7 +39,7 @@ // } // // can be inspected by errors.Cause. errors.Cause will recursively retrieve -// the topmost error which does not implement causer, which is assumed to be +// the topmost error that does not implement causer, which is assumed to be // the original cause. For example: // // switch err := errors.Cause(err).(type) { @@ -48,16 +49,16 @@ // // unknown error // } // -// causer interface is not exported by this package, but is considered a part -// of stable public API. +// Although the causer interface is not exported by this package, it is +// considered a part of its stable public interface. // // Formatted printing of errors // // All error values returned from this package implement fmt.Formatter and can -// be formatted by the fmt package. The following verbs are supported +// be formatted by the fmt package. The following verbs are supported: // // %s print the error. If the error has a Cause it will be -// printed recursively +// printed recursively. // %v see %s // %+v extended format. Each Frame of the error's StackTrace will // be printed in detail. @@ -65,13 +66,13 @@ // Retrieving the stack trace of an error or wrapper // // New, Errorf, Wrap, and Wrapf record a stack trace at the point they are -// invoked. This information can be retrieved with the following interface. +// invoked. This information can be retrieved with the following interface: // // type stackTracer interface { // StackTrace() errors.StackTrace // } // -// Where errors.StackTrace is defined as +// The returned errors.StackTrace type is defined as // // type StackTrace []Frame // @@ -85,8 +86,8 @@ // } // } // -// stackTracer interface is not exported by this package, but is considered a part -// of stable public API. +// Although the stackTracer interface is not exported by this package, it is +// considered a part of its stable public interface. // // See the documentation for Frame.Format for more details. package errors @@ -192,7 +193,7 @@ func Wrap(err error, message string) error { } // Wrapf returns an error annotating err with a stack trace -// at the point Wrapf is call, and the format specifier. +// at the point Wrapf is called, and the format specifier. // If err is nil, Wrapf returns nil. func Wrapf(err error, format string, args ...interface{}) error { if err == nil { @@ -220,6 +221,18 @@ func WithMessage(err error, message string) error { } } +// WithMessagef annotates err with the format specifier. +// If err is nil, WithMessagef returns nil. +func WithMessagef(err error, format string, args ...interface{}) error { + if err == nil { + return nil + } + return &withMessage{ + cause: err, + msg: fmt.Sprintf(format, args...), + } +} + type withMessage struct { cause error msg string diff --git a/src/inpxcreator/vendor/github.com/pkg/errors/stack.go b/src/inpxcreator/vendor/github.com/pkg/errors/stack.go index 6b1f289..2874a04 100644 --- a/src/inpxcreator/vendor/github.com/pkg/errors/stack.go +++ b/src/inpxcreator/vendor/github.com/pkg/errors/stack.go @@ -46,7 +46,8 @@ func (f Frame) line() int { // // Format accepts flags that alter the printing of some verbs, as follows: // -// %+s path of source file relative to the compile time GOPATH +// %+s function name and path of source file relative to the compile time +// GOPATH separated by \n\t (\n\t) // %+v equivalent to %+s:%d func (f Frame) Format(s fmt.State, verb rune) { switch verb { @@ -79,6 +80,14 @@ func (f Frame) Format(s fmt.State, verb rune) { // StackTrace is stack of Frames from innermost (newest) to outermost (oldest). type StackTrace []Frame +// Format formats the stack of Frames according to the fmt.Formatter interface. +// +// %s lists source files for each Frame in the stack +// %v lists the source file and line number for each Frame in the stack +// +// Format accepts flags that alter the printing of some verbs, as follows: +// +// %+v Prints filename, function, and line number for each Frame in the stack. func (st StackTrace) Format(s fmt.State, verb rune) { switch verb { case 'v': @@ -136,43 +145,3 @@ func funcname(name string) string { i = strings.Index(name, ".") return name[i+1:] } - -func trimGOPATH(name, file string) string { - // Here we want to get the source file path relative to the compile time - // GOPATH. As of Go 1.6.x there is no direct way to know the compiled - // GOPATH at runtime, but we can infer the number of path segments in the - // GOPATH. We note that fn.Name() returns the function name qualified by - // the import path, which does not include the GOPATH. Thus we can trim - // segments from the beginning of the file path until the number of path - // separators remaining is one more than the number of path separators in - // the function name. For example, given: - // - // GOPATH /home/user - // file /home/user/src/pkg/sub/file.go - // fn.Name() pkg/sub.Type.Method - // - // We want to produce: - // - // pkg/sub/file.go - // - // From this we can easily see that fn.Name() has one less path separator - // than our desired output. We count separators from the end of the file - // path until it finds two more than in the function name and then move - // one character forward to preserve the initial path segment without a - // leading separator. - const sep = "/" - goal := strings.Count(name, sep) + 2 - i := len(file) - for n := 0; n < goal; n++ { - i = strings.LastIndex(file[:i], sep) - if i == -1 { - // not enough separators found, set i so that the slice expression - // below leaves file unmodified - i = -len(sep) - break - } - } - // get back to 0 or trim the leading separator - file = file[i+len(sep):] - return file -} diff --git a/src/inpxcreator/vendor/golang.org/x/net/internal/socks/socks.go b/src/inpxcreator/vendor/golang.org/x/net/internal/socks/socks.go index 6929a9f..97db234 100644 --- a/src/inpxcreator/vendor/golang.org/x/net/internal/socks/socks.go +++ b/src/inpxcreator/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 authention + // AuthMethods specifies the list of request authentication // methods. // If empty, SOCKS client requests only AuthMethodNotRequired. AuthMethods []AuthMethod diff --git a/src/inpxcreator/vendor/golang.org/x/net/proxy/dial.go b/src/inpxcreator/vendor/golang.org/x/net/proxy/dial.go new file mode 100644 index 0000000..811c2e4 --- /dev/null +++ b/src/inpxcreator/vendor/golang.org/x/net/proxy/dial.go @@ -0,0 +1,54 @@ +// 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/src/inpxcreator/vendor/golang.org/x/net/proxy/direct.go b/src/inpxcreator/vendor/golang.org/x/net/proxy/direct.go index 4c5ad88..3d66bde 100644 --- a/src/inpxcreator/vendor/golang.org/x/net/proxy/direct.go +++ b/src/inpxcreator/vendor/golang.org/x/net/proxy/direct.go @@ -5,14 +5,27 @@ package proxy import ( + "context" "net" ) type direct struct{} -// Direct is a direct proxy: one that makes network connections directly. +// Direct implements Dialer by making network connections directly using net.Dial or net.DialContext. 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/src/inpxcreator/vendor/golang.org/x/net/proxy/per_host.go b/src/inpxcreator/vendor/golang.org/x/net/proxy/per_host.go index 0689bb6..573fe79 100644 --- a/src/inpxcreator/vendor/golang.org/x/net/proxy/per_host.go +++ b/src/inpxcreator/vendor/golang.org/x/net/proxy/per_host.go @@ -5,6 +5,7 @@ package proxy import ( + "context" "net" "strings" ) @@ -41,6 +42,20 @@ 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/src/inpxcreator/vendor/golang.org/x/net/proxy/proxy.go b/src/inpxcreator/vendor/golang.org/x/net/proxy/proxy.go index 553ead7..9ff4b9a 100644 --- a/src/inpxcreator/vendor/golang.org/x/net/proxy/proxy.go +++ b/src/inpxcreator/vendor/golang.org/x/net/proxy/proxy.go @@ -15,6 +15,7 @@ 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) @@ -25,21 +26,30 @@ type Auth struct { User, Password string } -// FromEnvironment returns the dialer specified by the proxy related variables in -// the environment. +// FromEnvironment returns the dialer specified by the proxy-related +// variables in the environment and makes underlying connections +// directly. 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 Direct + return forward } proxyURL, err := url.Parse(allProxy) if err != nil { - return Direct + return forward } - proxy, err := FromURL(proxyURL, Direct) + proxy, err := FromURL(proxyURL, forward) if err != nil { - return Direct + return forward } noProxy := noProxyEnv.Get() @@ -47,7 +57,7 @@ func FromEnvironment() Dialer { return proxy } - perHost := NewPerHost(proxy, Direct) + perHost := NewPerHost(proxy, forward) perHost.AddFromString(noProxy) return perHost } @@ -79,8 +89,13 @@ func FromURL(u *url.URL, forward Dialer) (Dialer, error) { } switch u.Scheme { - case "socks5": - return SOCKS5("tcp", u.Host, auth, forward) + case "socks5", "socks5h": + addr := u.Hostname() + port := u.Port() + if port == "" { + port = "1080" + } + return SOCKS5("tcp", net.JoinHostPort(addr, port), auth, forward) } // If the scheme doesn't match any of the built-in schemes, see if it diff --git a/src/inpxcreator/vendor/golang.org/x/net/proxy/socks5.go b/src/inpxcreator/vendor/golang.org/x/net/proxy/socks5.go index 56345ec..c91651f 100644 --- a/src/inpxcreator/vendor/golang.org/x/net/proxy/socks5.go +++ b/src/inpxcreator/vendor/golang.org/x/net/proxy/socks5.go @@ -17,8 +17,14 @@ import ( func SOCKS5(network, address string, auth *Auth, forward Dialer) (Dialer, error) { d := socks.NewDialer(network, address) if forward != nil { - d.ProxyDial = func(_ context.Context, network string, address string) (net.Conn, error) { - return forward.Dial(network, address) + 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) + } } } if auth != nil { diff --git a/src/inpxcreator/vendor/modules.txt b/src/inpxcreator/vendor/modules.txt new file mode 100644 index 0000000..fc5e83c --- /dev/null +++ b/src/inpxcreator/vendor/modules.txt @@ -0,0 +1,5 @@ +# github.com/pkg/errors v0.8.1 +github.com/pkg/errors +# golang.org/x/net v0.0.0-20191003171128-d98b1b443823 +golang.org/x/net/proxy +golang.org/x/net/internal/socks