Class: InternetHakai::MobileClientHandler
Overview
Constant Summary
collapse
- DOCOMO =
1
- KDDI =
2
- SOFTBANK =
3
ClientHandler::UNIQUE_BY_THREAD
Instance Attribute Summary
#performance_id, #vars
Class Method Summary
collapse
Instance Method Summary
collapse
#extend_vars, #extend_vars2, #handle_body, #initialize, #send, #set_opt, #set_var, #set_var_id
Class Method Details
.on_config_load(config) ⇒ Object
111
112
113
114
115
116
117
118
|
# File 'lib/internethakai/client_handler.rb', line 111
def self::on_config_load config
if(config.has_key? "uid_path")
s = File::open(config["uid_path"]){|io|io.read}
lines = s.split("\n")
config["uids"] = lines.map{|i|i.split(",")}.sort_by{rand}
end
config
end
|
Instance Method Details
#get_carrier ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/internethakai/client_handler.rb', line 146
def get_carrier
ids = @opts["uids"]
idx = @performance_id % ids.size
data = ids[idx]
unless data
if @opt["carrier"]
@opt["carrier"]
end
DOCOMO
else
idx = @performance_id % ids.size
ids[idx][0]
end
end
|
#get_uid ⇒ Object
140
141
142
143
144
145
|
# File 'lib/internethakai/client_handler.rb', line 140
def get_uid
ids = @opts["uids"]
return ids unless ids.is_a? Array
idx = @performance_id % ids.size
ids[idx][1]
end
|
#handle_client(client) ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/internethakai/client_handler.rb', line 119
def handle_client client
super
uid = get_uid
case get_carrier
when DOCOMO
@client.("http_x_dcmguid", uid)
when KDDI
@client.("http_x_up_subno", uid)
when SOFTBANK
@client.("http_x_jphone_uid", uid)
end
@client
end
|
#handle_url(client, url, opt) ⇒ Object
132
133
134
135
136
137
138
139
|
# File 'lib/internethakai/client_handler.rb', line 132
def handle_url client, url, opt
url = super
q = Util::get_query(url)
if q["uid"] == "NULLGWDOCOMO"
url = Util::set_params(url.gsub("uid=NULLGWDOCOMO", ""), {"uid" => get_uid})
end
url
end
|