0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-12 19:39:35 +03:00

Properly parse HTTP host for verification

Also fix H2 transport to not verify if host is not defined
This commit is contained in:
yuhan6665
2024-07-06 17:12:49 -04:00
parent 4c51636788
commit b8c0768b16
5 changed files with 22 additions and 6 deletions

View File

@ -1,8 +1,6 @@
package http
import (
"strings"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/dice"
"github.com/xtls/xray-core/transport/internet"
@ -18,9 +16,12 @@ func (c *Config) getHosts() []string {
}
func (c *Config) isValidHost(host string) bool {
if len(c.Host) == 0 {
return true
}
hosts := c.getHosts()
for _, h := range hosts {
if strings.Contains(strings.ToLower(host), strings.ToLower(h)) {
if internet.IsValidHTTPHost(host, h) {
return true
}
}