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.437 bin/pwn_simple_http_server
pwn-0.4.436 bin/pwn_simple_http_server
pwn-0.4.435 bin/pwn_simple_http_server
pwn-0.4.434 bin/pwn_simple_http_server
pwn-0.4.433 bin/pwn_simple_http_server
pwn-0.4.432 bin/pwn_simple_http_server
pwn-0.4.431 bin/pwn_simple_http_server
pwn-0.4.430 bin/pwn_simple_http_server
pwn-0.4.429 bin/pwn_simple_http_server
pwn-0.4.428 bin/pwn_simple_http_server
pwn-0.4.427 bin/pwn_simple_http_server
pwn-0.4.426 bin/pwn_simple_http_server
pwn-0.4.425 bin/pwn_simple_http_server
pwn-0.4.424 bin/pwn_simple_http_server
pwn-0.4.423 bin/pwn_simple_http_server
pwn-0.4.422 bin/pwn_simple_http_server
pwn-0.4.421 bin/pwn_simple_http_server
pwn-0.4.419 bin/pwn_simple_http_server
pwn-0.4.418 bin/pwn_simple_http_server
pwn-0.4.417 bin/pwn_simple_http_server