Skip to content

Commit

Permalink
feat: support proxy using different ports
Browse files Browse the repository at this point in the history
  • Loading branch information
cokemine committed Dec 24, 2022
1 parent 47c66b1 commit 7a1a697
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions frontend/lgproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ func batchRequest(servers []string, endpoint string, command string) []string {
// Compose URL and send the request
hostname := server
hostname = url.PathEscape(hostname)
// if strings.Contains(hostname, ":") {
// hostname = "[" + hostname + "]"
// }
port := strconv.Itoa(setting.proxyPort)
if strings.Contains(hostname, ":") {
hostname = "[" + hostname + "]"
splits := strings.Split(hostname, ":")
hostname = splits[0]
port = splits[1]
}
if setting.domain != "" {
hostname += "." + setting.domain
}
url := "http://" + hostname + ":" + strconv.Itoa(setting.proxyPort) + "/" + url.PathEscape(endpoint) + "?q=" + url.QueryEscape(command)
url := "http://" + hostname + ":" + port + "/" + url.PathEscape(endpoint) + "?q=" + url.QueryEscape(command)
go func(url string, i int) {
client := http.Client{Timeout: time.Duration(setting.timeOut) * time.Second}
response, err := client.Get(url)
Expand Down

0 comments on commit 7a1a697

Please sign in to comment.