package measurex import ( "fmt" "net/http" "net/url" ) // // Endpoint // // This file contains the definition of Endpoint and HTTPEndpoint // // EndpointNetwork is the network of an endpoint. type EndpointNetwork string const ( // NetworkTCP identifies endpoints using TCP. NetworkTCP = EndpointNetwork("tcp") // NetworkUDP identifies endpoints using UDP. NetworkUDP = EndpointNetwork("udp") ) // Endpoint is an endpoint for a domain. type Endpoint struct { // Network is the network (e.g., "tcp", "udp") Network EndpointNetwork // Address is the endpoint address (e.g., "8.8.8.8:443") Address string } // String converts an endpoint to a string (e.g., "8.8.8.8:443/tcp") func (e *Endpoint) String() string { return fmt.Sprintf("%s/%s", e.Address, e.Network) } // HTTPEndpoint is an HTTP/HTTPS/HTTP3 endpoint. type HTTPEndpoint struct { // Domain is the endpoint domain (e.g., "dns.google"). Domain string // Network is the network (e.g., "tcp" or "udp"). Network EndpointNetwork // Address is the endpoint address (e.g., "8.8.8.8:443"). Address string // SNI is the SNI to use (only used with URL.scheme == "https"). SNI string // ALPN is the ALPN to use (only used with URL.scheme == "https"). ALPN []string // URL is the endpoint URL. URL *url.URL // Header contains request headers. Header http.Header } // String converts an HTTP endpoint to a string (e.g., "8.8.8.8:443/tcp") func (e *HTTPEndpoint) String() string { return fmt.Sprintf("%s/%s", e.Address, e.Network) }