Copyright 2019 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package postgres

import (
	
	

	
	
	
)
IsExcluded reports whether the path matches the excluded list. A path matches an entry on the excluded list if it equals the entry, or is a component-wise suffix of the entry. So path "bad/ness" matches entries "bad" and "bad/", but path "badness" matches neither of those.
func ( *DB) ( context.Context,  string) ( bool,  error) {
	defer derrors.Wrap(&, "DB.IsExcluded(ctx, %q)", )

	 := .expoller.Current().([]string)
	for ,  := range  {
		 := 
		if !strings.HasSuffix(, "/") {
			 += "/"
		}
		if  ==  || strings.HasPrefix(, ) {
			log.Infof(, "path %q matched excluded prefix %q", , )
			return true, nil
		}
	}
	return false, nil
}
InsertExcludedPrefix inserts prefix into the excluded_prefixes table. For real-time administration (e.g. DOS prevention), use the dbadmin tool. to exclude or unexclude a prefix. If the exclusion is permanent (e.g. a user request), also add the prefix and reason to the excluded.txt file.
func ( *DB) ( context.Context, , ,  string) ( error) {
	defer derrors.Wrap(&, "DB.InsertExcludedPrefix(ctx, %q, %q)", , )

	_,  = .db.Exec(, "INSERT INTO excluded_prefixes (prefix, created_by, reason) VALUES ($1, $2, $3)",
		, , )
	if  == nil {
		.expoller.Poll()
	}
	return 
}
GetExcludedPrefixes reads all the excluded prefixes from the database.
func ( *DB) ( context.Context) ([]string, error) {
	return getExcludedPrefixes(, .db)
}

func ( context.Context,  *database.DB) ([]string, error) {
	return collectStrings(, , `SELECT prefix FROM excluded_prefixes`)