# -O option to arirang ruby script
# by pilot
# export PROXY_TYPE="RELAY"
# required the -X option
# eg) arirang -X yourproxy:3128 -R server.rb -h yourhost/24
class Arirang

#@ari_port = 80
#@ari_recvsize = 1024
#@ari_recvflag = 3

    def baedal
        ari_title  = "http server allow check\n"
        ari_desc   = "-O option to arirang ruby script\n"
        ari_author = "pilot <pilot@monkey.org>\n"

        puts "title: #{ari_title}"
        puts "desc: #{ari_desc}"
        puts "author: #{ari_author}"
    end

    def asadal
        ariconnect
        buf = "OPTIONS http://#{$ari_host}/ HTTP/1.0\r\n\r\n"
        resp = arisend(buf)

        # buf = $ari_recv.split("\r\n")[0..10].join("\r\n")
        resp.each do |line|
        x = line.match(/^Allow\: (.+)/)
            if x != nil
                y = "#{$ari_host} - #{x[1]}\n"
                ariprint(y)
            end

        end

    end

end