class IrcLB::Socket

Public Class Methods

new() click to toggle source
# File lib/irclb/ssl_server.rb, line 11
def initialize
  @tcp_srv = TCPServer.new 6697
  @ssl_ctx = OpenSSL::SSL::SSLContext.new
  @ssl_ctx.min_version = OpenSSL::SSL::TLS1_1_VERSION
  @ssl_ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
  @ssl_sock = OpenSSL::SSL::SSLSocket.new(@tcp_srv, @ssl_ctx)
  dont_block
end

Public Instance Methods

dont_block() click to toggle source
# File lib/irclb/ssl_server.rb, line 20
def dont_block
  loop do
    Thread.start(@ssl_sock.accept) do |client|
      puts client
      case client.gets
      when /^USER .*/
        client.puts ":irc.lb NOTICE * :This server is running IRClb, an IRC load balancer\r\n"
        client.puts ":irc.lb NOTICE * :IRClb is written by Ken Spencer / iota\r\n"
        client.puts ":irc.lb NOTICE * :He has a website at https://iotaspencer.me\r\n"
        client.puts ":irc.lb NOTICE * :\r\n"
        client.puts ":irc.lb NOTICE * :IRClb Support can be found in #irclb on irc.6697.co.uk\r\n"
        client.puts ":irc.lb NOTICE * :\r\n"
        client.puts ":irc.lb NOTICE * :With that out of the way, ...\r\n"
        client.puts ":irc.lb NOTICE * :Connecting you to #{$config.network.name}...\r\n"
      end
      client.close if client.gets =~ /^QUIT .*/
    end
  end
end