pwn 0.5.735 → 0.5.736
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.
- checksums.yaml +4 -4
- data/lib/pwn/plugins/repl/mesh.rb +47 -7
- data/lib/pwn/version.rb +1 -1
- data/spec/lib/pwn/plugins/repl_mesh_layout_spec.rb +29 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f20a2bcbd4611945405ce166826e978eabfe051ee9b1d5bc51ab07f9dde2e5d2
|
|
4
|
+
data.tar.gz: 894c5e39df14c75ce020427d0ea9294550b17dee242c728aaa1067fadfd1d683
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c512159a8249c30b3ae191d3e4d159d8f30da33b48dbc99fdb2d6e753c4811444f5db70492b8ca712a7dd26396818365c0940d225d9c9011247109a7cfd3a47f
|
|
7
|
+
data.tar.gz: 0a9bff32912c36b10baca436caf72a18f132f9f9e4779df8f823b0aa66f785e3c905473762b85953916dbc20b51bfcae1989697ed6a57282f2d9da1d114761de
|
|
@@ -88,9 +88,10 @@ module PWN
|
|
|
88
88
|
PWN.const_set(:MeshColors, [20, 23, 21])
|
|
89
89
|
PWN.const_set(:MeshLastColor, 20)
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
layout = PWN::Plugins::REPL.send(:mesh_layout, lines: Curses.lines, cols: Curses.cols)
|
|
92
|
+
mesh_tx_rows = layout[:tx]
|
|
93
|
+
mesh_header_rows = layout[:header]
|
|
94
|
+
body_height = layout[:body]
|
|
94
95
|
rx_header_win = Curses::Window.new(mesh_header_rows, Curses.cols, 0, 0)
|
|
95
96
|
rx_header_win.scrollok(false)
|
|
96
97
|
rx_header_win.nodelay = true
|
|
@@ -111,14 +112,18 @@ module PWN
|
|
|
111
112
|
frame.addstr(' CONVERSATION ')
|
|
112
113
|
frame.refresh
|
|
113
114
|
PWN.const_set(:MeshRxFrameWin, frame)
|
|
114
|
-
rx_body_win = Curses::Window.new(
|
|
115
|
+
rx_body_win = Curses::Window.new(
|
|
116
|
+
[body_height - 2, 1].max,
|
|
117
|
+
[Curses.cols - 4, 1].max,
|
|
118
|
+
body_start_row + (body_height > 2 ? 1 : 0),
|
|
119
|
+
Curses.cols > 4 ? 2 : 0
|
|
120
|
+
)
|
|
115
121
|
rx_body_win.scrollok(true)
|
|
116
122
|
rx_body_win.nodelay = true
|
|
117
123
|
rx_body_win.refresh
|
|
118
124
|
PWN.const_set(:MeshRxBodyWin, rx_body_win)
|
|
119
125
|
|
|
120
|
-
|
|
121
|
-
tx_win = Curses::Window.new(mesh_tx_rows, Curses.cols, tx_height, 0)
|
|
126
|
+
tx_win = Curses::Window.new(mesh_tx_rows, Curses.cols, layout[:tx_top], 0)
|
|
122
127
|
tx_win.scrollok(false)
|
|
123
128
|
tx_win.nodelay = true
|
|
124
129
|
PWN::Plugins::REPL.send(:mesh_box!, win: tx_win)
|
|
@@ -165,6 +170,41 @@ module PWN
|
|
|
165
170
|
t == :auto ? PWN_MESH_TRANSPORTS.first : t
|
|
166
171
|
end
|
|
167
172
|
|
|
173
|
+
# Row counts for header, CONVERSATION, and COMPOSE so the TUI fits the terminal.
|
|
174
|
+
def mesh_layout(opts = {})
|
|
175
|
+
lines = opts[:lines]
|
|
176
|
+
cols = opts[:cols]
|
|
177
|
+
lines = lines.nil? ? Curses.lines : Integer(lines)
|
|
178
|
+
cols = cols.nil? ? Curses.cols : Integer(cols)
|
|
179
|
+
lines = 1 if lines < 1
|
|
180
|
+
cols = 1 if cols < 1
|
|
181
|
+
header = 5
|
|
182
|
+
tx = 5
|
|
183
|
+
min_header = 3
|
|
184
|
+
min_tx = 3
|
|
185
|
+
min_body = 3
|
|
186
|
+
body = lines - header - tx
|
|
187
|
+
while body < min_body && header > min_header
|
|
188
|
+
header -= 1
|
|
189
|
+
body = lines - header - tx
|
|
190
|
+
end
|
|
191
|
+
while body < min_body && tx > min_tx
|
|
192
|
+
tx -= 1
|
|
193
|
+
body = lines - header - tx
|
|
194
|
+
end
|
|
195
|
+
body = [body, 1].max
|
|
196
|
+
overflow = header + body + tx - lines
|
|
197
|
+
body -= overflow if overflow.positive? && body > 1
|
|
198
|
+
body = 1 if body < 1
|
|
199
|
+
{
|
|
200
|
+
header: header,
|
|
201
|
+
body: body,
|
|
202
|
+
tx: tx,
|
|
203
|
+
cols: cols,
|
|
204
|
+
tx_top: header + body
|
|
205
|
+
}
|
|
206
|
+
end
|
|
207
|
+
|
|
168
208
|
# Explicit Unicode avoids ACS falling back to ASCII on some terminals.
|
|
169
209
|
def mesh_box!(opts = {})
|
|
170
210
|
win = opts[:win]
|
|
@@ -1808,7 +1848,7 @@ module PWN
|
|
|
1808
1848
|
false
|
|
1809
1849
|
end
|
|
1810
1850
|
|
|
1811
|
-
private :mesh_transport, :mesh_bound_transport, :mesh_box!, :mesh_mqtt_region, :mesh_mqtt_topic, :mesh_active_psks, :mesh_device_channel_meta, :mesh_device_channels
|
|
1851
|
+
private :mesh_transport, :mesh_bound_transport, :mesh_layout, :mesh_box!, :mesh_mqtt_region, :mesh_mqtt_topic, :mesh_active_psks, :mesh_device_channel_meta, :mesh_device_channels
|
|
1812
1852
|
private :mesh_radio_channel, :mesh_radio_index_for_name, :mesh_channel_name_for_index, :mesh_unassigned_slot_map, :mesh_psk_b64, :mesh_psk_same?, :mesh_env_channel_name_for_psk, :mesh_whitelist_name_for_index, :mesh_channel_name_from_topic, :mesh_link_label
|
|
1813
1853
|
private :mesh_connect_one, :mesh_connect, :mesh_mqtt_tls?, :mesh_subscribe, :mesh_text_payload_max, :mesh_payload_fits?, :mesh_text_chunks, :mesh_tx_row_ready?, :mesh_wait_tx_slot, :mesh_send_text, :mesh_disconnect, :mesh_compose_send, :mesh_channel_names, :mesh_env_hash
|
|
1814
1854
|
private :mesh_submit, :mesh_console_loop, :mesh_drain_events, :mesh_draw_input, :mesh_wrap_text, :mesh_ui_puts, :mesh_menu_root, :mesh_list_devices
|
data/lib/pwn/version.rb
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe PWN::Plugins::REPL, 'mesh terminal layout' do
|
|
6
|
+
it 'keeps a 5-row header and 5-row compose on a 24-line terminal' do
|
|
7
|
+
layout = described_class.send(:mesh_layout, lines: 24, cols: 80)
|
|
8
|
+
expect(layout[:header]).to eq(5)
|
|
9
|
+
expect(layout[:tx]).to eq(5)
|
|
10
|
+
expect(layout[:body]).to eq(14)
|
|
11
|
+
expect(layout[:tx_top]).to eq(19)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'shrinks conversation so header, conversation and compose fit a 12-line terminal' do
|
|
15
|
+
layout = described_class.send(:mesh_layout, lines: 12, cols: 40)
|
|
16
|
+
expect(layout[:header] + layout[:body] + layout[:tx]).to eq(12)
|
|
17
|
+
expect(layout[:tx_top] + layout[:tx]).to eq(12)
|
|
18
|
+
expect(layout[:header]).to be >= 3
|
|
19
|
+
expect(layout[:tx]).to be >= 3
|
|
20
|
+
expect(layout[:body]).to be >= 3
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'keeps compose on-screen on a 10-line terminal by shrinking conversation first' do
|
|
24
|
+
layout = described_class.send(:mesh_layout, lines: 10, cols: 40)
|
|
25
|
+
expect(layout[:header] + layout[:body] + layout[:tx]).to eq(10)
|
|
26
|
+
expect(layout[:tx_top]).to be < 10
|
|
27
|
+
expect(layout[:tx_top] + layout[:tx]).to eq(10)
|
|
28
|
+
end
|
|
29
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pwn
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.736
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 0day Inc.
|
|
@@ -6915,6 +6915,7 @@ files:
|
|
|
6915
6915
|
- spec/lib/pwn/plugins/repl_mesh_console_spec.rb
|
|
6916
6916
|
- spec/lib/pwn/plugins/repl_mesh_dispatch_spec.rb
|
|
6917
6917
|
- spec/lib/pwn/plugins/repl_mesh_dm_spec.rb
|
|
6918
|
+
- spec/lib/pwn/plugins/repl_mesh_layout_spec.rb
|
|
6918
6919
|
- spec/lib/pwn/plugins/repl_mesh_rx_paint_spec.rb
|
|
6919
6920
|
- spec/lib/pwn/plugins/repl_pwn_vault_spec.rb
|
|
6920
6921
|
- spec/lib/pwn/plugins/repl_spec.rb
|