Sha256: 3e5fe32518f53b154819828e2994aaf8b177806d930f848d86af450b8eee7cd7

Contents?: true

Size: 1005 Bytes

Versions: 151

Compression:

Stored size: 1005 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'optparse'

opts = {}
OptionParser.new do |options|
  options.banner = "USAGE:
    #{$PROGRAM_NAME} [opts]
  "
  options.on('-iIP', '--bind-ip=IP', '<Optional - HTTP Bind IP to Listen> (Defaults to Localhost)') do |i|
    opts[:bind_ip] = i
  end

  options.on('-pPORT', '--port=PORT', '<Optional - HTTP Port to Listen (Defaults to 3333)>') do |p|
    opts[:port] = p
  end
end.parse!

if opts.empty?
  puts `#{$PROGRAM_NAME} --help`
  exit 1
end

if opts[:bind_ip]
  bind_ip = opts[:bind_ip]
else
  bind_ip = '127.0.0.1'
end

if opts[:port]
  port = opts[:port].to_i
else
  port = 3333
end

begin
  system("thin start --adapter file --address #{bind_ip} --port #{port} --threaded --debug")
rescue RuntimeError
  puts "WARNING: Service Already Listening on TCP #{port}..."
  port = Random.rand(1_025..65_535)
  puts "Listen on #{bind_ip}:#{port}..."
  retry
rescue SystemExit, Interrupt
  puts "\n#{File.basename($PROGRAM_NAME)} terminated."
end

Version data entries

151 entries across 151 versions & 1 rubygems

Version Path
pwn-0.4.502 bin/pwn_simple_http_server
pwn-0.4.501 bin/pwn_simple_http_server
pwn-0.4.500 bin/pwn_simple_http_server
pwn-0.4.499 bin/pwn_simple_http_server
pwn-0.4.498 bin/pwn_simple_http_server
pwn-0.4.497 bin/pwn_simple_http_server
pwn-0.4.496 bin/pwn_simple_http_server
pwn-0.4.495 bin/pwn_simple_http_server
pwn-0.4.494 bin/pwn_simple_http_server
pwn-0.4.493 bin/pwn_simple_http_server
pwn-0.4.492 bin/pwn_simple_http_server
pwn-0.4.491 bin/pwn_simple_http_server
pwn-0.4.490 bin/pwn_simple_http_server
pwn-0.4.489 bin/pwn_simple_http_server
pwn-0.4.488 bin/pwn_simple_http_server
pwn-0.4.487 bin/pwn_simple_http_server
pwn-0.4.486 bin/pwn_simple_http_server
pwn-0.4.485 bin/pwn_simple_http_server
pwn-0.4.484 bin/pwn_simple_http_server
pwn-0.4.483 bin/pwn_simple_http_server