Porttrigger ( pw protected )

Discussion in 'Ruby' started by Udo, Mar 20, 2007.

  1. Udo

    Udo Guest

    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!
    Udo, Mar 20, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    2
    Views:
    557
    Andreas Klemt
    Jul 5, 2003
  2. clintonG

    Re: What means Protected WithEvents ?

    clintonG, Jul 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    440
    clintonG
    Jul 5, 2003
  3. Jon
    Replies:
    4
    Views:
    5,645
    Jonathan Williams
    Aug 7, 2003
  4. Philippe Meunier
    Replies:
    1
    Views:
    306
    Mike Moore [MSFT]
    Oct 24, 2003
  5. Stephen Miller
    Replies:
    5
    Views:
    9,134
    kaverao
    Sep 17, 2009
Loading...

Share This Page