Class: ParamBuilder
- Inherits:
-
Object
- Object
- ParamBuilder
- Defined in:
- lib/capi_param_builder.rb
Constant Summary collapse
- FBC_NAME =
"_fbc"- FBP_NAME =
"_fbp"- DEFAULT_1PC_AGE =
90 * 24 * 3600
- LANGUAGE_TOKEN =
Original Ruby language token
"BQ"- SUPPORTED_LANGUAGE_TOKENS =
["AQ", "Ag", "Aw", "BA", "BQ", "Bg"]
- MIN_PAYLOAD_SPLIT_LENGTH =
4- MAX_PAYLOAD_WITH_LANGUAGE_TOKEN_LENGTH =
5- IPV4_REGEX =
/\A(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\z/- IPV6_REGEX =
/\A(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\z|\A(?:[0-9a-fA-F]{1,4}:){1,7}:\z|\A(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}\z|\A(?:[0-9a-fA-F]{1,4}:){1,5}(?::[0-9a-fA-F]{1,4}){1,2}\z|\A(?:[0-9a-fA-F]{1,4}:){1,4}(?::[0-9a-fA-F]{1,4}){1,3}\z|\A(?:[0-9a-fA-F]{1,4}:){1,3}(?::[0-9a-fA-F]{1,4}){1,4}\z|\A(?:[0-9a-fA-F]{1,4}:){1,2}(?::[0-9a-fA-F]{1,4}){1,5}\z|\A[0-9a-fA-F]{1,4}:(?::[0-9a-fA-F]{1,4}){1,6}\z|\A:(?::[0-9a-fA-F]{1,4}){1,7}\z|\A::\z|\A(?:[0-9a-fA-F]{1,4}:){6}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\z/- DEFAULT_FORMAT =
Appendix constants
0x01- LANGUAGE_TOKEN_INDEX =
Ruby language token index
0x05- APPENDIX_LENGTH_V1 =
2- APPENDIX_LENGTH_V2 =
8- APPENDIX_NO_CHANGE =
Appendix type constants
0x00- APPENDIX_GENERAL_NEW =
0x01- APPENDIX_NET_NEW =
0x02- APPENDIX_MODIFIED_NEW =
0x03
Instance Method Summary collapse
- #get_cookies_to_set ⇒ Object
- #get_fbc ⇒ Object
- #get_fbp ⇒ Object
-
#initialize(input = nil) ⇒ ParamBuilder
constructor
A new instance of ParamBuilder.
- #process_request(host, queries, cookies, referer = nil) ⇒ Object
Constructor Details
#initialize(input = nil) ⇒ ParamBuilder
Returns a new instance of ParamBuilder.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/capi_param_builder.rb', line 38 def initialize(input = nil) @fbc_params_configs = [FbcParamConfigs.new("fbclid", "", "clickID")] @appendix_net_new = get_appendix(APPENDIX_NET_NEW) @appendix_modified_new = get_appendix(APPENDIX_MODIFIED_NEW) @appendix_no_change = get_appendix(APPENDIX_NO_CHANGE) if input.nil? return end if input.is_a?(Array) @domain_list = [] input.each do |domain_item| @domain_list.push(extract_host_from_http_host(domain_item.downcase)) end elsif input.is_a?(EtldPlusOneResolver) @etld_plus_one_resolver = input end end |
Instance Method Details
#get_cookies_to_set ⇒ Object
203 204 205 |
# File 'lib/capi_param_builder.rb', line 203 def () return end |
#get_fbc ⇒ Object
207 208 209 |
# File 'lib/capi_param_builder.rb', line 207 def get_fbc() return @fbc end |
#get_fbp ⇒ Object
211 212 213 |
# File 'lib/capi_param_builder.rb', line 211 def get_fbp() return @fbp end |
#process_request(host, queries, cookies, referer = nil) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/capi_param_builder.rb', line 177 def process_request(host, queries, , referer=nil) compute_etld_plus_one_for_host(host) = {} = Set.new() @fbc = (, FBC_NAME) @fbp = (, FBP_NAME) # Get new fbc payload new_fbc_payload = get_new_fbc_payload_from_url(queries, referer) # fbc update = (@fbc, new_fbc_payload) if !.nil? [FBC_NAME] = @fbc = .value end # fbp update = (@fbp) if !.nil? [FBP_NAME] = @fbp = .value end = Set.new(.values) return end |