Class: WiFiPortal_1

Inherits:
Object
  • Object
show all
Defined in:
lib/freewifi/general/wifi_portal_procedures.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apigw_wsdl, apigw_endpoint, apigw_namespace, apigw_wsse_aut_log, apigw_wsse_aut_pass, iwag1_host, iwag1_username, iwag1_password, iwag1_port, mtik_control_ips_get, mtik_user, mtik_password, hua_wlc_1_ip, hua_wlc_2_ip, hua_wlc_login, hua_wlc_password, iwag2_host, iwag2_username, iwag2_password, iwag2_port, protocol_mtik, mtik_capsman_list) ⇒ WiFiPortal_1

Returns a new instance of WiFiPortal_1.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 28

def initialize(apigw_wsdl,
               apigw_endpoint,
               apigw_namespace,
               apigw_wsse_aut_log,
               apigw_wsse_aut_pass,
               iwag1_host,
               iwag1_username,
               iwag1_password,
               iwag1_port,
               mtik_control_ips_get,
               mtik_user,
               mtik_password,
               hua_wlc_1_ip,
               hua_wlc_2_ip,
               ,
               hua_wlc_password,
               iwag2_host,
               iwag2_username,
               iwag2_password,
               iwag2_port,
               protocol_mtik,
               mtik_capsman_list
)
  @iwag_telnet_connector = CSRtelnet_1.new(iwag1_host, iwag1_username, iwag1_password)
  @ard_api_gw_connector_wifi = Savon.client do
    #ssl_verify_mode :none
    wsdl apigw_wsdl
    endpoint apigw_endpoint
    namespace apigw_namespace
    wsse_auth(apigw_wsse_aut_log, apigw_wsse_aut_pass, :digest)
    encoding 'UTF-8'
    headers = {"Accept-Encoding" => "gzip, deflate", "Connection" => "Keep-Alive"}
  end

  @iwag1_host = iwag1_host
  @iwag_username = iwag1_username
  @iwag_password = iwag1_password

  @mtik_api_connector = NEWhubWifiApi_1.new(mtik_control_ips_get, mtik_user, mtik_password)

  @hua_controller_connector = HuaWifi_1.new(hua_wlc_1_ip, hua_wlc_2_ip, , hua_wlc_password)

  @iwag_connector1 = IwagRequester.new(iwag1_host, iwag1_username, iwag1_password, iwag1_port)
  @iwag_connector2 = IwagRequester.new(iwag2_host, iwag2_username, iwag2_password, iwag2_port)

  @protocol_mtik = protocol_mtik
  @mtik_capsman_list = mtik_capsman_list
end

Instance Attribute Details

#ard_api_gw_connector_wifiObject

Returns the value of attribute ard_api_gw_connector_wifi.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def ard_api_gw_connector_wifi
  @ard_api_gw_connector_wifi
end

#hua_controller_connectorObject

Returns the value of attribute hua_controller_connector.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def hua_controller_connector
  @hua_controller_connector
end

#iwag1_hostObject

Returns the value of attribute iwag1_host.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def iwag1_host
  @iwag1_host
end

#iwag_connector1Object

Returns the value of attribute iwag_connector1.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def iwag_connector1
  @iwag_connector1
end

#iwag_connector2Object

Returns the value of attribute iwag_connector2.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def iwag_connector2
  @iwag_connector2
end

#iwag_passwordObject

Returns the value of attribute iwag_password.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def iwag_password
  @iwag_password
end

#iwag_telnet_connectorObject

Returns the value of attribute iwag_telnet_connector.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def iwag_telnet_connector
  @iwag_telnet_connector
end

#iwag_usernameObject

Returns the value of attribute iwag_username.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def iwag_username
  @iwag_username
end

#mtik_api_connectorObject

Returns the value of attribute mtik_api_connector.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def mtik_api_connector
  @mtik_api_connector
end

#mtik_capsman_listObject

Returns the value of attribute mtik_capsman_list.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def mtik_capsman_list
  @mtik_capsman_list
end

#mtik_control_ips_getObject

Returns the value of attribute mtik_control_ips_get.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def mtik_control_ips_get
  @mtik_control_ips_get
end

#mtik_passwordObject

Returns the value of attribute mtik_password.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def mtik_password
  @mtik_password
end

#mtik_userObject

Returns the value of attribute mtik_user.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def mtik_user
  @mtik_user
end

#protocol_mtikObject

Returns the value of attribute protocol_mtik.



13
14
15
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 13

def protocol_mtik
  @protocol_mtik
end

Instance Method Details

#get_subs_add_info3_1(ipaddress, access_interface) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 121

def get_subs_add_info3_1(ipaddress, access_interface)


  answer = ""

  #region get additional information
  if access_interface != "false"

    subscribers_mac = ""

    begin

      dump =""
      connection = Net::Telnet.new("Host" => "172.24.247.183", "Timeout" => false, "Prompt" => /.*#/) {|str|}
      connection.({"Name" => iwag_username, "Password" => iwag_password, "LoginPrompt" => /Username:/}) {|str|}
      connection.cmd("show ip dhcp binding #{ipaddress}") {
          |c|
        dump << c
      }
      connection.close
      as = dump.split("\n")
      reer = as[4].split(" ")

      ma = reer[1].to_s.upcase
      pos = ma[0]+ma[1]
      if pos=="01"
        subscribers_mac = ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]+":"+ma[15]+ma[16]
      else
        subscribers_mac = ma[0]+ma[1]+":"+ma[2]+ma[3]+":"+ma[5]+ma[6]+":"+ma[7]+ma[8]+":"+ma[10]+ma[11]+":"+ma[12]+ma[13]
      end

    rescue
      subscribers_mac = "unknown"
    end


    begin
      thr0 = Thread.new do
        begin
          p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.247.15")
          splitting5 = mikr_info5.split("---")
          if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
            answer = mikr_info5
          end
        rescue
          p "thr1 wrong"
        end
      end
    rescue
      p "thread 0 failed"
    end


    begin
      thr1 = Thread.new do
        begin
          p mikr_info7 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.214.155")
          splitting7 = mikr_info7.split("---")
          if splitting7[1] != "not on mikrotik controller" && splitting7[1]!="unknown" && splitting7[1]!=nil
            answer = mikr_info7
          end
        rescue
          p "thr1 wrong"
        end
      end
    rescue
      p "thread 1 failed"
    end


    begin
      thr2 = Thread.new do
        begin
          p mikr_info9 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.214.140")
          splitting9 = mikr_info9.split("---")
          if splitting9[1] != "not on mikrotik controller" && splitting9[1]!="unknown" && splitting9[1]!=nil
            answer = mikr_info9
          end
        rescue
          p "thr2 wrong"
        end
      end
    rescue
      p "thread 2 failed"
    end


    begin
      thr3 = Thread.new do
        begin
          p mikr_info9 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.214.105")
          splitting9 = mikr_info9.split("---")
          if splitting9[1] != "not on mikrotik controller" && splitting9[1]!="unknown" && splitting9[1]!=nil
            answer = mikr_info9
          end
        rescue
          p "thr3 wrong"
        end
      end
    rescue
      p "thread 3 failed"
    end

    begin
      thr4 = Thread.new do
        begin
          p mikr_info9 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, "172.24.223.105")
          splitting9 = mikr_info9.split("---")
          if splitting9[1] != "not on mikrotik controller" && splitting9[1]!="unknown" && splitting9[1]!=nil
            answer = mikr_info9
          end
        rescue
          p "thr4 wrong"
        end
      end
    rescue
      p "thread 4 failed"
    end


    thr0.join
    thr1.join
    thr2.join
    thr3.join
    thr4.join

    if answer==""
      answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
    end

  end


  return answer

end

#get_subs_add_info4new_1(access_interface, subscribers_mac) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 261

