◆ FIFTYONE_DEGREES_MAX_STRING
#define FIFTYONE_DEGREES_MAX_STRING 20000 |
Maximum value string being returned.
The biggest Javascript is 11666 so choose a number that is reasonably bigger than as as max length
\r\n
struct | ngx_http_51D_data_to_set
Structure containing details of a specific header to be set as per the config file. More...
|
struct | ngx_http_51D_match_conf_t
Match config structure set from the config file. More...
|
struct | ngx_http_51D_loc_conf_t
Module location config. More...
|
struct | ngx_http_51D_main_conf_t
Module main config. More...
|
struct | ngx_http_51D_srv_conf_t
Module server config. More...
|
#define | FIFTYONE_DEGREES_DEFAULTFILE (u_char*) "51Degrees-LiteV4.1.hash"
Default data file to use.
|
#define | FIFTYONE_DEGREES_PROPERTY_NOT_AVAILABLE "NoMatch"
Default property value if it is not available or no match is found.
|
#define | FIFTYONE_DEGREES_JAVASCRIPT_NOT_AVAILABLE "/* 51Degrees Javascript not available. */"
Default Javascript content if it is not available or no match is found.
|
#define | FIFTYONE_DEGREES_VALUE_SEPARATOR (u_char*) ","
Default separator.
|
#define | FIFTYONE_DEGREES_MAX_STRING 20000
Maximum value string being returned. More...
|
#define | FIFTYONE_DEGREES_MAX_PROPS_STRING 2048
Maxium size of string hold full properties list.
|
#define | FIFTYONE_DEGREES_SET_HEADER_PREFIX "SetHeader"
The SetHeader prefix value.
|
#define | FIFTYONE_DEGREES_MEMORY_ADJUSTMENT 1.1
NGINX shared memory zone requires minimum of 8 bytes and allocated size has to be power of 2. More...
|
#define | FIFTYONE_DEGREES_TRUE 1
True constant.
|
#define | FIFTYONE_DEGREES_FALSE 0
False constant.
|
#define | FIFTYONE_DEGREES_CONFIG_LEVELS 3
3 Config levels main, server and location.
|
typedef enum ngx_http_51D_performance_profile_e | ngx_http_51D_performance_profile
Performance profiles.
|
enum | ngx_http_51D_performance_profile_e { ngx_http_51D_in_memory = 1, ngx_http_51D_high_performance, ngx_http_51D_low_memory, ngx_http_51D_balanced, ngx_http_51D_balanced_temp } Performance profiles enumerator. More...
|
static void * | ngx_http_51D_create_main_conf (ngx_conf_t *cf)
Forward declaration of ngx_http_51D_create_main_conf. More...
|
static void * | ngx_http_51D_create_srv_conf (ngx_conf_t *cf)
Forward declaration of ngx_http_51D_create_srv_conf. More...
|
static void * | ngx_http_51D_create_loc_conf (ngx_conf_t *cf)
Forward declaration of ngx_http_51D_create_loc_conf. More...
|
static char * | ngx_http_51D_merge_loc_conf (ngx_conf_t *cf, void *parent, void *child)
Forward declaration of ngx_http_51D_merge_loc_conf. More...
|
static char * | ngx_http_51D_merge_srv_conf (ngx_conf_t *cf, void *parent, void *child)
Forward declaration of ngx_http_51D_merge_srv_conf. More...
|
static char * | ngx_http_51D_set_loc_resp (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
Forward declaration of ngx_http_51D_set_loc_resp. More...
|
static char * | ngx_http_51D_set_srv_resp (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
Forward declaration of ngx_http_51D_set_srv_resp. More...
|
static char * | ngx_http_51D_set_main_resp (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
Forward declaration of ngx_http_51D_set_main_resp. More...
|
static char * | ngx_http_51D_set_loc_cdn (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
Forward declaration of ngx_http_51D_set_loc_cdn. More...
|
static char * | ngx_http_51D_set_loc (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
Forward declaration of ngx_http_51D_set_loc. More...
|
static char * | ngx_http_51D_set_srv (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
Forward declaration of ngx_http_51D_set_srv. More...
|
static char * | ngx_http_51D_set_main (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
Forward declaration of ngx_http_51D_set_main. More...
|
static ngx_int_t | ngx_http_51D_handler (ngx_http_request_t *r)
Forward declaration of ngx_http_51D_handler. More...
|
static ngx_int_t | ngx_http_51D_header_filter (ngx_http_request_t *r)
Forward declaration of ngx_http_51D_header_filter. More...
|
static ngx_int_t | ngx_http_51D_body_filter (ngx_http_request_t *r, ngx_chain_t *in)
Forward declaration of ngx_http_51D_body_filter. More...
|
static ngx_int_t | ngx_http_51D_init_shm_resource_manager (ngx_shm_zone_t *shm_zone, void *data)
Forward declaration of ngx_http_51D_init_shm_resource_manager. More...
|
static ngx_int_t | report_status (ngx_log_t *log, StatusCode status, const char *fileName)
Report the status code returned by one of the 51Degrees APIs. More...
|
static ngx_int_t | report_insufficient_memory_status (ngx_log_t *log)
Report the insufficient memory since memory allocation is a common activity. More...
|
static ConfigHash | get_config_hash (ngx_http_51D_main_conf_t *fdmcf)
Get a fiftyoneDegreesConfigHash instance based on the main configuration. More...
|
static ngx_int_t | ngx_http_51D_post_conf (ngx_conf_t *cf)
Module post config. More...
|
static void | ngx_http_51D_init_match_conf (ngx_http_51D_match_conf_t *matchConf)
Initialises the match config so no headers and body are set. More...
|
void * | ngx_http_51D_shm_alloc (size_t __size)
Shared memory alloc function. More...
|
void * | ngx_http_51D_shm_alloc_aligned (int alignment, size_t __size)
Shared memory alloc aligned function. More...
|
void | ngx_http_51D_shm_free (void *__ptr)
Shared memory free function. More...
|
static ngx_int_t | ngx_http_51D_init_module (ngx_cycle_t *cycle)
Init module function. More...
|
static const char * | skipComponentName (const char *headerName)
Skip the component name in the header and return the pointer to the response header name. More...
|
static ngx_int_t | getRespHeaderIndex (ngx_str_t *headerNames, const char *headerName, ngx_uint_t respHeaderCount)
Get the header index of a given header name in the list of detected headers. More...
|
static ngx_http_51D_data_to_set * | getRespHeader (ngx_http_51D_data_to_set *respHeader, const char *headerName)
Find a header name in a header to set linked list. More...
|
static ngx_int_t | initRespHeaders (ngx_cycle_t *cycle, ngx_http_51D_main_conf_t *fdmcf, DataSetHash *dataSet)
Initialise the array of response headers to set. More...
|
static ngx_int_t | ngx_http_51D_init_process (ngx_cycle_t *cycle)
Init process function. More...
|
void | ngx_http_51D_exit_process (ngx_cycle_t *cycle)
Exit process function. More...
|
void | ngx_http_51D_exit_master (ngx_cycle_t *cycle)
Exit master process. More...
|
static ngx_table_elt_t * | search_headers_in (ngx_http_request_t *r, u_char *name, size_t len)
Search headers function. More...
|
static void | add_value (char *delimiter, char *val, char *dst, size_t length)
Add value function. More...
|
static bool | is_metadata (char *val)
Check if a property being requested is a meta data property. More...
|
static ngx_str_t * | empty_string (ngx_http_request_t *r)
Create an empty ngx string from the http request pool. More...
|
static ngx_str_t * | get_evidence_from_query_string_base (ngx_http_request_t *r, ngx_str_t *variableName)
Search and get the evidence from the query string. More...
|
static ngx_str_t * | get_evidence_from_query_string (ngx_http_request_t *r, ngx_str_t *variableName)
Search and get the evidence from the query string. More...
|
static void | add_override_evidence_from_cookie_and_query (ngx_http_request_t *r, ResultsHash *results, EvidenceKeyValuePairArray *evidence, ngx_array_t *cookies)
Add evidence required by the Hash device detection from cookie and query string. More...
|
static EvidenceKeyValuePairArray * | get_evidence (ResultsHash *results, ngx_http_request_t *r)
Create an evidence array and added the evidence from the http request. More...
|
ngx_uint_t | ngx_http_51D_get_match (ngx_http_51D_main_conf_t *fdmcf, ngx_http_request_t *r, int multi, ngx_str_t *userAgent)
Get match function. More...
|
static void | removeUnknown (char *dest, ngx_int_t *charsAdded)
Remove Unknown string from a given string and updated the number of characers added with 'Unknown' being removed. More...
|
void | ngx_http_51D_get_value (ngx_http_51D_main_conf_t *fdmcf, ngx_http_request_t *r, char *values_string, const char *requiredPropertyName, size_t length, ngx_uint_t includeNotAvailable, const char *customSeparator)
Get value function. More...
|
static ngx_str_t * | ngx_http_51D_get_user_agent (ngx_http_request_t *r, ngx_http_51D_data_to_set *data)
Get the user agent using the header name specified by the user in the configuration. More...
|
u_char * | getEscapedMatchedValueString (ngx_http_request_t *r, ngx_http_51D_main_conf_t *fdmcf, ngx_http_51D_data_to_set *header, int haveMatch, ngx_uint_t includeNotAvailable, ngx_str_t *userAgent, const char *customSeparator)
Perform detection if required and returned an escaped value string for the header to set. More...
|
ngx_uint_t | process (ngx_http_request_t *r, ngx_http_51D_main_conf_t *fdmcf, ngx_http_51D_data_to_set *header, ngx_table_elt_t *h[], int matchIndex, int haveMatch, ngx_str_t *userAgent)
Process a request and perform device detection based on the request info. More...
|
static ngx_table_elt_t * | findResponseHeader (ngx_http_request_t *r, ngx_str_t headerName)
Find a header in the response header list. More...
|
static char * | set_data (ngx_conf_t *cf, ngx_http_51D_data_to_set *data, ngx_str_t *value, char *propertiesString, int propertiesCount, ngx_http_51D_main_conf_t *fdmcf)
Set data function. More...
|
static char * | ngx_http_51D_set_header (ngx_conf_t *cf, ngx_http_51D_data_to_set *header, ngx_str_t *value, ngx_http_51D_main_conf_t *fdmcf)
Set up the header to be set. More...
|
static char * | ngx_http_51D_set_body (ngx_conf_t *cf, ngx_http_51D_data_to_set *body, ngx_str_t *value, ngx_http_51D_main_conf_t *fdmcf)
Set up the body to be set. More...
|
static char * | ngx_http_51D_set_conf_header (ngx_conf_t *cf, ngx_command_t *cmd, ngx_http_51D_match_conf_t *matchConf)
Set function. More...
|
static char * | ngx_http_51D_set_conf_body (ngx_conf_t *cf, ngx_command_t *cmd, ngx_http_51D_match_conf_t *matchConf)
Set function. More...
|
static char * | ngx_http_51D_set_conf_resp (ngx_conf_t *cf, ngx_command_t *cmd, ngx_http_51D_match_conf_t *matchConf)
Set function. More...
|
ngx_module_t | ngx_http_51D_module
Global module declaration. More...
|
static ngx_http_output_header_filter_pt | ngx_http_next_header_filter
Declaration of the next header filter function pointer.
|
static ngx_http_output_body_filter_pt | ngx_http_next_body_filter
Declaration of the next body filter function pointer.
|
static ngx_shm_zone_t * | ngx_http_51D_shm_resource_manager
Pointer to shared memory zones.
|
ngx_atomic_t | ngx_http_51D_shm_tag = 1
Atomic integer used to ensure a new data set memory zone on each reload.
|
ngx_atomic_t * | ngx_http_51D_worker_count
Count number of current worker processes.
|
static ngx_conf_enum_t | ngx_http_51D_performance_profiles []
Performance profile map, to map user specified string with corresponding profile. More...
|
static ngx_command_t | ngx_http_51D_commands []
Definitions of functions which can be called from the config file. More...
|
static ngx_http_module_t | ngx_http_51D_module_ctx
Module context. More...
|
#define FIFTYONE_DEGREES_MAX_STRING 20000 |
Maximum value string being returned.
The biggest Javascript is 11666 so choose a number that is reasonably bigger than as as max length
#define FIFTYONE_DEGREES_MEMORY_ADJUSTMENT 1.1 |
NGINX shared memory zone requires minimum of 8 bytes and allocated size has to be power of 2.
Any non- conforming value will be rounded up. Thus make this adjustment value account for the extra rounded up memory.
Performance profiles enumerator.
NOTE: Only in_memory is currently supported.
static void add_override_evidence_from_cookie_and_query | ( | ngx_http_request_t * | r, |
ResultsHash * | results, | ||
EvidenceKeyValuePairArray * | evidence, | ||
ngx_array_t * | cookies | ||
) |
Add evidence required by the Hash device detection from cookie and query string.
static void add_value | ( | char * | delimiter, |
char * | val, | ||
char * | dst, | ||
size_t | length | ||
) |
Add value function.
Appends a string to a list separated by the delimiter specified with 51D_valueSeparator, or a comma by default.
static ngx_str_t* empty_string | ( | ngx_http_request_t * | r | ) |
Create an empty ngx string from the http request pool.
static ngx_table_elt_t* findResponseHeader | ( | ngx_http_request_t * | r, |
ngx_str_t | headerName | ||
) |
Find a header in the response header list.
static ConfigHash get_config_hash | ( | ngx_http_51D_main_conf_t * | fdmcf | ) |
Get a fiftyoneDegreesConfigHash instance based on the main configuration.
static EvidenceKeyValuePairArray* get_evidence | ( | ResultsHash * | results, |
ngx_http_request_t * | r | ||
) |
Create an evidence array and added the evidence from the http request.
This should consider the evidence sent from cookies and query, since overrides are required by customer. This requires parsing the query string for the override values. For MVP might consider the override from cookies only.
static ngx_str_t* get_evidence_from_query_string | ( | ngx_http_request_t * | r, |
ngx_str_t * | variableName | ||
) |
Search and get the evidence from the query string.
If the variable does not contains 'arg_' prefix, add it as this is required by nginx.
static ngx_str_t* get_evidence_from_query_string_base | ( | ngx_http_request_t * | r, |
ngx_str_t * | variableName | ||
) |
Search and get the evidence from the query string.
u_char* getEscapedMatchedValueString | ( | ngx_http_request_t * | r, |
ngx_http_51D_main_conf_t * | fdmcf, | ||
ngx_http_51D_data_to_set * | header, | ||
int | haveMatch, | ||
ngx_uint_t | includeNotAvailable, | ||
ngx_str_t * | userAgent, | ||
const char * | customSeparator | ||
) |
Perform detection if required and returned an escaped value string for the header to set.
static ngx_http_51D_data_to_set* getRespHeader | ( | ngx_http_51D_data_to_set * | respHeader, |
const char * | headerName | ||
) |
Find a header name in a header to set linked list.
static ngx_int_t getRespHeaderIndex | ( | ngx_str_t * | headerNames, |
const char * | headerName, | ||
ngx_uint_t | respHeaderCount | ||
) |
Get the header index of a given header name in the list of detected headers.
static ngx_int_t initRespHeaders | ( | ngx_cycle_t * | cycle, |
ngx_http_51D_main_conf_t * | fdmcf, | ||
DataSetHash * | dataSet | ||
) |
Initialise the array of response headers to set.
static bool is_metadata | ( | char * | val | ) |
Check if a property being requested is a meta data property.
static ngx_int_t ngx_http_51D_body_filter | ( | ngx_http_request_t * | r, |
ngx_chain_t * | in | ||
) |
Forward declaration of ngx_http_51D_body_filter.
Body filter of the response.
This is called first in the body filter chain. It then call the subsequent filter in the chain with the updated response and either old or new content, depending on whether a matching is successfully performed.
static void * ngx_http_51D_create_loc_conf | ( | ngx_conf_t * | cf | ) |
Forward declaration of ngx_http_51D_create_loc_conf.
Create location config.
Allocates memory to the configuration.
static void * ngx_http_51D_create_main_conf | ( | ngx_conf_t * | cf | ) |
Forward declaration of ngx_http_51D_create_main_conf.
Create main config.
Allocates memory to the configuration and initialises config options to -1 (unset).
static void * ngx_http_51D_create_srv_conf | ( | ngx_conf_t * | cf | ) |
Forward declaration of ngx_http_51D_create_srv_conf.
Create server config.
Allocates memory to the configuration.
void ngx_http_51D_exit_master | ( | ngx_cycle_t * | cycle | ) |
Exit master process.
Frees resource created for the 51Degrees module.
void ngx_http_51D_exit_process | ( | ngx_cycle_t * | cycle | ) |
Exit process function.
Frees the results set that was created on process init.
ngx_uint_t ngx_http_51D_get_match | ( | ngx_http_51D_main_conf_t * | fdmcf, |
ngx_http_request_t * | r, | ||
int | multi, | ||
ngx_str_t * | userAgent | ||
) |
Get match function.
Gets a match for either a single User-Agent or all request headers.
static ngx_str_t* ngx_http_51D_get_user_agent | ( | ngx_http_request_t * | r, |
ngx_http_51D_data_to_set * | data | ||
) |
Get the user agent using the header name specified by the user in the configuration.
This is only applied to the single match.
void ngx_http_51D_get_value | ( | ngx_http_51D_main_conf_t * | fdmcf, |
ngx_http_request_t * | r, | ||
char * | values_string, | ||
const char * | requiredPropertyName, | ||
size_t | length, | ||
ngx_uint_t | includeNotAvailable, | ||
const char * | customSeparator | ||
) |
Get value function.
Gets the requested value for the current match and appends the value to the list of values separated by the delimiter specified with 51D_valueSeparator.
static ngx_int_t ngx_http_51D_handler | ( | ngx_http_request_t * | r | ) |
Forward declaration of ngx_http_51D_handler.
Module handler, gets a match using either the User-Agent or multiple http headers, then sets properties as headers.
This will call the 'process' method.
static ngx_int_t ngx_http_51D_header_filter | ( | ngx_http_request_t * | r | ) |
Forward declaration of ngx_http_51D_header_filter.
Header filter for response message.
This is called first in the header filter change. It then call subsequent filter in the chain with the updated response.
static void ngx_http_51D_init_match_conf | ( | ngx_http_51D_match_conf_t * | matchConf | ) |
Initialises the match config so no headers and body are set.
static ngx_int_t ngx_http_51D_init_module | ( | ngx_cycle_t * | cycle | ) |
Init module function.
Initialises the resrouce manager with the given initialisation parameters. Throws an error if the resource manager could not be initialised.
static ngx_int_t ngx_http_51D_init_process | ( | ngx_cycle_t * | cycle | ) |
Init process function.
Creates a result set from the shared resource manager. This result set is local to the process. Here is where the ResultsHash will be initialised.
static ngx_int_t ngx_http_51D_init_shm_resource_manager | ( | ngx_shm_zone_t * | shm_zone, |
void * | data | ||
) |
Forward declaration of ngx_http_51D_init_shm_resource_manager.
Init resource manager memory zone.
Allocates space for the resource manager in the shared memory zone.
static char * ngx_http_51D_merge_loc_conf | ( | ngx_conf_t * | cf, |
void * | parent, | ||
void * | child | ||
) |
Forward declaration of ngx_http_51D_merge_loc_conf.
Merge location config.
Either gets the value of count that is set, or sets to the default of 0.
static char * ngx_http_51D_merge_srv_conf | ( | ngx_conf_t * | cf, |
void * | parent, | ||
void * | child | ||
) |
Forward declaration of ngx_http_51D_merge_srv_conf.
Merge server config.
Either gets the value of count that is set, or sets to the default of 0.
static ngx_int_t ngx_http_51D_post_conf | ( | ngx_conf_t * | cf | ) |
Module post config.
Adds the module to the HTTP access phase array, sets the defaults if necessary, and sets the shared memory zones. Added header and body filter to the filter chain for develiring Javascript content upon requests.
This will initialise the main configuration data, including the performanceProfile, drift, difference ...
static char* ngx_http_51D_set_body | ( | ngx_conf_t * | cf, |
ngx_http_51D_data_to_set * | body, | ||
ngx_str_t * | value, | ||
ngx_http_51D_main_conf_t * | fdmcf | ||
) |
Set up the body to be set.
static char* ngx_http_51D_set_conf_body | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
ngx_http_51D_match_conf_t * | matchConf | ||
) |
Set function.
Is called for each occurrence of "51D_get_javascript_single" or "51D_get_javascript_all". Allocates space for the body structure and initialises it with the set body function.
static char* ngx_http_51D_set_conf_header | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
ngx_http_51D_match_conf_t * | matchConf | ||
) |
Set function.
Is called for each occurrence of "51D_match_single" or "51D_match_all". Allocates space for the header structure and initialises it with the set header function.
static char* ngx_http_51D_set_conf_resp | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
ngx_http_51D_match_conf_t * | matchConf | ||
) |
Set function.
Is called for each occurrence of "51D_set_resp_headers" Allocates space for the body structure and initialises it with the set body function.
static char* ngx_http_51D_set_header | ( | ngx_conf_t * | cf, |
ngx_http_51D_data_to_set * | header, | ||
ngx_str_t * | value, | ||
ngx_http_51D_main_conf_t * | fdmcf | ||
) |
Set up the header to be set.
static char * ngx_http_51D_set_loc | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
void * | conf | ||
) |
Forward declaration of ngx_http_51D_set_loc.
Set function.
Is called for occurrences of "51D_match_single" or "51D_match_all" in a location config block. Allocates space for the header structure and initialises it with the set header function.
static char * ngx_http_51D_set_loc_cdn | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
void * | conf | ||
) |
Forward declaration of ngx_http_51D_set_loc_cdn.
Set function.
Is called for occurrences of "51D_get_javascript_single" or "51D_javascript_all" in a location config block. Allocates space for the body structure and initialises it with the set body function.
static char * ngx_http_51D_set_loc_resp | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
void * | conf | ||
) |
Forward declaration of ngx_http_51D_set_loc_resp.
Set function.
Is called for occurrences of "51D_set_resp_headers" in a location config block.
static char * ngx_http_51D_set_main | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
void * | conf | ||
) |
Forward declaration of ngx_http_51D_set_main.
Set function.
Is called for occurrences of "51D_match_single" or "51D_match_all" in a http config block. Allocates space for the header structure and initialises it with the set header function.
static char * ngx_http_51D_set_main_resp | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
void * | conf | ||
) |
Forward declaration of ngx_http_51D_set_main_resp.
Set function.
Is called for occurrences of "51D_set_resp_headers" in a main config block.
static char * ngx_http_51D_set_srv | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
void * | conf | ||
) |
Forward declaration of ngx_http_51D_set_srv.
Set function.
Is called for occurrences of "51D_match_single" or "51D_match_all" in a server config block. Allocates space for the header structure and initialises it with the set header function.
static char * ngx_http_51D_set_srv_resp | ( | ngx_conf_t * | cf, |
ngx_command_t * | cmd, | ||
void * | conf | ||
) |
Forward declaration of ngx_http_51D_set_srv_resp.
Set function.
Is called for occurrences of "51D_set_resp_headers" in a server config block.