Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Porttrigger ( pw protected ) (http://www.velocityreviews.com/forums/t839203-porttrigger-pw-protected.html)

Udo 03-20-2007 03:59 PM

Porttrigger ( pw protected )
 
Hello!

I want to control the starting of certain services on my
Linux VPS with a home made porttrigger. If the right password
is received the according programm for that port is started.
( I have my reasons to do it this way and not with firewall
setting or encryted passwords. If you want to know ask ;-) )

This is what i have come up with so far:

#!/usr/bin/env ruby
require "socket"
server = TCPServer.new('0.0.0.0', 8089)
while (session = server.accept)
if (ret=session.gets.chomp) =~ /password/
puts `./sc_serv0`
end
session.close
end



It kinda works, but the problem is that the ruby isnt freeing
the port.
So programms that cant share ports give me:

error opening source socket! FATAL ERROR! Some other process is using
this port!

How do i close the TCPServer after the right password is received?
( In the final version i want to stop the started programm after
a certain amount of of time and start the trigger again ( and it
prolly needs to be threaded. ))
But for now i just want this to work.

server.shutdown wont work after the right pw is received.

Any ideas?

Thanks!


All times are GMT. The time now is 10:08 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57