def get_subs_add_info4new_1(access_interface, subscribers_mac)

  capsman_list = mtik_capsman_list

  answer = ""

  #region get additional information
  if access_interface != "false"

    p subscribers_mac

    threads_mikro_wlc = []
    capsman_list.each do |capsman|
      threads_mikro_wlc << Thread.new do
        begin
          if protocol_mtik == 'api'
            p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
            splitting5 = mikr_info5.split("---")
            if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
              answer = mikr_info5
              p answer
            end
          elsif protocol_mtik == 'ssh'
            p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_ssh(subscribers_mac, capsman)
            splitting5 = mikr_info5.split("---")
            if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
              answer = mikr_info5
              p answer
            end
          else
            p mikr_info5 = mtik_api_connector.get_info_subs_from_mik_1(subscribers_mac, capsman)
            splitting5 = mikr_info5.split("---")
            if splitting5[1] != "not on mikrotik controller" && splitting5[1]!="unknown" && splitting5[1]!=nil
              answer = mikr_info5
              p answer
            end
          end
        rescue
          p "thr0 wrong"
        end
      end
    end
    threads_mikro_wlc.each(&:join)

    if answer==""
      answer = subscribers_mac + "---" + "not on mikrotik controller" + "---" + "unknown" + "---" + "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown" + "---"+ "unknown"
    end
  end
  answer
end

#get_subs_info_ret_ssh_1(ip_address) ⇒ Object



693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 693

def get_subs_info_ret_ssh_1(ip_address)

  input_params = {:ip_address => ip_address}
  output_params = {}

  begin
    ipaddr_transformed = IPAddr.new ip_address
    ipaddr_network = ipaddr_transformed.mask(17).to_s

    if ipaddr_network == "100.71.0.0" #iwag old

      output_params = self.proc_100_71_0_0_ssh(ip_address)

    elsif ipaddr_network == "100.75.0.0" #min11iwag2

      output_params = self.proc_100_75_0_0_ssh(ip_address)

    elsif ipaddr_network == "100.70.0.0" #min11iwag1

      output_params = self.proc_100_70_0_0_ssh(ip_address)

    else
      output_params = {:code => 404, :result => "ERROR. Unknown IP Pool."}
    end

  rescue
    output_params = {:code => 500, :result => "ERROR. Something wrong.", :body => "SOAP mts_wifi_get_subs_info_return errorMethod unknown error"}
  end

  output_params

end

#get_subs_info_return_1(ip_address) ⇒ Object



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 659

def get_subs_info_return_1(ip_address)

  input_params = {:ip_address => ip_address}
  output_params = {}

  begin
    ipaddr_transformed = IPAddr.new ip_address
    ipaddr_network = ipaddr_transformed.mask(17).to_s

    if ipaddr_network == "100.71.0.0" #iwag old

      output_params = self.proc_100_71_0_0(ip_address)

    elsif ipaddr_network == "100.75.0.0" #min11iwag2

      output_params = self.proc_100_75_0_0(ip_address)

    elsif ipaddr_network == "100.70.0.0" #min11iwag1

      output_params = self.proc_100_70_0_0(ip_address)

    else
      output_params = {:code => 404, :result => "ERROR. Unknown IP Pool."}
    end

  rescue
    output_params = {:code => 500, :result => "ERROR. Something wrong.", :body => "SOAP mts_wifi_get_subs_info_return errorMethod unknown error"}
  end

  output_params

end

#proc_100_70_0_0(ip_address) ⇒ Object



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 552

def proc_100_70_0_0(ip_address)
  p "min11iwag1"

  begin
    result_iwag = self.python_mac_iwag1_1(ip_address)
    p result_iwag
    if result_iwag.split(" ")[0]!="Unknown"
      ppp = result_iwag.split(" ")

      subs_mac = ppp[0]
      access_int = ppp[1]
      access_poi = ppp[2]
      ssid_a = ppp[3]


      if access_int=='GigabitEthernet4.3002'
        access_poi = "belrw_4_HP_ap1-1"
        ssid_a = "BelRW_WiFi"
      elsif access_int=='GigabitEthernet4.3005'
        access_poi = "belbiz-AP1-1"
        ssid_a = "IMAGURU_GUEST"
      end

      if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
        frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
        splitting5 = frommikrotik.split("---")
        p access_poi = splitting5[1]
        p ssid_a = splitting5[2]
        p tx_rate_se = splitting5[3]
        p tx_rat = splitting5[4]
        p rx_rat = splitting5[5]
        p rx_signa = splitting5[6]
        p uptim = splitting5[7]
        p packet = splitting5[8]
        p byt = splitting5[9]
      end

      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"

      if subs_mac=="unknown"
        output_params = {:code => 505, :result => "ERROR. Something wrong."}
      end

      if subs_mac==""
        output_params = {:code => 505, :result => "ERROR. Something wrong."}
      end

      mess = {:iwag_access_interface => access_int,
              :subscribers_mac => subs_mac,
              :access_point => access_poi,
              :ssid_ap => ssid_a,
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => tx_rate_se,
                   :tx_rate => tx_rat,
                   :rx_rate => rx_rat,
                   :rx_signal => rx_signa,
                   :uptime => uptim,
                   :packets => packet,
                   :bytes => byt}
      }
      #           logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
      output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
      p output_params

    else

      mess = {:iwag_access_interface => "unknown",
              :subscribers_mac => "unknown",
              :access_point => "unknown",
              :ssid_ap => "unknown",
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => "unknown",
                   :tx_rate => "unknown",
                   :rx_rate => "unknown",
                   :rx_signal => "unknown",
                   :uptime => "unknown",
                   :packets => "unknown",
                   :bytes => "unknown"}
      }

      #           logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"

      output_params = {:code => 405, :result => "ERROR. MAC address not found on IWAG."}

      #render :soap => mess

    end
  rescue
    puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
    output_params = {:code => 505, :result => "ERROR. Something wrong."}
  end

  output_params

  ####

end

#proc_100_70_0_0_ssh(ip_address) ⇒ Object



966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 966

def proc_100_70_0_0_ssh(ip_address)
  p "min11iwag1"

  begin
    result_iwag = self.ssh_mac_iwag1_1(ip_address)
    p result_iwag
    if result_iwag.split(" ")[0]!="Unknown"
      ppp = result_iwag.split(" ")

      subs_mac = ppp[0]
      access_int = ppp[1]
      access_poi = ppp[2]
      ssid_a = ppp[3]


      if access_int=='GigabitEthernet4.3002'
        access_poi = "belrw_4_HP_ap1-1"
        ssid_a = "BelRW_WiFi"
      elsif access_int=='GigabitEthernet4.3005'
        access_poi = "belbiz-AP1-1"
        ssid_a = "IMAGURU_GUEST"
      end

      if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
        frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
        splitting5 = frommikrotik.split("---")
        p access_poi = splitting5[1]
        p ssid_a = splitting5[2]
        p tx_rate_se = splitting5[3]
        p tx_rat = splitting5[4]
        p rx_rat = splitting5[5]
        p rx_signa = splitting5[6]
        p uptim = splitting5[7]
        p packet = splitting5[8]
        p byt = splitting5[9]
      end

      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"

      if subs_mac=="unknown"
        output_params = {:code => 505, :result => "ERROR. Something wrong."}
      end

      if subs_mac==""
        output_params = {:code => 505, :result => "ERROR. Something wrong."}
      end

      mess = {:iwag_access_interface => access_int,
              :subscribers_mac => subs_mac,
              :access_point => access_poi,
              :ssid_ap => ssid_a,
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => tx_rate_se,
                   :tx_rate => tx_rat,
                   :rx_rate => rx_rat,
                   :rx_signal => rx_signa,
                   :uptime => uptim,
                   :packets => packet,
                   :bytes => byt}
      }
      #           logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
      output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
      p output_params

    else

      mess = {:iwag_access_interface => "unknown",
              :subscribers_mac => "unknown",
              :access_point => "unknown",
              :ssid_ap => "unknown",
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => "unknown",
                   :tx_rate => "unknown",
                   :rx_rate => "unknown",
                   :rx_signal => "unknown",
                   :uptime => "unknown",
                   :packets => "unknown",
                   :bytes => "unknown"}
      }

      #           logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"

      output_params = {:code => 405, :result => "ERROR. MAC address not found on IWAG."}

      #render :soap => mess

    end
  rescue
    puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
    output_params = {:code => 505, :result => "ERROR. Something wrong."}
  end

  output_params

  ####

