mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 17:30:30 +00:00
define SOCKS_PROXY in the environment to use socks.
e.g. SOCKS_PROXY=127.0.0.1:6969
This commit is contained in:
parent
24ea9db99a
commit
64c6b2d7d0
2 changed files with 19 additions and 3 deletions
1
Makefile
1
Makefile
|
@ -17,6 +17,7 @@ deps_frontend:
|
|||
|
||||
deps_backend:
|
||||
go get -u golang.org/x/tools/cmd/cover
|
||||
go get -u golang.org/x/net/proxy
|
||||
go get -u github.com/jteeuwen/go-bindata/...
|
||||
go get -u github.com/elazarl/go-bindata-assetfs/...
|
||||
go get -u github.com/drone/mq/...
|
||||
|
|
|
@ -9,9 +9,11 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/drone/drone/model"
|
||||
"golang.org/x/net/proxy"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
|
@ -76,9 +78,22 @@ func NewClientTokenTLS(uri, token string, c *tls.Config) Client {
|
|||
auther := config.Client(oauth2.NoContext, &oauth2.Token{AccessToken: token})
|
||||
if c != nil {
|
||||
if trans, ok := auther.Transport.(*oauth2.Transport); ok {
|
||||
if os.Getenv("SOCKS_PROXY") != "" {
|
||||
dialer, err := proxy.SOCKS5("tcp", os.Getenv("SOCKS_PROXY"), nil, proxy.Direct)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "can't connect to the proxy:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
trans.Base = &http.Transport{
|
||||
TLSClientConfig: c,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
Dial: dialer.Dial,
|
||||
}
|
||||
} else {
|
||||
trans.Base = &http.Transport{
|
||||
TLSClientConfig: c,
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue