fuckgoogle

package module
v0.0.0-...-7c949d2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Unlicense Imports: 12 Imported by: 0

README

...after the great success of hits like 'don't be evil', 'making the world a better place', and 'the market regulates itself', presenting:

caddy-google-is-broken

Caddy plugin to fuck google over in most ways available to an average ops person. To that end it provides a request handler fuck-google, as well as a request matcher google when more customization is needed.

Yes, it's somewhat ironic I wrote this as a plugin for Caddy, software that was an early adopter of google's extend- extinguish-protocols like http2. So is life; ironic.

building caddy with this plugin
  • set up a tiny go project and import this plugin (follow steps described here), or..
  • use xcaddy: xcaddy build --with git.nroo.de/norwin/caddy-google-is-broken

handler

The handler automatically applies a couple measures (some of which may deem familiar) to traffic from google servers and/or clients using google's products. There are several degrees of fuckuppery, default is maximum fuckup (just as is googles default).

fuck google... a teeny tiny bit fuck them for real all the way
451 all reqs from google IPs n n y y
451 all reqs from GoogleBot n y y y
beg for no FLoC y y y why even try
delay reqs of chrome users by 50ms 150ms 700ms 1400ms
delay reqs of blink users by - - - 1400ms
delay reqs of google search users by - 150ms 700ms 1400ms
delay reqs of google service users by - - - 1400ms
your idea..? ? ? ? ?
usage
  • Caddyfile:
    example.com {
        route {                    
            fuck-google for real
            file_server            # ..or other handlers serving your content.
        }
    }
    
    Instead of wrapping things in a route block, you can also specify an order block at the top of your Caddyfile:
    { order fuck-google before basicauth }
    
  • JSON: ..., "handle": [{ "handler": "fuck_google", "level": "a teeny tiny bit" }, ...]

matcher

The matcher can be used like any other matcher in Caddy. It doesn't do anything that couldn't be done with Caddy's builtin matchers, but provides much more convenience.

usage

By default all matching options are disabled. Multiple options apply an OR set.

  • Caddyfile
    google [googlebot] [ip-ranges] [ua-chrome] [ua-chromeish] [referer-google] [referer-other]
    
    google {
        [googlebot]
        [ip-ranges]
        [ua-chrome]
        [ua-chromeish]
        [referer-google]
        [referer-other]
    }
    
    example:
    @goog {
        method GET
        google ua-chrome referer-google
    }
    route @goog {
        file_server
    }
    
  • JSON:
    {
      "handle": ...,
      "match": [{
        "google": {
          "googlebot": true
          "ip_ranges": true
          "useragent_chrome": true
          "useragent_chromeish": true
          "referer_google": true
          "referer_other": true
        }
      }]
    }
    

For the ip-ranges match method, by default a static list of CIDR netblocks are shipped with the plugin. If you want to future proof yourself at the cost of caddy startup time (~100ms), build caddy with GOFLAGS=-tags=dyngoogips.

license

Unlicense

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchGoogleIPRanges

func FetchGoogleIPRanges(ctx context.Context) ([]string, error)

FetchGoogleIPRanges gets IP ranges via the advertised DNS SPF records

func FetchGoogleIPRangesFull

func FetchGoogleIPRangesFull(ctx context.Context) ([]string, error)

FetchGoogleIPRangesFull gets IP ranges via DNS SPF records, and includes all that can be trivially found (FetchGoogleIPRanges will miss a couple..)

Types

type FckGgl

type FckGgl struct {
	Level FuckupLevel `json:"level,omitempty"`
	// contains filtered or unexported fields
}

func (FckGgl) CaddyModule

func (FckGgl) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*FckGgl) Provision

func (m *FckGgl) Provision(ctx caddy.Context) error

Provision sets up the module defaults.

func (FckGgl) ServeHTTP

func (m FckGgl) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (*FckGgl) UnmarshalCaddyfile

func (m *FckGgl) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the handler from Caddyfile tokens.

fuck-google [<matcher>] [<level>] [{
    level <level>
}]

type FuckupLevel

type FuckupLevel string
const (
	FuckupLevel1 FuckupLevel = "a teeny tiny bit"
	FuckupLevel2 FuckupLevel = "fuck them"
	FuckupLevel3 FuckupLevel = "for real"
	FuckupLevel4 FuckupLevel = "all the way"
)

type GoogleMatcher

type GoogleMatcher struct {
	// traffic from google itself
	Bot      bool `json:"googlebot,omitempty"`
	IPranges bool `json:"ip_ranges,omitempty"`
	// traffic from google users
	UAChrome    bool `json:"useragent_chrome,omitempty"`
	UAChromeish bool `json:"useragent_chromeish,omitempty"`
	Referer     bool `json:"referer_google,omitempty"`
	RefererExt  bool `json:"referer_other,omitempty"`
	// contains filtered or unexported fields
}

func (GoogleMatcher) CaddyModule

func (GoogleMatcher) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (GoogleMatcher) Match

func (m GoogleMatcher) Match(r *http.Request) bool

Match returns true if r matches m.

func (*GoogleMatcher) Provision

func (m *GoogleMatcher) Provision(ctx caddy.Context) (err error)

Provision sets up the module defaults.

func (*GoogleMatcher) UnmarshalCaddyfile

func (m *GoogleMatcher) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile sets up the handler from Caddyfile tokens.

google [googlebot] [ip-ranges] [ua-chrome] [ua-chromeish] [referer-google] [referer-other]

google {
    [googlebot]
    [ip-ranges]
    [ua-chrome]
    [ua-chromeish]
    [referer-google]
    [referer-other]
}

Jump to

Keyboard shortcuts

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