Skip to content

Using host IP instead of dns name #425

Answered by giuliohome
giuliohome asked this question in Q&A
Discussion options

You must be logged in to vote

At first sight, this seems to be the point to be considered

func getHost(r *nethttp.Request) (string, error) {
	// check the host header first, then the request host
	// field (which may contain the actual URL if there is no
	// host header)
	if r.Header.Get("Host") != "" {
		return r.Header.Get("Host"), nil
	}
	if r.Host != "" {
		return r.Host, nil
	}
	return "", fmt.Errorf("host not found")
}

I have to verify if it already contains the ip in case it was sent from the client (and if the add-on is already usable to filter by ip as it is now, in such a situation).

I'm already looking at this answers saying

Per RFC 2616, this is either the value of the Host: header or the host name given …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@arschles
Comment options

@giuliohome
Comment options

Answer selected by giuliohome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants