meshtastic 0.0.20 → 0.0.22

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
  SHA256:
3
- metadata.gz: 118b74d5c53f38d6fcf05335c4fb5fb70a0caa6d8b46938a3d74769553a0bae8
4
- data.tar.gz: 155ea6cecde9a3d2adade6cbe033598c074cfe45c71ad11122fde2e3427602ea
3
+ metadata.gz: bbd76d5eb5caa289b389949f752dcdcbe9185dd55db794ceeaa7aeff86342eb9
4
+ data.tar.gz: 9a941303697050de11c04c2fbcc64ef6cffebd16b1959a3b1e5359b904c7628d
5
5
  SHA512:
6
- metadata.gz: 57cdde07d35c227e8135df98e225d62d0bf1c789db487356ea17d262a2d658d2f4139d92edfce9f1b8d66c3d048712c78be0d9ef29bf09ade051237d294c861c
7
- data.tar.gz: 031e774028e1823a2624f7827565edeb93f2e36bfc58e005c3d8ebb8c6d9df869d609f2cd9eb9e6b326aeaf70f31d8c3ddc0c71f11949e7c17df19cc19aa5719
6
+ metadata.gz: 3af0be5f4930d87b7a4f536417de6429302bd65da11f19ccf843241de0d32b1c72077ab6a4ce2231f237b75669514ee4a237b618e65534884da6f0db619f5f0a
7
+ data.tar.gz: d560584669d17490e6da18e4169164dce4077f2cbcb8619bca0f5d816b46e4526d2334acaeaeba3cd32b4a5e0494250dbd34fe6994a0baf4e2b066d60289722e
data/Gemfile CHANGED
@@ -11,17 +11,15 @@ gemspec
11
11
  # In some circumstances custom flags are passed to gems in order
12
12
  # to build appropriately. Defer to ./reinstall_pwn_gemset.sh
13
13
  # to review these custom flags (e.g. pg, serialport, etc).
14
- gem 'brakeman', '6.1.2'
15
14
  gem 'bundler', '>=2.5.3'
16
15
  gem 'bundle-audit', '0.1.0'
17
16
  gem 'geocoder', '1.8.2'
18
17
  gem 'google-protobuf', '3.21.12'
19
- # gem 'google-protobuf-z', '3.5.1'
20
18
  gem 'mqtt', '0.6.0'
21
19
  gem 'rake', '13.2.1'
22
20
  gem 'rdoc', '6.6.3.1'
23
21
  gem 'rspec', '3.13.0'
24
- gem 'rubocop', '1.63.3'
22
+ gem 'rubocop', '1.63.4'
25
23
  gem 'rubocop-rake', '0.6.0'
26
24
  gem 'rubocop-rspec', '2.29.1'
27
25
  gem 'rvm', '1.11.3.9'
data/README.md CHANGED
@@ -36,6 +36,15 @@ Meshtastic::MQTT.subscribe(
36
36
  )
