omq 0.7.0 → 0.9.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 +58 -1
- data/README.md +9 -49
- data/lib/omq/version.rb +1 -1
- data/lib/omq/zmtp/engine.rb +35 -9
- data/lib/omq/zmtp.rb +16 -13
- metadata +21 -33
- data/exe/omq +0 -6
- data/lib/omq/cli/base_runner.rb +0 -459
- data/lib/omq/cli/channel.rb +0 -8
- data/lib/omq/cli/client_server.rb +0 -111
- data/lib/omq/cli/config.rb +0 -54
- data/lib/omq/cli/formatter.rb +0 -75
- data/lib/omq/cli/pair.rb +0 -31
- data/lib/omq/cli/peer.rb +0 -8
- data/lib/omq/cli/pipe.rb +0 -265
- data/lib/omq/cli/pub_sub.rb +0 -14
- data/lib/omq/cli/push_pull.rb +0 -14
- data/lib/omq/cli/radio_dish.rb +0 -27
- data/lib/omq/cli/req_rep.rb +0 -83
- data/lib/omq/cli/router_dealer.rb +0 -76
- data/lib/omq/cli/scatter_gather.rb +0 -14
- data/lib/omq/cli.rb +0 -540
- data/lib/omq/zmtp/codec/command.rb +0 -210
- data/lib/omq/zmtp/codec/frame.rb +0 -89
- data/lib/omq/zmtp/codec/greeting.rb +0 -78
- data/lib/omq/zmtp/codec.rb +0 -18
- data/lib/omq/zmtp/connection.rb +0 -282
- data/lib/omq/zmtp/mechanism/null.rb +0 -72
- data/lib/omq/zmtp/valid_peers.rb +0 -29
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module OMQ
|
|
4
|
-
module ZMTP
|
|
5
|
-
module Mechanism
|
|
6
|
-
# NULL security mechanism — no encryption, no authentication.
|
|
7
|
-
#
|
|
8
|
-
# Performs the ZMTP 3.1 greeting exchange and READY command handshake.
|
|
9
|
-
#
|
|
10
|
-
class Null
|
|
11
|
-
MECHANISM_NAME = "NULL"
|
|
12
|
-
|
|
13
|
-
# Performs the full NULL handshake over +io+.
|
|
14
|
-
#
|
|
15
|
-
# 1. Exchange 64-byte greetings
|
|
16
|
-
# 2. Validate peer greeting (version, mechanism)
|
|
17
|
-
# 3. Exchange READY commands (socket type + identity)
|
|
18
|
-
#
|
|
19
|
-
# @param io [#read, #write] transport IO
|
|
20
|
-
# @param as_server [Boolean]
|
|
21
|
-
# @param socket_type [String]
|
|
22
|
-
# @param identity [String]
|
|
23
|
-
# @return [Hash] { peer_socket_type:, peer_identity: }
|
|
24
|
-
# @raise [ProtocolError]
|
|
25
|
-
#
|
|
26
|
-
def handshake!(io, as_server:, socket_type:, identity:)
|
|
27
|
-
# Send our greeting
|
|
28
|
-
io.write(Codec::Greeting.encode(mechanism: MECHANISM_NAME, as_server: as_server))
|
|
29
|
-
io.flush
|
|
30
|
-
|
|
31
|
-
# Read peer greeting
|
|
32
|
-
greeting_data = io.read_exactly(Codec::Greeting::SIZE)
|
|
33
|
-
peer_greeting = Codec::Greeting.decode(greeting_data)
|
|
34
|
-
|
|
35
|
-
unless peer_greeting[:mechanism] == MECHANISM_NAME
|
|
36
|
-
raise ProtocolError, "unsupported mechanism: #{peer_greeting[:mechanism]}"
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Send our READY command
|
|
40
|
-
ready_cmd = Codec::Command.ready(socket_type: socket_type, identity: identity)
|
|
41
|
-
io.write(ready_cmd.to_frame.to_wire)
|
|
42
|
-
io.flush
|
|
43
|
-
|
|
44
|
-
# Read peer READY command
|
|
45
|
-
frame = Codec::Frame.read_from(io)
|
|
46
|
-
unless frame.command?
|
|
47
|
-
raise ProtocolError, "expected command frame, got data frame"
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
peer_cmd = Codec::Command.from_body(frame.body)
|
|
51
|
-
unless peer_cmd.name == "READY"
|
|
52
|
-
raise ProtocolError, "expected READY command, got #{peer_cmd.name}"
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
props = peer_cmd.properties
|
|
56
|
-
peer_socket_type = props["Socket-Type"]
|
|
57
|
-
peer_identity = props["Identity"] || ""
|
|
58
|
-
|
|
59
|
-
unless peer_socket_type
|
|
60
|
-
raise ProtocolError, "peer READY missing Socket-Type"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
{ peer_socket_type: peer_socket_type, peer_identity: peer_identity }
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
# @return [Boolean] false — NULL does not encrypt frames
|
|
67
|
-
#
|
|
68
|
-
def encrypted? = false
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
data/lib/omq/zmtp/valid_peers.rb
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module OMQ
|
|
4
|
-
module ZMTP
|
|
5
|
-
# Valid socket type peer combinations per ZMTP spec.
|
|
6
|
-
#
|
|
7
|
-
VALID_PEERS = {
|
|
8
|
-
PAIR: %i[PAIR].freeze,
|
|
9
|
-
REQ: %i[REP ROUTER].freeze,
|
|
10
|
-
REP: %i[REQ DEALER].freeze,
|
|
11
|
-
DEALER: %i[REP DEALER ROUTER].freeze,
|
|
12
|
-
ROUTER: %i[REQ DEALER ROUTER].freeze,
|
|
13
|
-
PUB: %i[SUB XSUB].freeze,
|
|
14
|
-
SUB: %i[PUB XPUB].freeze,
|
|
15
|
-
XPUB: %i[SUB XSUB].freeze,
|
|
16
|
-
XSUB: %i[PUB XPUB].freeze,
|
|
17
|
-
PUSH: %i[PULL].freeze,
|
|
18
|
-
PULL: %i[PUSH].freeze,
|
|
19
|
-
CLIENT: %i[SERVER].freeze,
|
|
20
|
-
SERVER: %i[CLIENT].freeze,
|
|
21
|
-
RADIO: %i[DISH].freeze,
|
|
22
|
-
DISH: %i[RADIO].freeze,
|
|
23
|
-
SCATTER: %i[GATHER].freeze,
|
|
24
|
-
GATHER: %i[SCATTER].freeze,
|
|
25
|
-
PEER: %i[PEER].freeze,
|
|
26
|
-
CHANNEL: %i[CHANNEL].freeze,
|
|
27
|
-
}.freeze
|
|
28
|
-
end
|
|
29
|
-
end
|