validators

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CustomProvidersDir string
)

Functions

func BuildDetectionIndex

func BuildDetectionIndex(configs []ProviderConfig) ([]PrefixEntry, []PatternEntry, PrefixIndex, map[string][]*regexp.Regexp)

func DetectProviderFromIndex

func DetectProviderFromIndex(key string, prefixes []PrefixEntry, patterns []PatternEntry, manualCategory string, providerPatterns map[string][]*regexp.Regexp) string

func GetCategories added in v1.0.3

func GetCategories() ([]string, error)

func GetCommonDomains added in v1.0.8

func GetCommonDomains() []string

func GetProviderGroups added in v1.0.3

func GetProviderGroups() (map[string][]ProviderInfo, error)

func NewValidatorFactory added in v1.0.8

func NewValidatorFactory(proxy string, timeout int) (*ValidatorFactory, []ProviderConfig, *client.ProxyRotator, error)

Types

type DetectionResult added in v1.0.4

type DetectionResult struct {
	Provider    string
	Suggestions []string
	Message     string
	Entropy     float64
}

func DetectProviderWithSuggestion added in v1.0.4

func DetectProviderWithSuggestion(key string, prefixes []PrefixEntry, patterns []PatternEntry, manualCategory string, providerPatterns map[string][]*regexp.Regexp) DetectionResult

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

func NewDetector

func NewDetector() *Detector

func NewDetectorFromConfigs

func NewDetectorFromConfigs(configs []ProviderConfig) *Detector

func (*Detector) DetectProvider

func (d *Detector) DetectProvider(apiKey string, manualCategory string) string

func (*Detector) DetectProviderWithSuggestion added in v1.0.4

func (d *Detector) DetectProviderWithSuggestion(apiKey string, manualCategory string) DetectionResult

type DetectorIndex added in v1.0.7

type DetectorIndex struct {
	// contains filtered or unexported fields
}

type EndpointConfig added in v1.0.9

type EndpointConfig struct {
	URL     string            `yaml:"url"`
	Region  string            `yaml:"region,omitempty"`
	Headers map[string]string `yaml:"headers,omitempty"`
}

type ErrorCheck added in v1.0.9

type ErrorCheck struct {
	JSONPath string `yaml:"json_path,omitempty"`
}

type GenericValidator

type GenericValidator struct {
	// contains filtered or unexported fields
}

func NewGenericValidator

func NewGenericValidator(cfg ProviderConfig, proxy string, timeout int) (*GenericValidator, error)

func NewGenericValidatorWithClient

func NewGenericValidatorWithClient(cfg ProviderConfig, httpClient *http.Client, limiter *client.RateLimiterManager) *GenericValidator

func (*GenericValidator) FetchMetadata added in v1.0.9

func (v *GenericValidator) FetchMetadata(ctx context.Context, apiKey string, result *models.ValidationResult)

func (*GenericValidator) KeyPatterns

func (v *GenericValidator) KeyPatterns() []string

func (*GenericValidator) Name

func (v *GenericValidator) Name() string

func (*GenericValidator) SetCache added in v1.0.9

func (v *GenericValidator) SetCache(cache *client.ValidationCache)

func (*GenericValidator) SetCanaryCheck added in v1.0.8

func (v *GenericValidator) SetCanaryCheck(check bool)

func (*GenericValidator) SetSkipMetadata added in v1.0.8

func (v *GenericValidator) SetSkipMetadata(skip bool)

func (*GenericValidator) Validate

func (v *GenericValidator) Validate(ctx context.Context, apiKey string) (*models.ValidationResult, error)

type MetadataConfig

type MetadataConfig struct {
	URL               string            `yaml:"url"`
	Method            string            `yaml:"method"`
	Auth              string            `yaml:"auth"`
	Headers           map[string]string `yaml:"headers"`
	BalancePath       string            `yaml:"balance_path"`
	Extract           string            `yaml:"extract"`
	StoreAs           string            `yaml:"store_as"`
	RegexExtract      string            `yaml:"regex_extract"`
	RegexExtractMatch int               `yaml:"regex_extract_match"`
}

