apiotics 0.1.106 → 0.1.107

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ae938082fb0065695bbf435576a499d1494dee8
4
- data.tar.gz: 04de7d37aa5eea4cc7683954374e2b5ff5e55ccc
3
+ metadata.gz: 606275f78d00c05a5b3e8bfb9c34fa9d81b398d2
4
+ data.tar.gz: c4b3f245703a2302c564e5b933688b8ab0dd90f6
5
5
  SHA512:
6
- metadata.gz: 440ec47c651b6f04257fca8dd1ed99e57e917122f4d14c762d9fabaf02789d3d043a4c3f234848a6df146777d94f07d3e811624793a600b04e4bea98f04ffb02
7
- data.tar.gz: 86780ef017196c4b1ccdba57f3060c67024d2bf413dfd6434574c02bf5494a19d70591d4a5b6b4de0cf9ec5b1b2bd476101d932ae03bdf9bd6333dc1ea73310c
6
+ metadata.gz: 6fcc519a262b242561bb0c6e3359e498d633e604f1115bbe48cca49949b6361eac1dad8b569201cb0a7813c1ea852d51d910dd5394d14809ffbe8c4b7bce4e04
7
+ data.tar.gz: 2ceff891f833d0adf9742b0ac6446033acc8091b1ec1884d4845c49185b3fc635dc145a5c34d8b9b0058b88062482566742a6963c0b03f4fc06e6679aacee8ed
@@ -10,85 +10,82 @@ require "redis"
10
10
  module Apiotics
11
11
  class Server
12
12
  def initialize
13
- Thread.abort_on_exception = true
14
- hive_public_key = ApioticsSetting.find_by(key: "hive_public_key")
15
- if hive_public_key == nil || hive_public_key.value != Apiotics.configuration.public_key
16
- Server.clear_db_settings
17
- end
18
- @error_msg = nil
19
- server_details = Server.lookup
20
- rgs = ApioticsSetting.find_by(key: "server")
21
- rgs_port = ApioticsSetting.find_by(key: "port")
22
- if rgs == nil
23
- if server_details["status"] == "ok"
24
- rgs = server_details["ip"]
25
- c = ApioticsSetting.new
26
- c.key = "server"
27
- c.value = rgs
28
- c.save
29
- rgs_port = server_details["port"]
30
- c = ApioticsSetting.new
31
- c.key = "port"
32
- c.value = rgs_port
33
- c.save
34
- else
35
- @error_msg = server_details["status_msg"]
13
+ begin
14
+ Thread.abort_on_exception = true
15
+ hive_public_key = ApioticsSetting.find_by(key: "hive_public_key")
16
+ if hive_public_key == nil || hive_public_key.value != Apiotics.configuration.public_key
17
+ Server.clear_db_settings
36
18
  end
37
- else
38
- if server_details["status"] == "ok"
39
- rgs.value = server_details["ip"]
40
- rgs.save
41
- rgs = rgs.value
42
- rgs_port.value = server_details["port"]
43
- rgs_port.save
44
- rgs_port = rgs_port.value
19
+ @error_msg = nil
20
+ server_details = Server.lookup
21
+ rgs = ApioticsSetting.find_by(key: "server")
22
+ rgs_port = ApioticsSetting.find_by(key: "port")
23
+ if rgs == nil
24
+ if server_details["status"] == "ok"
25
+ rgs = server_details["ip"]
26
+ c = ApioticsSetting.new
27
+ c.key = "server"
28
+ c.value = rgs
29
+ c.save
30
+ rgs_port = server_details["port"]
31
+ c = ApioticsSetting.new
32
+ c.key = "port"
33
+ c.value = rgs_port
34
+ c.save
35
+ else
36
+ @error_msg = server_details["status_msg"]
37
+ end
45
38
  else
46
- @error_msg = server_details["status_msg"]
47
- end
48
- end
49
- if Apiotics.configuration.tls == true
50
- socket = TCPSocket.new(rgs, rgs_port)
51
- context = OpenSSL::SSL::SSLContext.new
52
- context.key = Server.key
53
- context.cert = Server.cert
54
- if Apiotics.configuration.verify_peer == true
55
- ca_tempfile = Tempfile.new
56
- ca_tempfile.write Server.ca_cert.to_pem
57
- ca_tempfile.rewind
58
- context.ca_file = ca_tempfile.path
59
- context.verify_mode = OpenSSL::SSL::VERIFY_PEER
39
+ if server_details["status"] == "ok"
40
+ rgs.value = server_details["ip"]
41
+ rgs.save
42
+ rgs = rgs.value
43
+ rgs_port.value = server_details["port"]
44
+ rgs_port.save
45
+ rgs_port = rgs_port.value
46
+ else
47
+ @error_msg = server_details["status_msg"]
48
+ end
60
49
  end
61
- server = OpenSSL::SSL::SSLSocket.new socket, context
62
- server.sync_close = true
63
- begin
50
+ if Apiotics.configuration.tls == true
51
+ socket = TCPSocket.new(rgs, rgs_port)
52
+ context = OpenSSL::SSL::SSLContext.new
53
+ context.key = Server.key
54
+ context.cert = Server.cert
55
+ if Apiotics.configuration.verify_peer == true
56
+ ca_tempfile = Tempfile.new
57
+ ca_tempfile.write Server.ca_cert.to_pem
58
+ ca_tempfile.rewind
59
+ context.ca_file = ca_tempfile.path
60
+ context.verify_mode = OpenSSL::SSL::VERIFY_PEER
61
+ end
62
+ server = OpenSSL::SSL::SSLSocket.new socket, context
63
+ server.sync_close = true
64
64
  server.connect
65
- rescue => e
66
- server.close
67
- raise e
68
- end
69
- if Apiotics.configuration.verify_peer == true
70
- ca_tempfile.close(true)
71
- end
72
- else
73
- begin
65
+ if Apiotics.configuration.verify_peer == true
66
+ ca_tempfile.close(true)
67
+ end
68
+ else
74
69
  server = TCPSocket.open(rgs, rgs_port)
75
- rescue => e
70
+ end
71
+ @server = server
72
+ @localport = Apiotics.configuration.local_port
73
+ listen_remote
74
+ @heartbeat_state = Hash.new
75
+ heartbeat = {
76
+ "action" => "set-request",
77
+ "instance" => "0000000000000000000000000000000000000000000000000000000000000000",
78
+ "driver" => "Core::Heartbeat",
79
+ "interface" => nil
80
+ }
81
+ send_heartbeat(heartbeat)
82
+ listen_local
83
+ rescue => e
84
+ if server != nil
76
85
  server.close
77
- raise e
78
86
  end
87
+ raise e
79
88
  end
80
- @server = server
81
- @localport = Apiotics.configuration.local_port
82
- listen_remote
83
- @heartbeat_state = Hash.new
84
- heartbeat = {
85
- "action" => "set-request",
86
- "instance" => "0000000000000000000000000000000000000000000000000000000000000000",
87
- "driver" => "Core::Heartbeat",
88
- "interface" => nil
89
- }
90
- send_heartbeat(heartbeat)
91
- listen_local
92
89
  end
93
90
 
94
91
  def send(msg)
@@ -1,3 +1,3 @@
1
1
  module Apiotics
2
- VERSION = '0.1.106'
2
+ VERSION = '0.1.107'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apiotics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.106
4
+ version: 0.1.107
5
5
  platform: ruby
6
6
  authors:
7
7
  - MicroArx Corporation