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

Provide option to listen on specific TCP address #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ General:

* `-target` - AWS service to send requests to. Required.
* `-port` - Port for the proxy to LISTEN on (will forward to whatever port you specify in target), default: `8080`.
* `-listen` - TCP address to listen on, e.g. `:8080` or `127.0.0.1:8080`. Optional. When specified, -port is ignored.
* `-service` - The AWS service type you are sending to, default: `es`. This is required for the signing process.

HTTP Connection Tuning:
Expand Down
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (

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

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, "TCP address to listen on, e.g. :8080 or 127.0.0.1:8080. Optional. When specified, the port is ignored.")
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,10 @@ func main() {

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