37
37
  ```
38
38
 
39
+ This code will print the `from` value of each message received:
40
+ ```ruby
41
+ require 'meshtastic'
42
+ mqtt_obj = Meshastic::MQTT.connect
43
+ Meshtastic::MQTT.subscribe( mqtt_obj: mqtt_obj) do |message|
44
+ puts message[:from]
45
+ end
46
+ ```
47
+
39
48
  ## Contributing
40
49
 
41
50
  Bug reports and pull requests are welcome on GitHub at https://github.com/0dayinc/meshtastic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/0dayinc/meshtastic/blob/master/CODE_OF_CONDUCT.md).
@@ -50,7 +50,7 @@ module Meshtastic
50
50
  # psk: 'optional - channel pre-shared key (default: AQ==)',
51
51
  # qos: 'optional - quality of service (default: 0)',
52
52
  # json: 'optional - JSON output (default: false)',
53
- # filter: 'optional - comma-delimited string(s) to filter on in payload (default: nil)'
53
+ # filter: 'optional - comma-delimited string(s) to filter on in message (default: nil)'
54
54
  # )
55
55
 
56
56
  public_class_method def self.subscribe(opts = {})
@@ -83,27 +83,29 @@ module Meshtastic
83
83
  mqtt_obj.get_packet do |packet_bytes|
84
84
  raw_packet = packet_bytes.to_s.b
85
85
  raw_packet_len = raw_packet.to_s.b.length
86
- raw_topic = packet_bytes.topic
87
- raw_payload = packet_bytes.payload
86
+ raw_topic = packet_bytes.topic ||= ''
87
+ raw_message = packet_bytes.payload
88
88
 
89
89
  begin
90
- payload = {}
90
+ disp = false
91
+ message = {}
92
+
91
93
  if json
92
- payload = JSON.parse(raw_payload, symbolize_names: true)
94
+ message = JSON.parse(raw_message, symbolize_names: true)
93
95
  else
94
- svc_envl = Meshtastic::ServiceEnvelope.decode(raw_payload)
95
- # map_report = Meshtastic::MapReport.decode(raw_payload)
96
- payload = svc_envl.to_h[:packet]
96
+ svc_envl = Meshtastic::ServiceEnvelope.decode(raw_message)
97
+ # map_report = Meshtastic::MapReport.decode(raw_message)
98
+ message = svc_envl.to_h[:packet]
97
99
  end
98
- payload[:topic] = raw_topic
99
- payload[:node_id_from] = "!#{payload[:from].to_i.to_s(16)}"
100
- payload[:node_id_to] = "!#{payload[:to].to_i.to_s(16)}"
101
-
102
- encrypted_payload = payload[:encrypted]
103
- # If encrypted_payload is not nil, then decrypt the message
104
- if encrypted_payload.length.positive?
105
- packet_id = payload[:id]
106
- packet_from = payload[:from]
100
+ message[:topic] = raw_topic
101
+ message[:node_id_from] = "!#{message[:from].to_i.to_s(16)}"
102
+ message[:node_id_to] = "!#{message[:to].to_i.to_s(16)}"
103
+
104
+ encrypted_message = message[:encrypted]
105
+ # If encrypted_message is not nil, then decrypt the message
106
+ if encrypted_message.to_s.length.positive?
107
+ packet_id = message[:id]
108
+ packet_from = message[:from]
107
109
  nonce_packet_id = [packet_id].pack('V').ljust(8, "\x00")
108
110
  nonce_from_node = [packet_from].pack('V').ljust(8, "\x00")
109
111
  nonce = "#{nonce_packet_id}#{nonce_from_node}".b
@@ -115,41 +117,33 @@ module Meshtastic
115
117
  cipher.key = dec_psk
116
118
  cipher.iv = nonce
117
119
 
118
- decrypted = cipher.update(encrypted_payload) + cipher.final
119
- payload[:decrypted] = decrypted
120
+ decrypted = cipher.update(encrypted_message) + cipher.final
121
+ message[:decrypted] = decrypted
120
122
  end
121
123
 
122
- filter_arr = [payload[:id].to_s] if filter.nil?
123
- disp = false
124
- flat_payload = payload.values.join(' ')
124
+ filter_arr = [message[:id].to_s] if filter.nil?
125
+ flat_message = message.values.join(' ')
125
126
 
126
- disp = true if filter_arr.first == payload[:id] ||
127
- filter_arr.all? { |filter| flat_payload.include?(filter) }
127
+ disp = true if filter_arr.first == message[:id] ||
128
+ filter_arr.all? { |filter| flat_message.include?(filter) }
128
129
 
130
+ rescue Google::Protobuf::ParseError
131
+ next
132
+ ensure
129
133
  if disp
130
134
  puts "\n"
131
135
  puts '-' * 80
132
136
  puts "*** DEBUGGING ***"
133
- puts "Payload:\n#{payload}"
137
+ puts "MSG:\n#{message.inspect}"
134
138
  # puts "\nMap Report: #{map_report.inspect}"
135
139
  puts "\nRaw Packet: #{raw_packet.inspect}"
136
140
  puts "Length: #{raw_packet_len}"
137
141
  puts '-' * 80
138
142
  puts "\n\n\n"
143
+ yield message if block_given?
139
144
  else
140
145
  print '.'
141
146
  end
142
- rescue Google::Protobuf::ParseError
143
- puts "\n"
144
- puts '-' * 80
145
- puts "*** DEBUGGING ***"
146
- puts "Payload:\n#{payload}"
147
- # puts "\nMap Report: #{map_report.inspect}"
148
- puts "\nRaw Packet: #{raw_packet.inspect}"
149
- puts "Length: #{raw_packet_len}"
150
- puts '-' * 80
151
- puts "\n\n\n"
152
- next
153
147
  end
154
148
  end
155
149
  rescue Interrupt
@@ -217,7 +211,7 @@ module Meshtastic
217
211
  psk: 'optional - channel pre-shared key (default: AQ==)',
218
212
  qos: 'optional - quality of service (default: 0)',
219
213
  json: 'optional - JSON output (default: false)',
220
- filter: 'optional - comma-delimited string(s) to filter on in payload (default: nil)'
214
+ filter: 'optional - comma-delimited string(s) to filter on in message (default: nil)'
221
215
  )
222
216
 
223
217
  #{self}.gps_search(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meshtastic
4
- VERSION = '0.0.20'
4
+ VERSION = '0.0.22'
5
5
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meshtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - 0day Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-26 00:00:00.000000000 Z
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: brakeman
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 6.1.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 6.1.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +128,14 @@ dependencies:
142
128
  requirements:
143
129
  - - '='
144
130
  - !ruby/object:Gem::Version
145
- version: 1.63.3
131
+ version: 1.63.4
146
132
  type: :runtime
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - '='
151
137
  - !ruby/object:Gem::Version
152
- version: 1.63.3
138
+ version: 1.63.4
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rubocop-rake
155
141
  requirement: !ruby/object:Gem::Requirement