client

package
v0.0.0-...-e184c4b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package client retrieves data over Gemini and implements a TOFU system.

Index

Constants

This section is empty.

Variables

View Source
var ErrTofu = errors.New("server cert does not match TOFU database")

Functions

func Fetch

func Fetch(u string) (*gemini.Response, error)

Fetch returns response data and an error. The error text is human friendly and should be displayed.

func FetchWithProxy

func FetchWithProxy(proxyHostname, proxyPort, u string) (*gemini.Response, error)

FetchWithProxy is the same as Fetch, but uses a proxy.

func FixUserURL

func FixUserURL(u string) string

FixUserURL will take a user-typed URL and add a gemini scheme to it if necessary. It is not the same as normalizeURL, and that func should still be used, afterward.

For example "example.com" will become "gemini://example.com", but "//example.com" will be left untouched.

func GetExpiry

func GetExpiry(domain, port string) time.Time

GetExpiry returns the stored expiry date for the given host. The time will be empty (zero) if there is not expiry date stored for that host.

func HasClientCert

func HasClientCert(host string, path string) bool

HasClientCert returns whether or not a client certificate exists for a host and path.

func Init

func Init() error

func NormalizeURL

func NormalizeURL(u string) string

NormalizeURL attempts to make URLs that are different strings but point to the same place all look the same.

Example: gemini://gus.guru:1965/ and //gus.guru/. This function will take both output the same URL each time.

It will also percent-encode invalid characters, and decode chars that don't need to be encoded. It will also apply Unicode NFC normalization.

The string passed must already be confirmed to be a URL. Detection of a search string vs. a URL must happen elsewhere.

It only works with absolute URLs.

func ResetTofuEntry

func ResetTofuEntry(domain, port string, cert *x509.Certificate)

ResetTofuEntry forces the cert passed to be valid, overwriting any previous TOFU entry. The port string can be empty, to indicate port 1965.

Types

This section is empty.

Jump to

Keyboard shortcuts

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