Skip to content

Commit

Permalink
createProxy() returns a proxy without stopping to listen
Browse files Browse the repository at this point in the history
  • Loading branch information
aidansteele committed Apr 9, 2021
1 parent 7d2e208 commit 6de72a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"log"
"net/http"
"os"
"os/exec"
"runtime/pprof"
Expand Down Expand Up @@ -151,7 +152,8 @@ func main() {
handleLoggedCall()
} else if *modeFlag == "proxy" {
readServiceFiles()
createProxy(*bindAddrFlag)
proxy := createProxy()
log.Fatal(http.ListenAndServe(*bindAddrFlag, proxy))
} else {
fmt.Println("ERROR: unknown mode")
}
Expand Down
5 changes: 3 additions & 2 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func loadCAKeys() error {

var awsHostnameRegexp = regexp.MustCompile(`^.*\.amazonaws\.com(?:\.cn)?$`)

func createProxy(addr string) {
func createProxy() *goproxy.ProxyHttpServer {
err := loadCAKeys()
if err != nil {
log.Fatal(err)
Expand All @@ -170,7 +170,8 @@ func createProxy(addr string) {

return resp
})
log.Fatal(http.ListenAndServe(addr, proxy))

return proxy
}

type ServiceDefinition struct {
Expand Down

0 comments on commit 6de72a8

Please sign in to comment.