added no_proxy
This commit is contained in:
+48
-22
@@ -397,6 +397,52 @@ func checkUsername(Username string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isNoProxy(rawURL string) bool {
|
||||||
|
noProxy := os.Getenv("NO_PROXY")
|
||||||
|
if noProxy == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if noProxy == "*" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
noProxyList := strings.Split(noProxy, ",")
|
||||||
|
parsedURL, err := url.Parse(rawURL)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
host := parsedURL.Hostname()
|
||||||
|
|
||||||
|
for _,value := range noProxyList {
|
||||||
|
value = strings.TrimSpace(value)
|
||||||
|
|
||||||
|
if host == value {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(value, "*.") && strings.HasSuffix(host, value[2:]){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkGitProxy(cloneOptions *git.CloneOptions) *git.CloneOptions {
|
||||||
|
if os.Getenv("HTTP_PROXY") != "" && !isNoProxy(cloneOptions.URL){
|
||||||
|
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
||||||
|
URL: os.Getenv("HTTP_PROXY"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.Getenv("HTTPS_PROXY") != "" && !isNoProxy(cloneOptions.URL) {
|
||||||
|
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
||||||
|
URL: os.Getenv("HTTPS_PROXY"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cloneOptions
|
||||||
|
}
|
||||||
|
|
||||||
func createNewUser(username, password, role, apikey string, org shuffle.OrgMini) error {
|
func createNewUser(username, password, role, apikey string, org shuffle.OrgMini) error {
|
||||||
// Returns false if there is an issue
|
// Returns false if there is an issue
|
||||||
// Use this for register
|
// Use this for register
|
||||||
@@ -4239,18 +4285,7 @@ func runInitEs(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("HTTP_PROXY") != "" {
|
cloneOptions = checkGitProxy(cloneOptions)
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTP_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Getenv("HTTPS_PROXY") != "" {
|
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTPS_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
branch := os.Getenv("SHUFFLE_DOWNLOAD_AUTH_BRANCH")
|
branch := os.Getenv("SHUFFLE_DOWNLOAD_AUTH_BRANCH")
|
||||||
if len(branch) > 0 && branch != "master" && branch != "main" {
|
if len(branch) > 0 && branch != "master" && branch != "main" {
|
||||||
@@ -4297,17 +4332,8 @@ func runInitEs(ctx context.Context) {
|
|||||||
URL: apis,
|
URL: apis,
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("HTTP_PROXY") != "" {
|
cloneOptions = checkGitProxy(cloneOptions)
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTP_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Getenv("HTTPS_PROXY") != "" {
|
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTPS_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_, err = git.Clone(storer, fs, cloneOptions)
|
_, err = git.Clone(storer, fs, cloneOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERROR] Failed loading repo %s into memory: %s", apis, err)
|
log.Printf("[ERROR] Failed loading repo %s into memory: %s", apis, err)
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import (
|
|||||||
"github.com/go-git/go-billy/v5/memfs"
|
"github.com/go-git/go-billy/v5/memfs"
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
gitProxy "github.com/go-git/go-git/v5/plumbing/transport"
|
|
||||||
"github.com/go-git/go-git/v5/storage/memory"
|
"github.com/go-git/go-git/v5/storage/memory"
|
||||||
http2 "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
http2 "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
||||||
|
|
||||||
@@ -2647,18 +2646,6 @@ func loadGithubWorkflows(url, username, password, userId, branch, orgId string)
|
|||||||
URL: url,
|
URL: url,
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("HTTP_PROXY") != "" {
|
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTP_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Getenv("HTTPS_PROXY") != "" {
|
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTPS_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Better auth.
|
// FIXME: Better auth.
|
||||||
if len(username) > 0 && len(password) > 0 {
|
if len(username) > 0 && len(password) > 0 {
|
||||||
cloneOptions.Auth = &http2.BasicAuth{
|
cloneOptions.Auth = &http2.BasicAuth{
|
||||||
@@ -2673,6 +2660,8 @@ func loadGithubWorkflows(url, username, password, userId, branch, orgId string)
|
|||||||
cloneOptions.ReferenceName = plumbing.ReferenceName(branch)
|
cloneOptions.ReferenceName = plumbing.ReferenceName(branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cloneOptions = checkGitProxy(cloneOptions)
|
||||||
|
|
||||||
storer := memory.NewStorage()
|
storer := memory.NewStorage()
|
||||||
r, err := git.Clone(storer, fs, cloneOptions)
|
r, err := git.Clone(storer, fs, cloneOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -3940,19 +3929,6 @@ func LoadSpecificApps(resp http.ResponseWriter, request *http.Request) {
|
|||||||
cloneOptions.ReferenceName = plumbing.ReferenceName(tmpBody.Branch)
|
cloneOptions.ReferenceName = plumbing.ReferenceName(tmpBody.Branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("HTTP_PROXY") != "" {
|
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTP_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.Getenv("HTTPS_PROXY") != "" {
|
|
||||||
cloneOptions.ProxyOptions = gitProxy.ProxyOptions{
|
|
||||||
URL: os.Getenv("HTTPS_PROXY"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Better auth.
|
// FIXME: Better auth.
|
||||||
if len(tmpBody.Field1) > 0 && len(tmpBody.Field2) > 0 {
|
if len(tmpBody.Field1) > 0 && len(tmpBody.Field2) > 0 {
|
||||||
cloneOptions.Auth = &http2.BasicAuth{
|
cloneOptions.Auth = &http2.BasicAuth{
|
||||||
@@ -3961,6 +3937,8 @@ func LoadSpecificApps(resp http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cloneOptions = checkGitProxy(cloneOptions)
|
||||||
|
|
||||||
storer := memory.NewStorage()
|
storer := memory.NewStorage()
|
||||||
r, err := git.Clone(storer, fs, cloneOptions)
|
r, err := git.Clone(storer, fs, cloneOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user