njongto_duo 0.0.50 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/njongto_duo.rb +49 -19
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98362172929d84e95721b15124bc435e8e112520dc2dbebfeb1f255e8d98207c
4
- data.tar.gz: 1b18b9b09d145408624d758b762ab8bf6648a0cbec121c76ddf8ea15b221b6fb
3
+ metadata.gz: 5d081a3f72d3a1b2d1a81c12de754a62d84c94f1dba858291819851dedf12e93
4
+ data.tar.gz: 15f71ea3c2bcc146de7e96e3dc586152990615fde106e2b6cae1d3280bd50860
5
5
  SHA512:
6
- metadata.gz: 3aa4611aebae97f092a9a307a77489e524e5276e6bd6b123c8a891e874e466c908a3e00016697c8b0d3e7fa8ed86fdffa262c4db2a03487ae505f167d89d1343
7
- data.tar.gz: f62e23025cd78c048fea601a1ada411e8463b6b1857f091491f30f0bcb4db687208d46867c9847a7f5802833a088eec517524a41b70c59f4050b309803e53080
6
+ metadata.gz: 3debd7abf452bb0858d29c4b7161188770bf42d626699f62743a311017f4d04e211ab4e45099d45a9b15b81002b49f1f043a6658122ef61085089a9d2643f41e
7
+ data.tar.gz: 1652c207bf27966cc8eebf35459f71bc1023f7c72615495cf6572fd276a5ebfde3fdfab902a8663961ee541e9fdb2915be093b50c27ee4ccb629fc15997db5e8
data/lib/njongto_duo.rb CHANGED
@@ -544,36 +544,66 @@ class Wordpress
544
544
  puts table[7]
545
545
  if table[5].to_i > table[7].to_i #설정을 맞게해줘야 실행이 됨
546
546
  if @data['포스트설정']['테더링'].checked?
547
- puts 'tedering ip change...'
547
+ puts 'Tethering IP change...'
548
+
548
549
  stdout, stderr, status = Open3.capture3('./adb devices')
550
+
549
551
  if status.success?
550
- device_id = stdout.split("\n")[1].split("\t")[0]
551
- puts device_id
552
- puts 'adb -s '+device_id+' shell svc data disable'
553
- stdout2, stderr2, status2 = Open3.capture3('./adb -s '+device_id+' shell svc data disable')
552
+ device_id = stdout.split("\n")[1].split("\t")[0]
553
+ puts device_id
554
+
555
+ # ADB 서버 초기화
556
+ puts 'adb kill-server'
557
+ Open3.capture3('adb kill-server')
558
+ sleep(2)
559
+
560
+ # 다시 ADB 서버 실행
561
+ puts 'adb start-server'
562
+ Open3.capture3('adb start-server')
563
+ sleep(2)
564
+
565
+ # 데이터를 끄고 켜기
566
+ puts 'adb -s ' + device_id + ' shell svc data disable'
567
+ stdout2, stderr2, status2 = Open3.capture3('./adb -s ' + device_id + ' shell svc data disable')
568
+
569
+ if status2.success?
554
570
  sleep(3)
555
- puts 'adb -s '+device_id+' shell svc data enable'
556
- Open3.capture3('./adb -s '+device_id+' shell svc data enable')
571
+ puts 'adb -s ' + device_id + ' shell svc data enable'
572
+ Open3.capture3('./adb -s ' + device_id + ' shell svc data enable')
557
573
  sleep(3)
558
574
  puts 'adb ok'
559
575
  sleep(8)
576
+
577
+ # IP 변경을 확인하는 람다 함수
560
578
  robot_ip = lambda do
561
- http = HTTP.get('https://www.findip.kr/')
562
- noko = Nokogiri::HTML(http.to_s)
563
- if noko.xpath('/html/body/header/h2').text != @my_ip
564
- @my_ip = noko.xpath('/html/body/header/h2').text
565
- else
566
- puts @my_ip
567
- puts'[테더링] 연결 재시도.......'.red
568
- sleep(3)
569
- robot_ip[]
579
+ loop do # 무한 루프
580
+ begin
581
+ http = HTTP.get('https://www.findip.kr/')
582
+ noko = Nokogiri::HTML(http.to_s)
583
+ new_ip = noko.xpath('/html/body/header/h2').text.strip
584
+
585
+ if new_ip != @my_ip
586
+ @my_ip = new_ip
587
+ puts "IP 변경됨: #{@my_ip}"
588
+ break # IP가 변경되었으면 루프 종료
589
+ else
590
+ puts 'IP가 변경되지 않음. 재시도...'
591
+ sleep(3) # 3초 후 재시도
592
+ end
593
+ rescue => e
594
+ puts "IP 확인 중 오류 발생: #{e.message}. 재시도 중..."
595
+ sleep(3) # 3초 후 재시도
570
596
  end
597
+ end
571
598
  end
572
- robot_ip[]
599
+ robot_ip[] # 최초 호출
600
+ else
601
+ puts 'Failed to disable data. Error: ' + stderr2
602
+ end
573
603
  else
574
- puts 'adb error pass'.red
604
+ puts 'adb error, unable to get devices. Error: ' + stderr
575
605
  end
576
- end
606
+ end
577
607
 
578
608
  check_success = 1
579
609
  @data['table'][index][-1] = 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: njongto_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.50
4
+ version: 0.0.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon