settings

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSettings = Settings{
	Strings:           DefaultStrings,
	ChallengeTemplate: "anubis",
	ChallengeTemplateOverrides: func() map[string]string {
		m := make(map[string]string)
		maps.Copy(m, map[string]string{
			"Theme": "",
			"Logo":  "",
		})
		return m
	}(),

	Bind: Bind{
		Address:         ":8080",
		Network:         "tcp",
		SocketMode:      "0770",
		Proxy:           false,
		TLSAcmeAutoCert: "",
	},
	Backends: make(map[string]Backend),
}
View Source
var DefaultStrings = make(Strings).set(map[string]string{
	"title_challenge": "Checking you are not a bot",
	"title_error":     "Oh no!",

	"noscript_warning": "<p>Sadly, you may need to enable JavaScript to get past this challenge. This is required because AI companies have changed the social contract around how website hosting works.</p>",

	"details_title": "Why am I seeing this?",
	"details_text": `
<p>
	You are seeing this because the administrator of this website has set up <a href="https://git.gammaspectra.live/git/go-away">go-away</a> 
	to protect the server against the scourge of <a href="https://thelibre.news/foss-infrastructure-is-under-attack-by-ai-companies/">AI companies aggressively scraping websites</a>.
</p>
<p>
	Mass scraping can and does cause downtime for the websites, which makes their resources inaccessible for everyone.
</p>
<p>
	Please note that some challenges requires the use of modern JavaScript features and some plugins may disable these.
	Disable such plugins for this domain (for example, JShelter) if you encounter any issues.
</p>
`,
	"details_contact_admin_with_request_id": "If you have any issues contact the site administrator and provide the following Request Id",

	"button_refresh_page": "Refresh page",

	"status_loading_challenge":   "Loading challenge",
	"status_starting_challenge":  "Starting challenge",
	"status_loading":             "Loading...",
	"status_calculating":         "Calculating...",
	"status_challenge_success":   "Challenge success!",
	"status_challenge_done_took": "Done! Took",
	"status_error":               "Error:",
})

Functions

This section is empty.

Types

type Backend

type Backend struct {
	// URL Target server backend path. Supports http/https/unix protocols.
	URL string `yaml:"url"`

	// Host Override the Host header and TLS SNI with this value if specified
	Host string `yaml:"host"`

	// HTTP2Enabled Enable HTTP2 to backend
	HTTP2Enabled bool `yaml:"http2-enabled"`

	// TLSSkipVerify Disable TLS certificate verification, if any
	TLSSkipVerify bool `yaml:"tls-skip-verify"`

	// IpHeader HTTP header to set containing the IP header. Set - to forcefully ignore global defaults.
	IpHeader string `yaml:"ip-header"`

	// GoDNS Resolve URL using the Go DNS server
	// Only relevant when running with CGO enabled
	GoDNS bool `yaml:"go-dns"`
}

func (Backend) Create

func (b Backend) Create() (*httputil.ReverseProxy, error)

type Bind

type Bind struct {
	Address    string `yaml:"address"`
	Network    string `yaml:"network"`
	SocketMode string `yaml:"socket-mode"`
	Proxy      bool   `yaml:"proxy"`

	Passthrough bool `yaml:"passthrough"`

	// TLSAcmeAutoCert URL to ACME directory, or letsencrypt
	TLSAcmeAutoCert string `yaml:"tls-acme-autocert"`

	// TLSCertificate Alternate to TLSAcmeAutoCert
	TLSCertificate string `yaml:"tls-certificate"`
	// TLSPrivateKey Alternate to TLSAcmeAutoCert
	TLSPrivateKey string `yaml:"tls-key"`
}

func (*Bind) Listener

func (b *Bind) Listener() (net.Listener, string)

func (*Bind) Server

func (b *Bind) Server(backends map[string]http.Handler, acmeCachePath string) (*http.Server, func(http.Handler), error)
type Link struct {
	Name string `yaml:"name"`
	URL  string `yaml:"url"`
}

type Settings

type Settings struct {
	Bind Bind `yaml:"bind"`

	Backends map[string]Backend `yaml:"backends"`

	BindDebug   string `yaml:"bind-debug"`
	BindMetrics string `yaml:"bind-metrics"`

	Strings Strings `yaml:"strings"`

	// Links to add to challenge/error pages like privacy/impressum.
	Links []Link `yaml:"links"`

	ChallengeTemplate string `yaml:"challenge-template"`

	// ChallengeTemplateOverrides Key/Value overrides for the current chosen template
	ChallengeTemplateOverrides map[string]string `yaml:"challenge-template-overrides"`
}

type Strings

type Strings map[string]string

func (Strings) Get

func (s Strings) Get(value string) template.HTML

Jump to

Keyboard shortcuts

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