qcmd 0.1.16.pre2 → 0.1.16
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.
- data/CHANGELOG.md +11 -0
- data/bin/qcmd +1 -1
- data/bin/qcmd-proxy +152 -0
- data/lib/qcmd/cli.rb +3 -1
- data/lib/qcmd/core_ext/osc.rb +1 -1
- data/lib/qcmd/core_ext/osc/client.rb +10 -0
- data/lib/qcmd/core_ext/osc/message.rb +7 -0
- data/lib/qcmd/version.rb +1 -1
- data/sample/dnssd.rb +2 -0
- metadata +8 -5
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
### 0.1.9 to 0.1.16
|
2
|
+
|
3
|
+
* replace command parser with updated version of [Sexpistol](https://github.com/aarongough/sexpistol).
|
4
|
+
* add "sleep" command. 1f047b45eb33e0d65563fae0eb1eb73e4fb61ee9
|
5
|
+
* add log related commands (`log-silent`, `log-noisy`, `log-debug`, `log-info`,
|
6
|
+
and `echo`) for use in alias commands. 16b10d1c824c31a32716e5bbeb08adf4858ba4c6
|
7
|
+
* multiple commands can be given when launching qcmd with the -c option 16b10d1c824c31a32716e5bbeb08adf4858ba4c6
|
8
|
+
* add ++, --, \*\*, and // command modifiers df4eca08865225927c32fe73d1dd5038807209a6
|
9
|
+
* add a TCP based OSC server to support qcmd-proxy 436f7384ba0fee9dc2bbf25df19e7b78c4b60fb2
|
10
|
+
* create qcmd-proxy to allow for easier debugging of OSC apps that want to talk to QLab
|
11
|
+
|
1
12
|
### 0.1.8 to 0.1.9
|
2
13
|
|
3
14
|
* add help documentation for the "alias" command
|
data/bin/qcmd
CHANGED
data/bin/qcmd-proxy
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
help_message = <<-EOS
|
4
|
+
|
5
|
+
After starting qcmd-proxy, you should be able to to connect to "OSC QLab
|
6
|
+
Proxy Server" from QLab Remote for iPad and see all the messages flying back
|
7
|
+
and forth in your terminal. Due to the way QLab responds via blind UDP, you
|
8
|
+
may have to manually connect to the proxy server.
|
9
|
+
|
10
|
+
qcmd-proxy can also be used to debug your own OSC apps. Simply start QLab,
|
11
|
+
then start qcmd-proxy from the command line and then connect your app to port
|
12
|
+
52000 of your machine instead of 53000.
|
13
|
+
|
14
|
+
Running your OSC app/script/tool/toy on localhost will cause an infinite
|
15
|
+
looping scenario where qcmd-proxy receives a response from QLab and forwards
|
16
|
+
it to itself. To avoid this, qcmd-proxy will not forward UDP messages to apps
|
17
|
+
running on 127.0.0.1, 0.0.0.0, or "localhost".
|
18
|
+
|
19
|
+
NOTE: if you're running a very active OSC app, you could be generating more
|
20
|
+
data than qcmd can spit to the console easily, you should redirect output to
|
21
|
+
a logfile if you're going to be sending more than, say, 8 commands a second.
|
22
|
+
|
23
|
+
Usage:
|
24
|
+
|
25
|
+
qcmd-proxy [options]
|
26
|
+
|
27
|
+
where [options] are:
|
28
|
+
|
29
|
+
EOS
|
30
|
+
|
31
|
+
require 'qcmd'
|
32
|
+
require 'dnssd'
|
33
|
+
require 'trollop'
|
34
|
+
|
35
|
+
VERSION_STRING = "qcmd-proxy #{ Qcmd::VERSION } (c) 2013 Figure 53, Baltimore, MD."
|
36
|
+
|
37
|
+
opts = Trollop::options do
|
38
|
+
version VERSION_STRING
|
39
|
+
banner help_message
|
40
|
+
opt :receiving_port, 'The port qcmd-proxy will receive requests from client apps on.', :default => 52000
|
41
|
+
opt :qlab_listening_port, 'The port QLab is listening on.', :default => 53000
|
42
|
+
opt :qlab_response_port, 'The port QLab will respond on.', :default => 53001
|
43
|
+
opt :qlab_host_name, 'The hostname of the running QLab instance.', :default => 'localhost'
|
44
|
+
end
|
45
|
+
|
46
|
+
receiving_port = opts[:receiving_port]
|
47
|
+
|
48
|
+
# 52001 for testing on localhost, 53001 for real-world use.
|
49
|
+
udp_response_port = 53001
|
50
|
+
|
51
|
+
# These are QLab's built in ports and cannot be changed.
|
52
|
+
qlab_listening_port = opts[:qlab_listening_port]
|
53
|
+
qlab_response_port = opts[:qlab_response_port]
|
54
|
+
qlab_host_name = opts[:qlab_host_name]
|
55
|
+
|
56
|
+
# qcmd-proxy registers itself on the local network as an application supporting
|
57
|
+
# the QLab OSC protocol.
|
58
|
+
dnssd_thread = Thread.new do
|
59
|
+
# name, type, domain, port
|
60
|
+
service = DNSSD.register 'OSC QLab Proxy Server', '_qlab._udp', 'local.', receiving_port
|
61
|
+
service = DNSSD.register 'OSC QLab Proxy Server', '_qlab._tcp', 'local.', receiving_port
|
62
|
+
end
|
63
|
+
|
64
|
+
# TCP & UDP servers that talk directly to QLab
|
65
|
+
begin
|
66
|
+
outbound_qlab_tcp_connection = OSC::TCP::Client.new qlab_host_name, qlab_listening_port
|
67
|
+
rescue Errno::ECONNREFUSED
|
68
|
+
Qcmd.print_wrapped "Could not connect to QLab. Make sure you have QLab running on this machine before starting qcmd-proxy."
|
69
|
+
exit 1
|
70
|
+
end
|
71
|
+
outbound_qlab_udp_connection = OSC::Client.new qlab_host_name, qlab_listening_port
|
72
|
+
|
73
|
+
# Forwarding UDP Server
|
74
|
+
#
|
75
|
+
# This server gets requests from a remote control app and forwards them to QLab
|
76
|
+
begin
|
77
|
+
forwarding_udp_server = OSC::Server.new(receiving_port)
|
78
|
+
rescue Errno::EADDRINUSE
|
79
|
+
Qcmd.print_wrapped "Port #{ receiving_port } already seems to be in use, please choose a different recieving port."
|
80
|
+
end
|
81
|
+
|
82
|
+
# we won't know which IP Adress is making the UDP request until a request has been received.
|
83
|
+
requesting_ip_address = nil
|
84
|
+
requesting_clients = {}
|
85
|
+
|
86
|
+
forwarding_udp_server.add_method(/.*/) do |message|
|
87
|
+
Qcmd.print "[udp from client] #{ message.debug }"
|
88
|
+
|
89
|
+
# get client app's ip address, we'll use it to forward traffic from QLab back
|
90
|
+
# to the remote control app.
|
91
|
+
requesting_ip_address = message.ip_address.sub(/\.\.\./, '')
|
92
|
+
|
93
|
+
# immediately send message to QLab
|
94
|
+
begin
|
95
|
+
outbound_qlab_udp_connection.send message
|
96
|
+
rescue Errno::ECONNREFUSED
|
97
|
+
Qcmd.print "Connection to QLab lost!"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# try to avoid forwarding messages to qcmd-proxy
|
102
|
+
def is_loopback_address?(ip_address)
|
103
|
+
/^(127\.0\.0\.1|0\.0\.0\.0|localhost)$/ =~ ip_address
|
104
|
+
end
|
105
|
+
|
106
|
+
# Receive real responses from QLab and forward them back to original requestor
|
107
|
+
# on port 53001, just like the real QLab. Slight problem, we don't know who
|
108
|
+
# sent the request that inspired this response, so we guess it's the requestor
|
109
|
+
# who made a request most recently.
|
110
|
+
inbound_qlab_udp_connection = OSC::Server.new qlab_response_port
|
111
|
+
inbound_qlab_udp_connection.add_method(/.*/) do |qlab_response_message|
|
112
|
+
if requesting_ip_address
|
113
|
+
Qcmd.print "[udp from QLab for #{ requesting_ip_address }:#{ udp_response_port }] #{ qlab_response_message.debug }"
|
114
|
+
|
115
|
+
if !is_loopback_address?(requesting_ip_address.to_s)
|
116
|
+
requesting_clients[requesting_ip_address] = OSC::Client.new(requesting_ip_address, udp_response_port)
|
117
|
+
requesting_clients[requesting_ip_address].send(qlab_response_message)
|
118
|
+
end
|
119
|
+
else
|
120
|
+
Qcmd.print "Cannot forward UDP from QLab! No requesting_ip_address available"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
## OSC::TCPServer gets requests and forwards them to QLab
|
125
|
+
forwarding_tcp_server = OSC::TCP::Server.new(receiving_port)
|
126
|
+
forwarding_tcp_server.add_method(/.*/) do |message|
|
127
|
+
Qcmd.print "[tcp from client] #{ message.debug }"
|
128
|
+
|
129
|
+
outbound_qlab_udp_connection.send(message) do |qlab_response_message|
|
130
|
+
if qlab_response_message
|
131
|
+
Qcmd.print "[tcp from QLab] #{ qlab_response_message.debug }"
|
132
|
+
message.responder.send(qlab_response_message)
|
133
|
+
else
|
134
|
+
Qcmd.print "[tcp from QLab] nil"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
Qcmd.print "starting forwarding UDP server on port #{ receiving_port }"
|
140
|
+
udp_forwarding_thread = Thread.new do
|
141
|
+
forwarding_udp_server.run
|
142
|
+
end
|
143
|
+
|
144
|
+
Qcmd.print "starting inbound UDP server on port #{ qlab_response_port }"
|
145
|
+
udp_inbound_thread = Thread.new do
|
146
|
+
inbound_qlab_udp_connection.run
|
147
|
+
end
|
148
|
+
|
149
|
+
Qcmd.print "starting forwarding TCP server on port #{ receiving_port }"
|
150
|
+
forwarding_tcp_server.run
|
151
|
+
|
152
|
+
|
data/lib/qcmd/cli.rb
CHANGED
@@ -197,9 +197,11 @@ module Qcmd
|
|
197
197
|
if machine_name.nil? || machine_name.to_s.empty?
|
198
198
|
machine = nil
|
199
199
|
elsif Qcmd::Network.find(machine_name)
|
200
|
+
log(:debug, "[connect_to_machine_by_name] Searching for machine by name: #{ machine_name.to_s }")
|
200
201
|
machine = Qcmd::Network.find(machine_name)
|
201
202
|
elsif Qcmd::Network::IPV4_MATCHER =~ machine_name.to_s
|
202
|
-
machine
|
203
|
+
log(:debug, "[connect_to_machine_by_name] Connecting to machine by IP ADDRESS: #{ machine_name.to_s }")
|
204
|
+
machine = Qcmd::Machine.new(machine_name, machine_name.to_s, 53000)
|
203
205
|
end
|
204
206
|
|
205
207
|
if machine.nil?
|
data/lib/qcmd/core_ext/osc.rb
CHANGED
data/lib/qcmd/version.rb
CHANGED
data/sample/dnssd.rb
CHANGED
@@ -28,12 +28,14 @@ def do_browse_on_service(b)
|
|
28
28
|
row :target, r
|
29
29
|
puts '*' * 40
|
30
30
|
end
|
31
|
+
|
31
32
|
end
|
32
33
|
|
33
34
|
browsers = []
|
34
35
|
|
35
36
|
browsers.push(DNSSD.browse('_qlab._udp.') do |b|
|
36
37
|
do_browse_on_service(b)
|
38
|
+
sleep 2
|
37
39
|
end)
|
38
40
|
|
39
41
|
# browsers.push(DNSSD.browse('_qlab._tcp.') do |b|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qcmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.16
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.16
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Adam Bachman
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dnssd
|
@@ -128,6 +128,7 @@ email:
|
|
128
128
|
- adam.bachman@gmail.com
|
129
129
|
executables:
|
130
130
|
- qcmd
|
131
|
+
- qcmd-proxy
|
131
132
|
extensions: []
|
132
133
|
extra_rdoc_files: []
|
133
134
|
files:
|
@@ -139,6 +140,7 @@ files:
|
|
139
140
|
- Rakefile
|
140
141
|
- TODO.md
|
141
142
|
- bin/qcmd
|
143
|
+
- bin/qcmd-proxy
|
142
144
|
- features/support/setup.rb
|
143
145
|
- lib/qcmd.rb
|
144
146
|
- lib/qcmd/action.rb
|
@@ -152,6 +154,7 @@ files:
|
|
152
154
|
- lib/qcmd/context.rb
|
153
155
|
- lib/qcmd/core_ext/array.rb
|
154
156
|
- lib/qcmd/core_ext/osc.rb
|
157
|
+
- lib/qcmd/core_ext/osc/client.rb
|
155
158
|
- lib/qcmd/core_ext/osc/message.rb
|
156
159
|
- lib/qcmd/core_ext/osc/sending_socket.rb
|
157
160
|
- lib/qcmd/core_ext/osc/tcp.rb
|
@@ -204,9 +207,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
208
|
none: false
|
206
209
|
requirements:
|
207
|
-
- - ! '
|
210
|
+
- - ! '>='
|
208
211
|
- !ruby/object:Gem::Version
|
209
|
-
version:
|
212
|
+
version: '0'
|
210
213
|
requirements: []
|
211
214
|
rubyforge_project:
|
212
215
|
rubygems_version: 1.8.24
|