omq-cli 0.1.0 → 0.2.0
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/CHANGELOG.md +25 -0
- data/README.md +14 -0
- data/lib/omq/cli/base_runner.rb +1 -22
- data/lib/omq/cli/version.rb +1 -1
- data/lib/omq/cli.rb +88 -2
- 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: 7b1d3b2b127f70f0c59d6e008de4b4f94a0886012819953a3028ca346ecc1feb
|
|
4
|
+
data.tar.gz: a1e912d9aec54b22e4467cb7b2e24c3765333feb5b5fd83cbfc2fa27e0b6a3b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e773ac7df2e7aab7212491ded8c85fe7b6591ec5c4f3553efcac5f23786f54db9fc20b25af5df835e4b0ae17e1117ad63178e3429e616fc18bf00a43f2ca8eee
|
|
7
|
+
data.tar.gz: 6ef6c64204c54e18f8f3fced595ac4b0b3f36299f528cca981dc34876fa654a73c744be1324318a5fd0f2308f002d594779654facc143f5c19096d18534a39cf
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 — 2026-03-31
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`omq keygen`** — generates a persistent CURVE keypair (Z85-encoded
|
|
8
|
+
env vars). Supports `--curve-crypto rbnacl|nuckle` and the
|
|
9
|
+
`OMQ_CURVE_CRYPTO` env var.
|
|
10
|
+
- **`--curve-crypto BACKEND`** — explicit crypto backend selection for
|
|
11
|
+
CURVE encryption. Defaults to rbnacl if installed; no silent fallback
|
|
12
|
+
to nuckle.
|
|
13
|
+
- **`-v` logs crypto backend** — `omq keygen -v` and socket commands
|
|
14
|
+
with `-v` log which CURVE backend was loaded.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **CURVE uses protocol-zmtp** — replaces the old omq-curve gem with
|
|
19
|
+
`Protocol::ZMTP::Mechanism::Curve` and a pluggable `crypto:` backend.
|
|
20
|
+
- **`load_curve_crypto` is a CLI module method** — shared between
|
|
21
|
+
`omq keygen` and socket runners.
|
|
22
|
+
|
|
23
|
+
## 0.1.0 — 2026-03-31
|
|
24
|
+
|
|
25
|
+
Initial release — CLI extracted from the omq gem (v0.8.0).
|
data/README.md
CHANGED
|
@@ -338,6 +338,20 @@ omq push -c tcp://remote:5557 -z < data.txt
|
|
|
338
338
|
omq pull -b tcp://:5557 -z
|
|
339
339
|
```
|
|
340
340
|
|
|
341
|
+
## Key generation
|
|
342
|
+
|
|
343
|
+
Generate a persistent CURVE keypair:
|
|
344
|
+
|
|
345
|
+
```sh
|
|
346
|
+
omq keygen
|
|
347
|
+
# OMQ_SERVER_PUBLIC='...'
|
|
348
|
+
# OMQ_SERVER_SECRET='...'
|
|
349
|
+
|
|
350
|
+
omq keygen --curve-crypto nuckle # pure Ruby backend
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Export the vars, then use `--curve-server` (server) or `--curve-server-key` (client).
|
|
354
|
+
|
|
341
355
|
## CURVE encryption
|
|
342
356
|
|
|
343
357
|
End-to-end encryption using CurveZMQ. Requires a crypto backend:
|
data/lib/omq/cli/base_runner.rb
CHANGED
|
@@ -157,7 +157,7 @@ module OMQ
|
|
|
157
157
|
|
|
158
158
|
return unless server_key_z85 || server_mode
|
|
159
159
|
|
|
160
|
-
crypto = load_curve_crypto(config.curve_crypto || ENV["OMQ_CURVE_CRYPTO"])
|
|
160
|
+
crypto = CLI.load_curve_crypto(config.curve_crypto || ENV["OMQ_CURVE_CRYPTO"], verbose: config.verbose)
|
|
161
161
|
require "protocol/zmtp/mechanism/curve"
|
|
162
162
|
|
|
163
163
|
if server_key_z85
|
|
@@ -184,27 +184,6 @@ module OMQ
|
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
|
|
187
|
-
def load_curve_crypto(name)
|
|
188
|
-
case name&.downcase
|
|
189
|
-
when "rbnacl" then require "rbnacl"; RbNaCl
|
|
190
|
-
when "nuckle" then require "nuckle"; Nuckle
|
|
191
|
-
when nil
|
|
192
|
-
begin
|
|
193
|
-
require "rbnacl"; RbNaCl
|
|
194
|
-
rescue LoadError
|
|
195
|
-
abort "CURVE requires a crypto backend. Install rbnacl (recommended):\n" \
|
|
196
|
-
" gem install rbnacl # requires system libsodium\n" \
|
|
197
|
-
"Or use pure Ruby (not audited):\n" \
|
|
198
|
-
" --curve-crypto nuckle\n" \
|
|
199
|
-
" # or: OMQ_CURVE_CRYPTO=nuckle"
|
|
200
|
-
end
|
|
201
|
-
else
|
|
202
|
-
abort "Unknown CURVE crypto backend: #{name}. Use 'rbnacl' or 'nuckle'."
|
|
203
|
-
end
|
|
204
|
-
rescue LoadError
|
|
205
|
-
abort "Could not load #{name} gem: gem install #{name}"
|
|
206
|
-
end
|
|
207
|
-
|
|
208
187
|
# ── Shared loop bodies ──────────────────────────────────────────
|
|
209
188
|
|
|
210
189
|
|
data/lib/omq/cli/version.rb
CHANGED
data/lib/omq/cli.rb
CHANGED
|
@@ -267,10 +267,88 @@ module OMQ
|
|
|
267
267
|
end
|
|
268
268
|
|
|
269
269
|
|
|
270
|
+
def run(argv = ARGV)
|
|
271
|
+
case argv.first
|
|
272
|
+
when "keygen"
|
|
273
|
+
argv.shift
|
|
274
|
+
run_keygen(argv)
|
|
275
|
+
else
|
|
276
|
+
run_socket(argv)
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
# Generates a persistent CURVE keypair and prints it as
|
|
282
|
+
# Z85-encoded env vars.
|
|
283
|
+
#
|
|
284
|
+
def run_keygen(argv)
|
|
285
|
+
crypto_name = nil
|
|
286
|
+
verbose = false
|
|
287
|
+
while (arg = argv.shift)
|
|
288
|
+
case arg
|
|
289
|
+
when "--curve-crypto"
|
|
290
|
+
crypto_name = argv.shift
|
|
291
|
+
when "-v", "--verbose"
|
|
292
|
+
verbose = true
|
|
293
|
+
when "-h", "--help"
|
|
294
|
+
puts "Usage: omq keygen [--curve-crypto rbnacl|nuckle] [-v]\n\n" \
|
|
295
|
+
"Generates a CURVE keypair for persistent server identity.\n" \
|
|
296
|
+
"Output: Z85-encoded env vars for use with --curve-server."
|
|
297
|
+
exit
|
|
298
|
+
else
|
|
299
|
+
abort "omq keygen: unknown option: #{arg}"
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
crypto_name ||= ENV["OMQ_CURVE_CRYPTO"]
|
|
303
|
+
|
|
304
|
+
crypto = load_curve_crypto(crypto_name, verbose: verbose)
|
|
305
|
+
require "protocol/zmtp/mechanism/curve"
|
|
306
|
+
require "protocol/zmtp/z85"
|
|
307
|
+
|
|
308
|
+
key = crypto::PrivateKey.generate
|
|
309
|
+
puts "OMQ_SERVER_PUBLIC='#{Protocol::ZMTP::Z85.encode(key.public_key.to_s)}'"
|
|
310
|
+
puts "OMQ_SERVER_SECRET='#{Protocol::ZMTP::Z85.encode(key.to_s)}'"
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
# Loads the named NaCl-compatible crypto backend.
|
|
315
|
+
#
|
|
316
|
+
# @param name [String, nil] "rbnacl", "nuckle", or nil (auto-detect rbnacl)
|
|
317
|
+
# @param verbose [Boolean] log which backend was loaded to stderr
|
|
318
|
+
# @return [Module] RbNaCl or Nuckle
|
|
319
|
+
#
|
|
320
|
+
def load_curve_crypto(name, verbose: false)
|
|
321
|
+
crypto = case name&.downcase
|
|
322
|
+
when "rbnacl"
|
|
323
|
+
require "rbnacl"
|
|
324
|
+
RbNaCl
|
|
325
|
+
when "nuckle"
|
|
326
|
+
require "nuckle"
|
|
327
|
+
Nuckle
|
|
328
|
+
when nil
|
|
329
|
+
begin
|
|
330
|
+
require "rbnacl"; RbNaCl
|
|
331
|
+
rescue LoadError
|
|
332
|
+
abort "CURVE requires a crypto backend. Install rbnacl (recommended):\n" \
|
|
333
|
+
" gem install rbnacl # requires system libsodium\n" \
|
|
334
|
+
"Or use pure Ruby (not audited):\n" \
|
|
335
|
+
" --curve-crypto nuckle\n" \
|
|
336
|
+
" # or: OMQ_CURVE_CRYPTO=nuckle"
|
|
337
|
+
end
|
|
338
|
+
else
|
|
339
|
+
abort "Unknown CURVE crypto backend: #{name}. Use 'rbnacl' or 'nuckle'."
|
|
340
|
+
end
|
|
341
|
+
$stderr.puts "omq: CURVE crypto backend: #{crypto.name}" if verbose
|
|
342
|
+
crypto
|
|
343
|
+
rescue LoadError
|
|
344
|
+
abort "Could not load #{name} gem: gem install #{name}"
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
|
|
270
348
|
# Parses CLI arguments, validates options, and runs the main
|
|
271
349
|
# event loop inside an Async reactor.
|
|
272
350
|
#
|
|
273
|
-
def
|
|
351
|
+
def run_socket(argv)
|
|
274
352
|
config = build_config(argv)
|
|
275
353
|
|
|
276
354
|
require "omq"
|
|
@@ -454,7 +532,15 @@ module OMQ
|
|
|
454
532
|
o.on("-v", "--verbose", "Print connection events to stderr") { opts[:verbose] = true }
|
|
455
533
|
o.on("-q", "--quiet", "Suppress message output") { opts[:quiet] = true }
|
|
456
534
|
o.on( "--transient", "Exit when all peers disconnect") { opts[:transient] = true }
|
|
457
|
-
o.on("-V", "--version")
|
|
535
|
+
o.on("-V", "--version") {
|
|
536
|
+
if ENV["OMQ_DEV"]
|
|
537
|
+
require_relative "../../../omq/lib/omq/version"
|
|
538
|
+
else
|
|
539
|
+
require "omq/version"
|
|
540
|
+
end
|
|
541
|
+
puts "omq-cli #{OMQ::CLI::VERSION} (omq #{OMQ::VERSION})"
|
|
542
|
+
exit
|
|
543
|
+
}
|
|
458
544
|
o.on("-h") { puts o; exit }
|
|
459
545
|
o.on( "--help") { page "#{o}\n#{EXAMPLES}"; exit }
|
|
460
546
|
o.on( "--examples") { page EXAMPLES; exit }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omq-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Patrik Wenger
|
|
@@ -35,6 +35,7 @@ executables:
|
|
|
35
35
|
extensions: []
|
|
36
36
|
extra_rdoc_files: []
|
|
37
37
|
files:
|
|
38
|
+
- CHANGELOG.md
|
|
38
39
|
- LICENSE
|
|
39
40
|
- README.md
|
|
40
41
|
- exe/omq
|