end

#proc_100_71_0_0(ip_address) ⇒ Object



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 313

def proc_100_71_0_0(ip_address)
  begin
    p access_int = iwag_telnet_connector.return_iwag_access_interface_1(ip_address)

    ip_a = ip_address

    access_poi = "unknown"
    ssid_a = "unknown"
    tx_rate_se = "unknown"
    tx_rat = "unknown"
    rx_rat = "unknown"
    rx_signa = "unknown"
    uptim = "unknown"
    packet = "unknown"
    byt = "unknown"

    if access_int == "Tunnel5"
      mikr_info2 = self.get_subs_add_info3_1(ip_address, access_int)
      splitting2 = mikr_info2.split("---")
      subs_mac = splitting2[0]
      access_poi = "belrw_3_Cisco_ap1-1"
      ssid_a = "BelRW_WiFi"
      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"
    elsif access_int == "GigabitEthernet2.4008"
      mikr_info3 = self.get_subs_add_info3_1(ip_address, access_int)
      splitting3 = mikr_info3.split("---")
      subs_mac = splitting3[0]
      access_poi = "belrw_4_HP_ap1-1"
      ssid_a = "BelRW_WiFi"
      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"
    elsif access_int == "Tunnel9"
      subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
      p resp1 = hua_controller_connector.get_sub_info_1(subs_mac)
      p resp=resp1.split(",,,")

      p access_poi = resp[1]
      p ssid_a = resp[2]
      p tx_rate_se = resp[3]
      p tx_rat = resp[4]
      p rx_rat = resp[5]
      p rx_signa = resp[6]
      p uptim = resp[7]
      p packet = resp[8]
      p byt = resp[9]
    elsif access_int == "Tunnel16"
      subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
      p resp1 = hua_controller_connector.get_sub_info2_1(subs_mac)
      p resp=resp1.split(",,,")

      p access_poi = resp[1]
      p ssid_a = resp[2]
      p tx_rate_se = resp[3]
      p tx_rat = resp[4]
      p rx_rat = resp[5]
      p rx_signa = resp[6]
      p uptim = resp[7]
      p packet = resp[8]
      p byt = resp[9]
    else
      p "before get info"
      p mikr_info5 = self.get_subs_add_info3_1(ip_address, access_int)
      p "after get info"
      splitting5 = mikr_info5.split("---")
      p subs_mac = splitting5[0]

      p access_poi = splitting5[1]
      p ssid_a = splitting5[2]
      p tx_rate_se = splitting5[3]
      p tx_rat = splitting5[4]
      p rx_rat = splitting5[5]
      p rx_signa = splitting5[6]
      p uptim = splitting5[7]
      p packet = splitting5[8]
      p byt = splitting5[9]


      if access_poi==nil || access_poi=="" || access_poi=="unknown"
        access_poi = "not on mikrotik controller"
      end

      if ssid_a==nil || ssid_a=="" || ssid_a=="unknown"
        ssid_a = "unknown"
        tx_rate_se = "unknown"
        tx_rat = "unknown"
        rx_rat = "unknown"
        rx_signa = "unknown"
        uptim = "unknown"
        packet = "unknown"
        byt = "unknown"
      end

    end

    if subs_mac=="unknown"
      output_params = {:code => 505, :result => "ERROR. Something wrong."}
    end

    if subs_mac==""
      subs_mac="unknown"
    end


    mess = {:iwag_access_interface => access_int,
            :subscribers_mac => subs_mac,
            :access_point => access_poi,
            :ssid_ap => ssid_a,
            :apid => "unknown",
            :statistics =>
                {:tx_rate_set => tx_rate_se,
                 :tx_rate => tx_rat,
                 :rx_rate => rx_rat,
                 :rx_signal => rx_signa,
                 :uptime => uptim,
                 :packets => packet,
                 :bytes => byt}
    }
    #         logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
    output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
  rescue

    puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
    output_params = {:code => 505, :result => "ERROR. Something wrong."}
  end
  output_params
