Documentation
¶
Index ¶
- Constants
- func GetFilePath(dir string, names []string) (found string, err error)
- func GetPublishedDate(manager *ResourceManager) time.Time
- func InitManagerFromFile(manager *ResourceManager, config ConfigHash, properties string, ...) error
- func InitManagerFromMemory(manager *ResourceManager, config ConfigHash, properties string, ...) error
- type CEvidence
- type ConfigHash
- func (config *ConfigHash) AllowUnmatched() bool
- func (config *ConfigHash) Concurrency() uint16
- func (config *ConfigHash) Difference() int32
- func (config *ConfigHash) Drift() int32
- func (config *ConfigHash) PerformanceProfile() PerformanceProfile
- func (config *ConfigHash) SetAllowUnmatched(allow bool)
- func (config *ConfigHash) SetConcurrency(concurrency uint16)
- func (config *ConfigHash) SetDifference(diff int32)
- func (config *ConfigHash) SetDrift(drift int32)
- func (config *ConfigHash) SetTraceRoute(trace bool)
- func (config *ConfigHash) SetUpdateMatchedUserAgent(update bool)
- func (config *ConfigHash) SetUsePerformanceGraph(use bool)
- func (config *ConfigHash) SetUsePredictiveGraph(use bool)
- func (config *ConfigHash) SetUseUpperPrefixHeaders(use bool)
- func (config *ConfigHash) SizeManagerFromFile(properties string, filePath string) (size uint64, err error)
- func (config *ConfigHash) SizeManagerFromMemory(properties string, memory unsafe.Pointer, size uint64) (s uint64, err error)
- func (config *ConfigHash) TraceRoute() bool
- func (config *ConfigHash) UpdateMatchedUserAgent() bool
- func (config *ConfigHash) UsePerformanceGraph() bool
- func (config *ConfigHash) UsePredictiveGraph() bool
- func (config *ConfigHash) UseUpperPrefixHeaders() bool
- type Evidence
- type EvidenceKey
- type EvidencePrefix
- type Exception
- type MatchMethod
- type PerformanceProfile
- type PropertiesRequired
- type ResourceManager
- type ResultsHash
- func (results *ResultsHash) AvailableProperties() []string
- func (results *ResultsHash) Count() int
- func (results *ResultsHash) DeviceId() (id string, err error)
- func (results *ResultsHash) DeviceIdByIndex(index uint32) (id string, err error)
- func (results *ResultsHash) Difference() int32
- func (results *ResultsHash) DifferenceByIndex(index uint32) (int32, error)
- func (results *ResultsHash) Drift() int32
- func (results *ResultsHash) DriftByIndex(index uint32) (int32, error)
- func (results *ResultsHash) Free()
- func (results *ResultsHash) HasValues(propertyName string) (hasValues bool, err error)
- func (results *ResultsHash) HasValuesByIndex(requiredPropertyIndex int) (hasValues bool, err error)
- func (results *ResultsHash) Iterations() int32
- func (results *ResultsHash) IterationsByIndex(index uint32) (int32, error)
- func (results *ResultsHash) MatchDeviceId(id string) error
- func (results *ResultsHash) MatchEvidence(e *Evidence) error
- func (results *ResultsHash) MatchUserAgent(ua string) error
- func (results *ResultsHash) MatchedNodes() int32
- func (results *ResultsHash) Method() MatchMethod
- func (results *ResultsHash) MethodByIndex(index uint32) (MatchMethod, error)
- func (results *ResultsHash) NoValueReasonMessage(propertyName string) (message string, err error)
- func (results *ResultsHash) NoValueReasonMessageByIndex(requiredPropertyIndex int) (message string, err error)
- func (results *ResultsHash) PropertyName(requiredPropertyIndex int) string
- func (results *ResultsHash) PropertyType(requiredPropertyIndex int) reflect.Type
- func (results *ResultsHash) RequiredPropertyIndexFromName(propertyName string) int
- func (results *ResultsHash) ResponseHeaders(manager *ResourceManager) (headers map[string]string, err error)
- func (results *ResultsHash) SetResponseHeaders(w http.ResponseWriter, manager *ResourceManager) error
- func (results *ResultsHash) Trace() string
- func (results *ResultsHash) TraceByIndex(index uint32) (string, error)
- func (results *ResultsHash) UserAgent(index int) (string, error)
- func (results *ResultsHash) UserAgents() uint32
- func (results *ResultsHash) Values(requiredPropertyIndex int) (values []string, err error)
- func (results *ResultsHash) ValuesString(propertyName string, separator string) (value string, err error)
Constants ¶
const ( ErrSHPropertyIncorrectFormat = "'SetHeader' property name is not in correct format." ErrNoMatch = "No match found." )
Error messages
const ( HttpHeaderString EvidencePrefix = C.FIFTYONE_DEGREES_EVIDENCE_HTTP_HEADER_STRING HttpIpAddresses = C.FIFTYONE_DEGREES_EVIDENCE_HTTP_HEADER_IP_ADDRESSES HttpEvidenceServer = C.FIFTYONE_DEGREES_EVIDENCE_SERVER HttpEvidenceQuery = C.FIFTYONE_DEGREES_EVIDENCE_QUERY HttpEvidenceCookie = C.FIFTYONE_DEGREES_EVIDENCE_COOKIE HttpEvidenceIgnore = C.FIFTYONE_DEGREES_EVIDENCE_IGNORE )
Variables ¶
This section is empty.
Functions ¶
func GetFilePath ¶
GetFilePath take a directory and search for the target file in that directory, including the subdirectories. The directory is a relative path to the current directory of the caller file.
func GetPublishedDate ¶ added in v4.4.32
func GetPublishedDate(manager *ResourceManager) time.Time
func InitManagerFromFile ¶
func InitManagerFromFile( manager *ResourceManager, config ConfigHash, properties string, filePath string) error
InitFromFile initializes a resource manager based on a given data file path. The input properties is a comma separated string list. This matches the C API fiftyoneDegreesHashInitManagerFromFile.
func InitManagerFromMemory ¶
func InitManagerFromMemory( manager *ResourceManager, config ConfigHash, properties string, memory unsafe.Pointer, size uint64) error
InitFromMemory initializes a resource manager based on a given data file content held in the memory. The input properties is a comma separated string list. This matches the C API fiftyoneDegreesHashInitManagerFromFile.
TODO: To be implemeted
Types ¶
type CEvidence ¶
type CEvidence struct {
// contains filtered or unexported fields
}
C type Evidence
type ConfigHash ¶
type ConfigHash struct { CPtr *C.ConfigHash // contains filtered or unexported fields }
ConfigHash wraps around pointer to a value of C ConfigHash structure
func NewConfigHash ¶
func NewConfigHash(perf PerformanceProfile) *ConfigHash
NewConfigHash creates a new ConfigHash object. Target performance profile is required as initial setup and any following adjustments will be done on top of this initial performance profile. Any invalid input will result in default config to be used. In C the default performance profile is the same as balanced profile.
func (*ConfigHash) AllowUnmatched ¶
func (config *ConfigHash) AllowUnmatched() bool
AllowUnmatched returns whether unmatched should be allowed
func (*ConfigHash) Concurrency ¶
func (config *ConfigHash) Concurrency() uint16
Concurrency returns the configured concurrency
func (*ConfigHash) Difference ¶
func (config *ConfigHash) Difference() int32
Difference returns the configured difference value
func (*ConfigHash) Drift ¶
func (config *ConfigHash) Drift() int32
Drift returns the configured drift value
func (*ConfigHash) PerformanceProfile ¶
func (config *ConfigHash) PerformanceProfile() PerformanceProfile
PerformanceProfile get the configured performance profile
func (*ConfigHash) SetAllowUnmatched ¶
func (config *ConfigHash) SetAllowUnmatched(allow bool)
SetAllowUnmatched set whether unmatched should be allowed
func (*ConfigHash) SetConcurrency ¶
func (config *ConfigHash) SetConcurrency(concurrency uint16)
SetConcurrency sets the expected concurrent requests.
func (*ConfigHash) SetDifference ¶
func (config *ConfigHash) SetDifference(diff int32)
SetDifference sets the maximum difference in hash value to allow when finding hashes during the processing of HTTP headers.
func (*ConfigHash) SetDrift ¶
func (config *ConfigHash) SetDrift(drift int32)
SetDrift sets the maximum drift to allow when matching hashes.
func (*ConfigHash) SetTraceRoute ¶
func (config *ConfigHash) SetTraceRoute(trace bool)
SetTraceRoute sets whether the route through each graph should be traced during processing.
func (*ConfigHash) SetUpdateMatchedUserAgent ¶
func (config *ConfigHash) SetUpdateMatchedUserAgent(update bool)
SetUpdateMatchedUserAgent set whether or not tracking the matched User-Agent should be enabled.
func (*ConfigHash) SetUsePerformanceGraph ¶
func (config *ConfigHash) SetUsePerformanceGraph(use bool)
SetUsePerformanceGraph sets whether performance optimized graph should be used for processing.
func (*ConfigHash) SetUsePredictiveGraph ¶
func (config *ConfigHash) SetUsePredictiveGraph(use bool)
SetUsePredictiveGraph sets whether predictive optimized graph should be used for processing.
func (*ConfigHash) SetUseUpperPrefixHeaders ¶
func (config *ConfigHash) SetUseUpperPrefixHeaders(use bool)
SetUseUpperPrefixHeaders set whether or not the HTTP header might be prefixed with 'HTTP_'
func (*ConfigHash) SizeManagerFromFile ¶
func (config *ConfigHash) SizeManagerFromFile( properties string, filePath string) (size uint64, err error)
SizeManagerFromFile returns the size of the memory which will be used for holding a resource manager based on a given file. The input properties is a comma separated string list. This matches the C API fiftyoneDegreeshashSizeManagerFromFile.
func (*ConfigHash) SizeManagerFromMemory ¶
func (config *ConfigHash) SizeManagerFromMemory( properties string, memory unsafe.Pointer, size uint64) (s uint64, err error)
SizeManagerFromMemory returns the size of the memory which will be used for holding a resource manager based on a given memory. The given memory holds a data file content that is intended to initialize the resource amanger. The properties is a comma separated string list. This matches the C API fiftyoneDegreeshashSizeManagerFromMemory.
TODO: To be implemeted
func (*ConfigHash) TraceRoute ¶
func (config *ConfigHash) TraceRoute() bool
TraceRoute returns whether route through each graph should be traced.
func (*ConfigHash) UpdateMatchedUserAgent ¶
func (config *ConfigHash) UpdateMatchedUserAgent() bool
UpdateMatchedUserAgent returns whether tracking the matched User-Agent should be enabled
func (*ConfigHash) UsePerformanceGraph ¶
func (config *ConfigHash) UsePerformanceGraph() bool
UsePerformanceGraph returns whether performance optimized graph should be used.
func (*ConfigHash) UsePredictiveGraph ¶
func (config *ConfigHash) UsePredictiveGraph() bool
UsePredictiveGraph returns whether predictive optmized graph should be used.
func (*ConfigHash) UseUpperPrefixHeaders ¶
func (config *ConfigHash) UseUpperPrefixHeaders() bool
UseUpperPrefixHeaders returns whether HTTP_ upper case prefixes should be considered when evaluating HTTP hreaders.
type Evidence ¶
type Evidence struct { CPtr *C.EvidenceKeyValuePairArray // contains filtered or unexported fields }
Evidence structure
func NewEvidenceHash ¶
NewEvidenceHash returns a new EvidenceHash object with a given capacity
func (*Evidence) Add ¶
func (evidence *Evidence) Add( prefix EvidencePrefix, key string, value string) error
Add adds a new evidence to the object. This matches the C API fiftyoneDegreesEvidenceAddString
type EvidenceKey ¶
type EvidenceKey struct { Prefix EvidencePrefix Key string }
Header Key required by engine
type EvidencePrefix ¶
type EvidencePrefix C.fiftyoneDegreesEvidencePrefix
type MatchMethod ¶
type MatchMethod int
Match method
const ( None MatchMethod = iota Performance Combined Predictive )
Types of method
type PerformanceProfile ¶
type PerformanceProfile int
Performance Profile
const ( Default PerformanceProfile = iota LowMemory BalancedTemp Balanced HighPerformance InMemory )
type PropertiesRequired ¶
type PropertiesRequired struct {
CPtr *C.PropertiesRequired
}
PropertiesRequired wraps around a pointer to a value of C PropertiesRequired structure.
func NewPropertiesRequired ¶
func NewPropertiesRequired( properties string) *PropertiesRequired
NewPropertiesRequired creates a new PropertiesRequired object.
func (*PropertiesRequired) Free ¶
func (properties *PropertiesRequired) Free()
Free free the C resource and set CPtr to nil
func (*PropertiesRequired) Properties ¶
func (properties *PropertiesRequired) Properties() string
Properties returns the required properties string
type ResourceManager ¶
type ResourceManager struct { HttpHeaderKeys []EvidenceKey // Http header keys required by this engine CPtr *C.ResourceManager // Pointer to C resource // contains filtered or unexported fields }
ResourceManagers wraps around a pointer to a value of C ResourceManager structure
func NewResourceManager ¶
func NewResourceManager() *ResourceManager
NewResourceManager creats a new object of ResourceManager
func (*ResourceManager) Free ¶
func (manager *ResourceManager) Free()
Free frees the native resources allocated in the C layer for a Resource Manager.
func (*ResourceManager) ReloadFromFile ¶
func (manager *ResourceManager) ReloadFromFile(fileName string) error
ReloadFromFile reloads the data set being used by the resource manager using the specified data file location. This is corresponding to the C API fiftyoneDegreesHashReloadManagerFromFile.
func (*ResourceManager) ReloadFromMemory ¶
func (manager *ResourceManager) ReloadFromMemory() error
ReloadFromMemory reloads the data set being used by the resource manager using a data file loaded into continuous memory. This is corresponding to the C API fiftyoneDegreesHashReloadManagerFromMemory.
func (*ResourceManager) ReloadFromOriginalFile ¶
func (manager *ResourceManager) ReloadFromOriginalFile() error
ReloadFromOriginalFile reloads the data set being used by the resource manager using the data file location which was used when the manager was created. This is corresponding to the C API fiftyoneDegreesHashReloadManagerFromOriginalFile
type ResultsHash ¶
type ResultsHash struct { CPtr *C.ResultsHash CResults *interface{} // Pointer to a slice holding C results }
ResultsHash wraps around a pointer to a value of C ResultsHash structure
func NewResultsHash ¶
func NewResultsHash( manager *ResourceManager, uaCapacity uint32, overridesCapacity uint32) *ResultsHash
NewResultsHash create a new ResultsHash object. This matches the C API fiftyoneDegreesResultsHashCreate.
func (*ResultsHash) AvailableProperties ¶
func (results *ResultsHash) AvailableProperties() []string
AvailableProperties returns a list of available properties. The index of this property can be used obtain further details about the property.
func (*ResultsHash) Count ¶
func (results *ResultsHash) Count() int
Count returns the number of results
func (*ResultsHash) DeviceId ¶
func (results *ResultsHash) DeviceId() (id string, err error)
DeviceId returns the unique device id. This matches the C API fiftyoneDegreesHashGetDeviceIdFromResults.
func (*ResultsHash) DeviceIdByIndex ¶
func (results *ResultsHash) DeviceIdByIndex( index uint32) (id string, err error)
DeviceIdByIndex returns the unique device id of a result pointed by a index.
func (*ResultsHash) Difference ¶
func (results *ResultsHash) Difference() int32
Difference returns the total difference between the results returned and the target User-Agent.
func (*ResultsHash) DifferenceByIndex ¶
func (results *ResultsHash) DifferenceByIndex(index uint32) (int32, error)
DifferenceByIndex returns the difference between the result pointed by a index and the target User-Agent.
func (*ResultsHash) Drift ¶
func (results *ResultsHash) Drift() int32
Drift returns the maximum drift for a matched substring.
func (*ResultsHash) DriftByIndex ¶
func (results *ResultsHash) DriftByIndex(index uint32) (int32, error)
DriftByIndex returns the drift for a matched substring of a result pointed by an index.
func (*ResultsHash) Free ¶
func (results *ResultsHash) Free()
Free free the resource allocated in the C layer.
func (*ResultsHash) HasValues ¶
func (results *ResultsHash) HasValues( propertyName string) (hasValues bool, err error)
HasValuesByIndex returns whether the last detection returns any matched value for a given property name.
func (*ResultsHash) HasValuesByIndex ¶
func (results *ResultsHash) HasValuesByIndex( requiredPropertyIndex int) (hasValues bool, err error)
HasValuesByIndex returns whether the last detection returns any matched value for a given property index. This matches the C API fiftyoneDegreesResultsHashGetHasValues
func (*ResultsHash) Iterations ¶
func (results *ResultsHash) Iterations() int32
Iterations returns the number of iterations carried out in order to find a match.
func (*ResultsHash) IterationsByIndex ¶
func (results *ResultsHash) IterationsByIndex(index uint32) (int32, error)
Iterations returns the number of iterations carried out in order to find a match of a result pointed by an index.
func (*ResultsHash) MatchDeviceId ¶
func (results *ResultsHash) MatchDeviceId(id string) error
MatchDeviceId performs a detection on a given device id. This matches the C API fiftyoneDegreesResultsHashFromDeviceId
func (*ResultsHash) MatchEvidence ¶
func (results *ResultsHash) MatchEvidence(e *Evidence) error
MatchEvidence performs a detection on evidence encapsulated in a EvidenceHash object. This matches the C API fiftyoneDegreesResultsHashFromEvidence.
func (*ResultsHash) MatchUserAgent ¶
func (results *ResultsHash) MatchUserAgent(ua string) error
Detections
MatchUserAgent performs a detection on an User-Agent string. This matches the C API fiftyoneDegreesResultsHashFromUserAgent.
func (*ResultsHash) MatchedNodes ¶
func (results *ResultsHash) MatchedNodes() int32
MatchedNodes returns the number of hash nodes matched within the evidence.
func (*ResultsHash) Method ¶
func (results *ResultsHash) Method() MatchMethod
Method returns the method used to determine the match result.
func (*ResultsHash) MethodByIndex ¶
func (results *ResultsHash) MethodByIndex(index uint32) (MatchMethod, error)
MethodByIndex returns the method use to determine a match result pointed by a index.
func (*ResultsHash) NoValueReasonMessage ¶
func (results *ResultsHash) NoValueReasonMessage( propertyName string) (message string, err error)
NoValueReasonMessage returns the no value message of a given property name.
func (*ResultsHash) NoValueReasonMessageByIndex ¶
func (results *ResultsHash) NoValueReasonMessageByIndex( requiredPropertyIndex int) (message string, err error)
NoValueReasonMessageByIndex returns the no value message of a given property index. This matches a combination of the C APIs fiftyoneDegreesResultsNoValueReason and fiftyoneDegreesResultsHashGetNoValueReasonMessage
func (*ResultsHash) PropertyName ¶
func (results *ResultsHash) PropertyName( requiredPropertyIndex int) string
PropertyName returns the name of a property at a given index.
func (*ResultsHash) PropertyType ¶
func (results *ResultsHash) PropertyType( requiredPropertyIndex int) reflect.Type
PropertyType returns the type that a value of a property determined by a given proprety index can have.
TODO: To be implemeted
func (*ResultsHash) RequiredPropertyIndexFromName ¶
func (results *ResultsHash) RequiredPropertyIndexFromName( propertyName string) int
RequiredPropertyIndexFromName returns the required index of a property using its name
func (*ResultsHash) ResponseHeaders ¶
func (results *ResultsHash) ResponseHeaders( manager *ResourceManager) (headers map[string]string, err error)
GetResponseHeaders construct a map of Headers and their values to be set in a HTTP response.
func (*ResultsHash) SetResponseHeaders ¶
func (results *ResultsHash) SetResponseHeaders( w http.ResponseWriter, manager *ResourceManager) error
ResponseHeaders constructs the response header and use the input response writer to write the headers to the response.
func (*ResultsHash) Trace ¶
func (results *ResultsHash) Trace() string
Trace returns the trace route in a readable format.
TODO: To be implemeted
func (*ResultsHash) TraceByIndex ¶
func (results *ResultsHash) TraceByIndex(index uint32) (string, error)
TraceByIndex returns the trace reoute in a readable format of a result pointed by a given index.
TODO: To be implemeted
func (*ResultsHash) UserAgent ¶
func (results *ResultsHash) UserAgent(index int) (string, error)
UserAgent return the user agent of a result pointed by a given index.
func (*ResultsHash) UserAgents ¶
func (results *ResultsHash) UserAgents() uint32
UserAgents returns number of User-Agents that were used in the results.
func (*ResultsHash) Values ¶
func (results *ResultsHash) Values( requiredPropertyIndex int) (values []string, err error)
Values returns a list of values resulted from a detection for a given property index.
TODO: To be implemeted
func (*ResultsHash) ValuesString ¶
func (results *ResultsHash) ValuesString( propertyName string, separator string) (value string, err error)
ValuesString returns a string of all values resulted from a detection. If there are multiple values, they are separated by the specified separator.