I am trying to run this script on a ubuntu 11.04 box: http://taoofmac.com/space/projects/ReGrowl
Its a small script bound to UDP port 9887 designed to relay Growl packets.
I can send the script Growl packets from the local machine and it works exactly as expected.
However, when trying to send packets from another machine on my network they seem to be dropped or not make it to the script.
I have configured ubuntu to allow the port and the output of netstat looks like this:
root@UbuntuVM:~# netstat -a | grep "udp"
udp 0 0 localhost:9887 *:*
udp 768 0 *:mdns *:*
udp 0 0 *:mdns *:*
udp 0 0 *:45030 *:*
udp6 0 0 [::]:44730 [::]:*
udp6 0 0 [::]:mdns [::]:*
My script is the first entry on the list.
I have used wireshark and confirmed that the ubuntu machine is receiving the packets.
Do I need todo anything to ubuntu to allow python to bind to UDP ports? Anyone know whats going on here?
Thanks in advance!
UPDATE:
The output of the script should look like this:
127.0.0.1 - - [28/Sep/2011 12:30:27] REGISTER Network Responder 56 ['192.168.0.24', '192.168.0.140', '192.168.0.11', '192.168.0.25', '192.168.0.18', '192.168.0.28', '192.168.0.10', '192.168.0.30']
127.0.0.1 - - [28/Sep/2011 12:30:27] NOTIFY ('Network Status', 'Connection Status', 'Test', 'Network Responder') 80 ['192.168.0.24', '192.168.0.140', '192.168.0.11', '192.168.0.25', '192.168.0.18', '192.168.0.28', '192.168.0.10', '192.168.0.30']
The first IP is the source of the packet, and the array of IPs at the end are the destinations for the packet to be relayed to. As you can this packet originated from the local machine, if I send a packet form another machine its IP should apear first.
Here is the portion of the script that implements the UDP server:
class GrowlRelay(UDPServer):
"""Growl Notification Relay"""
allow_reuse_address = True
def __init__(self, inpassword = None, outpassword = None):
"""Initializes the relay and launches the resolver thread"""
self.inpassword = inpassword
self.outpassword = outpassword
self.resolver = RendezvousWatcher()
self.resolver.start()
UDPServer.__init__(self,('localhost', GROWL_UDP_PORT), _RequestHandler)
def server_close(self):
self.resolver.shutdown()
The full script and dependant classes are available and the link above.
Your code binds the server to localhost, i.e. it only listens to local connections. Replace
UDPServer.__init__(self,('localhost', GROWL_UDP_PORT), _RequestHandler)
with
UDPServer.__init__(self,('', GROWL_UDP_PORT), _RequestHandler)
to accept connections from anywhere.