end

#proc_100_71_0_0_ssh(ip_address) ⇒ Object



727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 727

def proc_100_71_0_0_ssh(ip_address)
  begin
    p access_int = iwag_telnet_connector.return_iwag_access_interface_1(ip_address)

    ip_a = ip_address

    access_poi = "unknown"
    ssid_a = "unknown"
    tx_rate_se = "unknown"
    tx_rat = "unknown"
    rx_rat = "unknown"
    rx_signa = "unknown"
    uptim = "unknown"
    packet = "unknown"
    byt = "unknown"

    if access_int == "Tunnel5"
      mikr_info2 = self.get_subs_add_info3_1(ip_address, access_int)
      splitting2 = mikr_info2.split("---")
      subs_mac = splitting2[0]
      access_poi = "belrw_3_Cisco_ap1-1"
      ssid_a = "BelRW_WiFi"
      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"
    elsif access_int == "GigabitEthernet2.4008"
      mikr_info3 = self.get_subs_add_info3_1(ip_address, access_int)
      splitting3 = mikr_info3.split("---")
      subs_mac = splitting3[0]
      access_poi = "belrw_4_HP_ap1-1"
      ssid_a = "BelRW_WiFi"
      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"
    elsif access_int == "Tunnel9"
      subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
      p resp1 = hua_controller_connector.get_sub_info_1(subs_mac)
      p resp=resp1.split(",,,")

      p access_poi = resp[1]
      p ssid_a = resp[2]
      p tx_rate_se = resp[3]
      p tx_rat = resp[4]
      p rx_rat = resp[5]
      p rx_signa = resp[6]
      p uptim = resp[7]
      p packet = resp[8]
      p byt = resp[9]
    elsif access_int == "Tunnel16"
      subs_mac = iwag_telnet_connector.get_subs_mac2_1(ip_address)
      p resp1 = hua_controller_connector.get_sub_info2_1(subs_mac)
      p resp=resp1.split(",,,")

      p access_poi = resp[1]
      p ssid_a = resp[2]
      p tx_rate_se = resp[3]
      p tx_rat = resp[4]
      p rx_rat = resp[5]
      p rx_signa = resp[6]
      p uptim = resp[7]
      p packet = resp[8]
      p byt = resp[9]
    else
      p "before get info"
      p mikr_info5 = self.get_subs_add_info3_1(ip_address, access_int)
      p "after get info"
      splitting5 = mikr_info5.split("---")
      p subs_mac = splitting5[0]

      p access_poi = splitting5[1]
      p ssid_a = splitting5[2]
      p tx_rate_se = splitting5[3]
      p tx_rat = splitting5[4]
      p rx_rat = splitting5[5]
      p rx_signa = splitting5[6]
      p uptim = splitting5[7]
      p packet = splitting5[8]
      p byt = splitting5[9]


      if access_poi==nil || access_poi=="" || access_poi=="unknown"
        access_poi = "not on mikrotik controller"
      end

      if ssid_a==nil || ssid_a=="" || ssid_a=="unknown"
        ssid_a = "unknown"
        tx_rate_se = "unknown"
        tx_rat = "unknown"
        rx_rat = "unknown"
        rx_signa = "unknown"
        uptim = "unknown"
        packet = "unknown"
        byt = "unknown"
      end

    end

    if subs_mac=="unknown"
      output_params = {:code => 505, :result => "ERROR. Something wrong."}
    end

    if subs_mac==""
      subs_mac="unknown"
    end


    mess = {:iwag_access_interface => access_int,
            :subscribers_mac => subs_mac,
            :access_point => access_poi,
            :ssid_ap => ssid_a,
            :apid => "unknown",
            :statistics =>
                {:tx_rate_set => tx_rate_se,
                 :tx_rate => tx_rat,
                 :rx_rate => rx_rat,
                 :rx_signal => rx_signa,
                 :uptime => uptim,
                 :packets => packet,
                 :bytes => byt}
    }
    #         logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
    output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
  rescue

    puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
    output_params = {:code => 505, :result => "ERROR. Something wrong."}
  end
  output_params
