hsts

package module
v0.0.0-...-5e6e305 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

README

hsts

GoDoc Build Status

Package hsts provides access to the Chromium HSTS preloaded list.

The list is manually converted into go code occasionally with go generate.

To request your site be added to the list, please visit hstspreload.org.

Usage

import "go.tmthrgd.dev/hsts"

Hostnames (or domain names) can be checked for inclusion in the list by calling IsPreloaded:

if hsts.IsPreloaded(hostname) {
	// ...
}

Transport is a http.RoundTripper that automatically upgrades insecure http requests to hosts in the preload list into secure https requests. It can be used by setting the (*http.Client).Transport field as follows:

client := &http.Client{
	Transport: &hsts.Transport{},
}
resp, err := client.Do(req)

License

BSD 3-Clause License

The minimal perfect hashing code was taken from cespare/mph by Caleb Spare and is licensed under an MIT License.

Documentation

Overview

Package hsts provides access to the Chromium HSTS preloaded list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPreloaded

func IsPreloaded(host string) bool

IsPreloaded reports whether host appears in the HSTS preloaded list.

func NthLastIndexOf

func NthLastIndexOf(s string, b byte, n int) int

Types

type Transport

type Transport struct {
	// Base is the underlying http.RoundTripper to use or
	// http.DefaultTransport if nil.
	Base http.RoundTripper
}

Transport is a http.RoundTripper that transparently upgrades insecure http requests to secure https requests for hosts that appear in the HSTS preloaded list.

func (*Transport) RoundTrip

func (rt *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL