Skip to content

Commit

Permalink
HTTP transport: Use dest as Host if not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Fangliding authored Nov 20, 2024
1 parent 6ba0dba commit 4c121d1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion transport/internet/http/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func (c *Config) getHosts() []string {
if len(c.Host) == 0 {
return []string{"www.example.com"}
return []string{""}
}
return c.Host
}
Expand Down
9 changes: 8 additions & 1 deletion transport/internet/http/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,16 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
}
}

Host := httpSettings.getRandomHost()
if Host == "" && net.ParseAddress(dest.NetAddr()).Family().IsDomain() {
Host = dest.Address.Domain()
} else if Host == "" {
Host = "www.example.com"
}

request := &http.Request{
Method: httpMethod,
Host: httpSettings.getRandomHost(),
Host: Host,
Body: breader,
URL: &url.URL{
Scheme: "https",
Expand Down

0 comments on commit 4c121d1

Please sign in to comment.