end

#proc_100_75_0_0(ip_address) ⇒ Object



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 451

def proc_100_75_0_0(ip_address)

  begin
    result_iwag = self.python_mac_iwag2_1(ip_address)
    if result_iwag.split(" ")[0]!="Unknown"
      ppp = result_iwag.split(" ")

      subs_mac = ppp[0]
      access_int = ppp[1]
      access_poi = ppp[2]
      ssid_a = ppp[3]

      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"

      if access_int=='GigabitEthernet4.3002'
        access_poi = "belrw_4_HP_ap1-1"
        ssid_a = "BelRW_WiFi"
      elsif access_int=='GigabitEthernet4.3005'
        access_poi = "belbiz-AP1-1"
        ssid_a = "IMAGURU_GUEST"
      end

      if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
        frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
        splitting5 = frommikrotik.split("---")
        p access_poi = splitting5[1]
        p ssid_a = splitting5[2]
        p tx_rate_se = splitting5[3]
        p tx_rat = splitting5[4]
        p rx_rat = splitting5[5]
        p rx_signa = splitting5[6]
        p uptim = splitting5[7]
        p packet = splitting5[8]
        p byt = splitting5[9]
      end

      if subs_mac=="unknown"
        output_params = {:code => 505, :result => "ERROR. Something wrong."}
      end

      if subs_mac==""
        subs_mac="unknown"
      end


      mess = {:iwag_access_interface => access_int,
              :subscribers_mac => subs_mac,
              :access_point => access_poi,
              :ssid_ap => ssid_a,
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => tx_rate_se,
                   :tx_rate => tx_rat,
                   :rx_rate => rx_rat,
                   :rx_signal => rx_signa,
                   :uptime => uptim,
                   :packets => packet,
                   :bytes => byt}
      }
#            logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
      output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
      p output_params

    else

      mess = {:iwag_access_interface => "unknown",
              :subscribers_mac => "unknown",
              :access_point => "unknown",
              :ssid_ap => "unknown",
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => "unknown",
                   :tx_rate => "unknown",
                   :rx_rate => "unknown",
                   :rx_signal => "unknown",
                   :uptime => "unknown",
                   :packets => "unknown",
                   :bytes => "unknown"}
      }
#            logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{params[:ipaddress]} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
      output_params = {:code => 202, :result => "Request completed", :body => {:message => mess}}
      p output_params

    end
  rescue
    puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
    output_params = {:code => 505, :result => "ERROR. Something wrong."}
  end

  output_params

  ####
end

#proc_100_75_0_0_ssh(ip_address) ⇒ Object



865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 865

def proc_100_75_0_0_ssh(ip_address)

  begin
    result_iwag = self.ssh_mac_iwag2_1(ip_address)
    if result_iwag.split(" ")[0]!="Unknown"
      ppp = result_iwag.split(" ")

      subs_mac = ppp[0]
      access_int = ppp[1]
      access_poi = ppp[2]
      ssid_a = ppp[3]

      tx_rate_se = "unknown"
      tx_rat = "unknown"
      rx_rat = "unknown"
      rx_signa = "unknown"
      uptim = "unknown"
      packet = "unknown"
      byt = "unknown"

      if access_int=='GigabitEthernet4.3002'
        access_poi = "belrw_4_HP_ap1-1"
        ssid_a = "BelRW_WiFi"
      elsif access_int=='GigabitEthernet4.3005'
        access_poi = "belbiz-AP1-1"
        ssid_a = "IMAGURU_GUEST"
      end

      if access_poi == "Unknown" && ssid_a == "Unknown" && subs_mac != "Unknown"
        frommikrotik = self.get_subs_add_info4new_1(access_int, subs_mac)
        splitting5 = frommikrotik.split("---")
        p access_poi = splitting5[1]
        p ssid_a = splitting5[2]
        p tx_rate_se = splitting5[3]
        p tx_rat = splitting5[4]
        p rx_rat = splitting5[5]
        p rx_signa = splitting5[6]
        p uptim = splitting5[7]
        p packet = splitting5[8]
        p byt = splitting5[9]
      end

      if subs_mac=="unknown"
        output_params = {:code => 505, :result => "ERROR. Something wrong."}
      end

      if subs_mac==""
        subs_mac="unknown"
      end


      mess = {:iwag_access_interface => access_int,
              :subscribers_mac => subs_mac,
              :access_point => access_poi,
              :ssid_ap => ssid_a,
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => tx_rate_se,
                   :tx_rate => tx_rat,
                   :rx_rate => rx_rat,
                   :rx_signal => rx_signa,
                   :uptime => uptim,
                   :packets => packet,
                   :bytes => byt}
      }
