Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support binding to ip. Default to loppback #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/defaults"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/signer/v4"
v4 "github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/kelseyhightower/envconfig"
)

type EnvConfig struct {
Target string
Port int `default:"8080"`
Service string `default:"es"`
Listen string `default:"127.0.0.1"`
}

type AppConfig struct {
Expand Down Expand Up @@ -143,6 +144,7 @@ func main() {

var targetFlag = flag.String("target", e.Target, "target url to proxy to")
var portFlag = flag.Int("port", e.Port, "listening port for proxy")
var listenFlag = flag.String("listen", e.Listen, "listen to this address. Set empty string for all")
var serviceFlag = flag.String("service", e.Service, "AWS Service.")
var regionFlag = flag.String("region", os.Getenv("AWS_REGION"), "AWS region for credentials")
var flushInterval = flag.Duration("flush-interval", 0, "Flush interval to flush to the client while copying the response body.")
Expand Down Expand Up @@ -186,7 +188,7 @@ func main() {

// Start the proxy server
proxy := NewSigningProxy(targetURL, creds, region, appC)
listenString := fmt.Sprintf(":%v", *portFlag)
listenString := fmt.Sprintf("%s:%d", *listenFlag, *portFlag)
fmt.Printf("Listening on %v\n", listenString)
http.ListenAndServe(listenString, proxy)
}