type MetadataFromValidation

type MetadataFromValidation struct {
	BalancePath         string `yaml:"balance_path"`
	BalanceSubtractPath string `yaml:"balance_subtract_path"`
	NamePath            string `yaml:"name_path"`
	NameFallbackPath    string `yaml:"name_fallback_path"`
	EmailPath           string `yaml:"email_path"`
	QuotaPath           string `yaml:"quota_path"`
	CreditsPath         string `yaml:"credits_path"`
	VIPLevelPath        string `yaml:"vip_level_path"`
	TeamNamePath        string `yaml:"team_name_path"`
	UsernamePath        string `yaml:"username_path"`
	RegexExtract        string `yaml:"regex_extract"`
	RegexExtractMatch   int    `yaml:"regex_extract_match"`
}

type PatternEntry

type PatternEntry struct {
	Regex    *regexp.Regexp
	Provider string
	Category string
}

type PrefixEntry

type PrefixEntry struct {
	Prefix   string
	Provider string
	Category string
}

type PrefixIndex added in v1.0.5

type PrefixIndex map[string][]PrefixEntry

type ProviderConfig

type ProviderConfig struct {
	Name                   string                  `yaml:"name"`
	Category               string                  `yaml:"category"`
	KeyPrefixes            []string                `yaml:"key_prefixes"`
	KeyPatterns            []string                `yaml:"key_patterns"`
	SyntaxCheck            string                  `yaml:"syntax_check,omitempty"`
	CanaryPatterns         []string                `yaml:"canary_patterns,omitempty"`
	Validation             ValidationConfig        `yaml:"validation"`
	Metadata               []MetadataConfig        `yaml:"metadata,omitempty"`
	MetadataFromValidation *MetadataFromValidation `yaml:"metadata_from_validation,omitempty"`
}

func InitValidatorsWithConfigs

func InitValidatorsWithConfigs(proxy string, timeout int) (map[string]Validator, []ProviderConfig, *client.ProxyRotator, error)

func LoadProviderConfigs

func LoadProviderConfigs() ([]ProviderConfig, error)

type ProviderGroup added in v1.0.3

type ProviderGroup struct {
	Prefix    string
	Providers []ProviderInfo
}

type ProviderInfo

type ProviderInfo struct {
	Name        string
	Category    string
	KeyPrefixes []string
}

func FindProviderByName added in v1.0.3

func FindProviderByName(name string) ([]ProviderInfo, error)

func GetAllProviders

func GetAllProviders() ([]ProviderInfo, error)

func GetProvidersByCategory added in v1.0.3

func GetProvidersByCategory(category string) ([]ProviderInfo, error)

type ValidationConfig

type ValidationConfig struct {
	Method     string            `yaml:"method"`
	URL        string            `yaml:"url"`
	Auth       string            `yaml:"auth"`
	Headers    map[string]string `yaml:"headers"`
	Body       string            `yaml:"body"`
	Endpoints  []EndpointConfig  `yaml:"endpoints,omitempty"`
	ErrorCheck *ErrorCheck       `yaml:"error_check,omitempty"`
}

type Validator

type Validator interface {
	Name() string
	KeyPatterns() []string
	Validate(ctx context.Context, apiKey string) (*models.ValidationResult, error)
	SetSkipMetadata(bool)
	SetCanaryCheck(bool)
	FetchMetadata(ctx context.Context, apiKey string, result *models.ValidationResult)
}

type ValidatorFactory added in v1.0.8

type ValidatorFactory struct {
	// contains filtered or unexported fields
}

func (*ValidatorFactory) Cache added in v1.0.9

func (*ValidatorFactory) GetValidator added in v1.0.8

func (f *ValidatorFactory) GetValidator(name string) (Validator, bool)

Jump to

Keyboard shortcuts

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