#            logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{ip_address} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
      output_params = {:code => 200, :result => "Request completed", :body => {:message => mess}}
      p output_params

    else

      mess = {:iwag_access_interface => "unknown",
              :subscribers_mac => "unknown",
              :access_point => "unknown",
              :ssid_ap => "unknown",
              :apid => "unknown",
              :statistics =>
                  {:tx_rate_set => "unknown",
                   :tx_rate => "unknown",
                   :rx_rate => "unknown",
                   :rx_signal => "unknown",
                   :uptime => "unknown",
                   :packets => "unknown",
                   :bytes => "unknown"}
      }
#            logger.info "HAproxy #{request.remote_ip}, request device real ip: #{request.headers['X-Client']}, ipaddressinputparameter: #{params[:ipaddress]} recieved from mts_wifi_get_subs_info_return procedure of wifi_portal_controller  such information as: #{mess.to_xml}"
      output_params = {:code => 202, :result => "Request completed", :body => {:message => mess}}
      p output_params

    end
  rescue
    puts 'SOAP mts_wifi_get_subs_info_return errorMethod'
    output_params = {:code => 505, :result => "ERROR. Something wrong."}
  end

  output_params

  ####
end

#python_mac_iwag1_1(ipaddress) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 78

def python_mac_iwag1_1(ipaddress)
  begin
    response = ard_api_gw_connector_wifi.call(:mts_python_mac_iwag1) do
      message({:ipaddress => ipaddress})
    end
    answer = response.to_hash
    return answer[:mts_python_mac_iwag1_response][:data].gsub("\n", "")
  rescue
    return "Unknown  Unknown  Unknown  Unknown"
  end
end

#python_mac_iwag2_1(ipaddress) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 100

def python_mac_iwag2_1(ipaddress)
  begin
    response = ard_api_gw_connector_wifi.call(:mts_python_mac_iwag2) do
      message({:ipaddress => ipaddress})
    end
    answer = response.to_hash
    return answer[:mts_python_mac_iwag2_response][:data].gsub("\n", "")
  rescue
    return "Unknown  Unknown  Unknown  Unknown"
  end
end

#ssh_mac_iwag1_1(ipaddress) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 91

def ssh_mac_iwag1_1(ipaddress)
  begin
    data_iw1 = iwag_connector1.iwag_get_dhcp_binding_ssh(ipaddress)
    "#{data_iw1[:mac]}  #{data_iw1[:iwaginterface]}  #{data_iw1[:aphostname]}  #{data_iw1[:SSID]}"
  rescue
    return "Unknown  Unknown  Unknown  Unknown"
  end
end

#ssh_mac_iwag2_1(ipaddress) ⇒ Object



112
113
114
115
116
117
118
119
# File 'lib/freewifi/general/wifi_portal_procedures.rb', line 112

def ssh_mac_iwag2_1(ipaddress)
  begin
    data_iw1 = iwag_connector2.iwag_get_dhcp_binding_ssh(ipaddress)
    "#{data_iw1[:mac]}  #{data_iw1[:iwaginterface]}  #{data_iw1[:aphostname]}  #{data_iw1[:SSID]}"
  rescue
    return "Unknown  Unknown  Unknown  Unknown"
  end
end