Added proxy options
This commit is contained in:
@@ -395,6 +395,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
|
||||
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
|
||||
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
|
||||
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
|
||||
|
||||
+48
-1
@@ -28,6 +28,7 @@ import (
|
||||
"cloud.google.com/go/datastore"
|
||||
"cloud.google.com/go/pubsub"
|
||||
"cloud.google.com/go/storage"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/appengine/mail"
|
||||
|
||||
"github.com/getkin/kin-openapi/openapi2"
|
||||
@@ -50,9 +51,14 @@ import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
// PROXY overrides
|
||||
// "gopkg.in/src-d/go-git.v4/plumbing/transport/client"
|
||||
// githttp "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
||||
|
||||
// Web
|
||||
// "github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
"google.golang.org/grpc"
|
||||
http2 "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
||||
// Old items (cloud)
|
||||
// "google.golang.org/appengine"
|
||||
@@ -2466,6 +2472,7 @@ func setUser(ctx context.Context, data *User) error {
|
||||
|
||||
// Used for testing only. Shouldn't impact production.
|
||||
func handleCors(resp http.ResponseWriter, request *http.Request) bool {
|
||||
//allowedOrigins := "*"
|
||||
allowedOrigins := "http://localhost:3000"
|
||||
|
||||
resp.Header().Set("Vary", "Origin")
|
||||
@@ -6144,6 +6151,45 @@ func runInit(ctx context.Context) {
|
||||
if err != nil {
|
||||
log.Printf("Failed increasing local stats: %s", err)
|
||||
}
|
||||
log.Printf("Finalized init statistics update")
|
||||
|
||||
httpProxy := os.Getenv("HTTP_PROXY")
|
||||
if len(httpProxy) > 0 {
|
||||
log.Printf("Running with HTTP proxy %s (env: HTTP_PROXY)", httpProxy)
|
||||
}
|
||||
|
||||
/*
|
||||
proxyUrl, err := url.Parse(httpProxy)
|
||||
if err != nil {
|
||||
log.Printf("Failed setting up proxy: %s", err)
|
||||
} else {
|
||||
// accept any certificate (might be useful for testing)
|
||||
customClient := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
Proxy: http.ProxyURL(proxyUrl),
|
||||
},
|
||||
|
||||
// 15 second timeout
|
||||
Timeout: 15 * time.Second,
|
||||
|
||||
// don't follow redirect
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
}
|
||||
|
||||
// Override http(s) default protocol to use our custom client
|
||||
client.InstallProtocol("http", githttp.NewClient(customClient))
|
||||
client.InstallProtocol("https", githttp.NewClient(customClient))
|
||||
}
|
||||
}
|
||||
|
||||
httpsProxy := os.Getenv("SHUFFLE_HTTPS_PROXY")
|
||||
if len(httpsProxy) > 0 {
|
||||
log.Printf("Running with HTTPS proxy %s", httpsProxy)
|
||||
}
|
||||
*/
|
||||
|
||||
// Fix active users etc
|
||||
q := datastore.NewQuery("Users").Filter("active =", true)
|
||||
@@ -6337,7 +6383,8 @@ func init() {
|
||||
|
||||
log.Printf("Starting Shuffle backend - initializing database connection")
|
||||
// option.WithoutAuthentication
|
||||
dbclient, err = datastore.NewClient(ctx, gceProject)
|
||||
|
||||
dbclient, err = datastore.NewClient(ctx, gceProject, option.WithGRPCDialOption(grpc.WithNoProxy()))
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("DBclient error during init: %s", err))
|
||||
}
|
||||
|
||||
@@ -1375,7 +1375,7 @@ func deleteWorkflow(resp http.ResponseWriter, request *http.Request) {
|
||||
resp.Write([]byte(`{"success": true}`))
|
||||
}
|
||||
|
||||
// FIXME - check whether all nodes has a branch, otherwise go back
|
||||
// Saves a workflow to an ID
|
||||
func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
|
||||
cors := handleCors(resp, request)
|
||||
if cors {
|
||||
@@ -1462,6 +1462,11 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Fixing wrong owners when importing
|
||||
if workflow.Owner == "" {
|
||||
workflow.Owner = user.Id
|
||||
}
|
||||
|
||||
// FIXME - this shouldn't be necessary with proper API checks
|
||||
newActions := []Action{}
|
||||
allNodes := []string{}
|
||||
@@ -1491,6 +1496,8 @@ func saveWorkflow(resp http.ResponseWriter, request *http.Request) {
|
||||
workflow.Actions = newActions
|
||||
|
||||
for _, trigger := range workflow.Triggers {
|
||||
log.Printf("Trigger %s: %s", trigger.TriggerType, trigger.Status)
|
||||
|
||||
//log.Println("TRIGGERS")
|
||||
allNodes = append(allNodes, trigger.ID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user