In our previous post, we showed you how to use socat, ssh, and some fancy footwork to pipe a UDP-based request coming from Net::Growl, through a TCP-based reverse-proxy ala SSH, and back to the Mac as a UDP-request straight to Growl.
What happens if you’ve got more than one person wanting to do the same thing from that same shell server? Aside from everyone agreeing on a few ports they’d like to reserve for their Growl activities, here’s the skinny.
The problem
When we first wanted to do this, the only technology hurdle, was that Net::Growl in its current incarnation does not support passing a unique UDP port in the register and notify calls. Not a big deal, here’s what you do to fix:
- Download Net::Growl distribution to your linux machine
- Apply this patch to the distribution
- Rebuild it via: perl Makefile.PL, make, sudo make install
If you’re using our super fancy growl-net-notify.pl script for Weechat, it is already set up to pass a different UDP port by changing the settings in the /growl setup call.
Scenarios
For the TCP side of the equation, you’ll each have to pick your own TCP port (above 1024 of course) to reverse-proxy with. In my previous example I chose 9999, so you can have others choose 9900, 9901, 9902, whatever flows off the tongue.
On the local side, socat and your ssh reverse-proxy will change, but using UDP 9887 will not. Growl is listening there.
On the linux side, where weechat + screen is running, we’ll use whatever our agreed upon TCP port was, and pick our own UDP port to pass messages to from Weechat. This is easily modified from growl-net-notify using /growl setup [host] [pass] [port] where port is whatever your agreed Growl port is going to be. And setup socat to use your agreed upon TCP port, and agreed upon UDP port and do a /growl test hello, world!
Examples
A lot of times reading manuals, I skim through to read the examples, in man pages its usually near the bottom. I need to see the commands in action. So here is an example with a situation you’re likely to run into.
2 people using the same host for IRC. For the sake of example, we’ll use the names: Steve and Andrew.
Steve will use: TCP 9900 and UDP 9889
On the Mac side the commands he’ll use:
% socat TCP-LISTEN:9900,reuseaddr,fork UDP:127.0.0.1:9887 & % ssh myserver -R 9900:127.0.0.1:9900
On the Linux side the commands he’ll use:
socat UDP-LISTEN:9889,reuseaddr,fork TCP:127.0.0.1:9900 &
And from within Weechat’s growl
/growl setup localhost mypass 9889
Andrew will use the defaults: TCP 9999 and UDP 9887
socat TCP-LISTEN:9999,reuseaddr,fork UDP:127.0.0.1:9887 & ssh myserver -R 9999:127.0.0.1:9999
On the Linux side the commands he’ll use:
socat UDP-LISTEN:9887,reuseaddr,fork TCP:127.0.0.1:9999 &
And from within Weechat’s growl
/growl setup localhost mypass 9887
It’s that simple.