Skip to content

Commit

Permalink
Make https a toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
colin969 committed Nov 4, 2023
1 parent db15a81 commit 97de8bf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type ServerSettings struct {
LegacyOverridePaths []string `json:"legacyOverridePaths"`
UseInfinityServer bool `json:"useInfinityServer"`
InfinityServerURL string `json:"infinityServerURL"`
EnableHttpsProxy bool `json:"enableHttpsProxy"`
}

// ExtApplicationTypes is a map that holds the content types of different file extensions
Expand Down Expand Up @@ -92,6 +93,7 @@ func initServer() {
infinityServerURL := flag.String("infinityServerURL", serverSettings.InfinityServerURL, "The URL of the infinity server")
legacyCGIBINPath := flag.String("legacyCGIBINPath", serverSettings.LegacyCGIBINPath, "This is the path for CGI-BIN")
handleLegacyRequests := flag.Bool("handleLegacyRequests", false, "Whether to handle legacy requests internally (true) or externally (false)")
enableHttpsProxy := flag.Bool("enableHttpsProxy", false, "Whether to enable HTTPS proxying or not")

flag.Parse()

Expand All @@ -102,6 +104,7 @@ func initServer() {
fmt.Printf("Failed to get absolute game root path")
return
}
serverSettings.EnableHttpsProxy = *enableHttpsProxy
serverSettings.ProxyPort = strconv.Itoa(*proxyPort)
serverSettings.ServerHTTPPort = strconv.Itoa(*serverHTTPPort)
serverSettings.ApiPrefix = *apiPrefix
Expand Down Expand Up @@ -332,7 +335,11 @@ XgVWIMrKj4T7p86bcxq4jdWDYUYpRd/2Og==
goproxy.MitmConnect.TLSConfig = goproxy.TLSConfigFromCA(&cert)

// Handle HTTPS requests (DOES NOT HANDLE HTTP)
proxy.OnRequest().HandleConnect(goproxy.AlwaysReject)
if serverSettings.EnableHttpsProxy {
proxy.OnRequest().HandleConnect(goproxy.AlwaysMitm)
} else {
proxy.OnRequest().HandleConnect(goproxy.AlwaysReject)
}
proxy.OnRequest().HijackConnect(func(req *http.Request, client net.Conn, ctx *goproxy.ProxyCtx) {
_, resp := handleRequest(req, ctx)
err := resp.Write(client)
Expand Down

0 comments on commit 97de8bf

Please sign in to comment.