1 |
|
2 | var tr = require('tor-request');
|
3 | tr.TorControlPort.password = 'hotelpartner';
|
4 | var general = {
|
5 | "generateDeviceID": function generateDeviceID(show = false) {
|
6 |
|
7 |
|
8 | let nr1 = Math.floor((Math.random() * 9999) + 1000);
|
9 | let nr2 = Math.floor((Math.random() * 9999) + 1000);
|
10 | let nr3 = Math.floor((Math.random() * 1) + 10);
|
11 | if(show)
|
12 | console.log('generateDeviceID: '+ `72331403-${nr1}-${nr2}-${nr3}`)
|
13 |
|
14 | return `72331403-${nr1}-${nr2}-${nr3}`
|
15 | },
|
16 | "getNewIP": function getNewIP(ischanging=false) {
|
17 |
|
18 | return new Promise(resolve=>{
|
19 |
|
20 | console.log('old ip: ' + currentip);
|
21 |
|
22 | hp_bot.general.generateDeviceID(true);
|
23 |
|
24 | if(ischanging)
|
25 | socket.emit('newip',slave, async function(status) {
|
26 | console.log("callback")
|
27 | currentip = await _SERVER.showExternalIP(false)
|
28 |
|
29 | if(!currentip)
|
30 | setTimeout(()=>{getNewIP();},1000);
|
31 | else
|
32 | {
|
33 | console.log("new ip:"+currentip)
|
34 | resolve(currentip)
|
35 | }
|
36 | });
|
37 |
|
38 | else{
|
39 | setTimeout(()=>{
|
40 | resolve(currentip)
|
41 | },40000)
|
42 | }
|
43 | })
|
44 | },
|
45 | "getXMLData": function fetchIphoneXMLData(adult,start,end,city,cityid) {
|
46 | return new Promise(resolve=>{
|
47 | const devid = general.generateDeviceID();
|
48 | const _url = `https://iphone-xml.booking.com/json/bookings.getHotelAvailabilityMobile?detail_level=1&genius_freebies=2&show_distance_cc=1&request_less_fields=2&show_facilities_review_score=1&show_last_minute_saving=1&include_translations=2&add_bh_info=1&languagecode=de&urgency=1&include_taxes=1&include_count=1&location_source=autocomplete&show_price_trend=1&show_deals=flash%2Clastm%2Csmart%2Cgenius&children_qty=0&low_av_alternatives=0&&&order_by=popularity&show_if_class_is_estimated=1&show_categories=v3&show_location_score=1&show_last_reservation_text=1&show_reinforcement_text=v2&show_filtered_facilities=1&show_if_no_cc_allowed=2&show_soldout=1&show_is_personalized_result=0&show_flash_saving=1&max_persons=-2&use_direct_payment=1&add_ctrip_info=1&include_rack_rate_savings=1&&include_url=1&bh_alt_urgency_msg=1&show_refundable=1&check_price_is_final=1&show_extra_charges=1&room_qty=1&show_if_city_center=1&available_rooms=0&price_buckets=100&flash_deals_amount_if_unsigned=2&show_low_availability=2&show_business_badge=1&autoextend=1&user_os=6.0.1&user_version=11.3.1-android&network_type=wifi&bt=1&arrival_date=${start}&departure_date=${end}&city_ids=${cityid.replace('city=', '').replace('|si=ai%2Cco%2Cci%2Cre%2Cdi', '')}&rows=5000&device_id=${devid}da-ef8edab1ad7f&guest_qty=${adult}`;
|
49 | const options = {
|
50 | headers: {
|
51 | 'Content-Type' : 'application/x-www-form-urlencoded',
|
52 | 'Authorization': 'Basic dGhlc2FpbnRzYnY6ZGdDVnlhcXZCeGdN'
|
53 | },
|
54 | url: _url,
|
55 | timeout: 900000
|
56 | };
|
57 |
|
58 |
|
59 | tr.request(options, function (err, resp, body) {
|
60 | console.log(body)
|
61 | resolve(JSON.parse(body));
|
62 | })
|
63 | })
|
64 | }
|
65 | }
|
66 |
|
67 |
|
68 |
|
69 | setInterval(()=>{
|
70 | tr.renewTorSession(function () {
|
71 | general.getXMLData(1,'2017-10-15','2017-10-17','bern','-2551235');
|
72 | tr.request('https://api.ipify.org', function (err, res, body) {
|
73 | if (!err && res.statusCode == 200)
|
74 | {
|
75 | console.log("Your public (through Tor) IP is: " + body);
|
76 | }else
|
77 | console.log(err)
|
78 | });
|
79 |
|
80 | })
|
81 | },4000)
|