Documentation ¶
Overview ¶
Package websvc contains the AdGuard DNS web service.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindData ¶
type BindData struct { // TLS is the optional TLS configuration. TLS *tls.Config // Address is the binding address. Address netip.AddrPort }
BindData is data for binding one HTTP server to an address.
type BlockPageServerConfig ¶
type BlockPageServerConfig struct { // ContentFilePath is the path to HTML block page content file. ContentFilePath string // Bind are the addresses on which to serve the block page. Bind []*BindData }
BlockPageServerConfig is the blocking page server configuration.
type Config ¶
type Config struct { // AdultBlocking is the optional adult-blocking block-page web server. AdultBlocking *BlockPageServerConfig // GeneralBlocking is the optional general block-page web server. GeneralBlocking *BlockPageServerConfig // SafeBrowsing is the optional safe-browsing block-page web server. SafeBrowsing *BlockPageServerConfig // LinkedIP is the optional linked IP web server. LinkedIP *LinkedIPServer // RootRedirectURL is the URL to which root HTTP requests are redirected. // If not set, these requests are responded with a 404 page. RootRedirectURL *url.URL // StaticContent is the content that is served statically at the given // paths. It must not be nil; use [http.NotFoundHandler] if not needed. StaticContent http.Handler // DNSCheck is the HTTP handler for DNS checks. DNSCheck http.Handler // ErrColl is used to collect linked IP proxy errors and other errors. ErrColl errcoll.Interface // Error404 is the content of the HTML page for the 404 status. If not set, // a simple plain text 404 response is served. Error404 []byte // Error500 is the content of the HTML page for the 500 status. If not set, // a simple plain text 500 response is served. Error500 []byte // NonDoHBind are the bind addresses and optional TLS configuration for the // web service in addition to the ones in the DNS-over-HTTPS handlers. NonDoHBind []*BindData // Timeout is the timeout for all server operations. Timeout time.Duration }
Config is the AdGuard DNS web service configuration structure.
type LinkedIPServer ¶
type LinkedIPServer struct { // TargetURL is the URL to which linked IP API requests are proxied. TargetURL *url.URL // Bind are the addresses on which to serve the linked IP API. Bind []*BindData }
LinkedIPServer is the linked IP server configuration.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the AdGuard DNS web service. A nil *Service serves a simple plain-text 404 page.
func New ¶
New returns a new properly initialized *Service. If c is nil, svc is a nil *Service that only serves a simple plain-text 404 page. The service must be refreshed with Service.Refresh before use.
func (*Service) Refresh ¶
Refresh implements the agdservice.Refresher interface for *Service. svc may be nil.
func (*Service) ServeHTTP ¶
func (svc *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for *Service.
func (*Service) Shutdown ¶
Shutdown implements the service.Interface interface for *Service. svc may be nil.
func (*Service) Start ¶
Start implements the service.Interface interface for *Service. It starts serving all endpoints but does not wait for them to actually go online. svc may be nil. err is always nil; if any endpoint fails to start, it panics.
TODO(a.garipov): Wait for the services to go online.
TODO(a.garipov): Use the context for cancelation.
type StaticContent ¶
type StaticContent map[string]*StaticFile
StaticContent serves static content with the given content type. Elements must not be nil.
func (StaticContent) ServeHTTP ¶
func (sc StaticContent) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface for StaticContent.
type StaticFile ¶
type StaticFile struct { // Headers contains headers of the HTTP response. Headers http.Header // Content is the file content. Content []byte }
StaticFile is a single file in a [StaticFS].