Sha256: 21c9fc47d5b4d68f501cd3028247f63e57ed401e2e50ad8591001f5e84389a74

Contents?: true

Size: 1.05 KB

Versions: 430

Compression:

Stored size: 1.05 KB

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.to_s,
    '--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

430 entries across 430 versions & 1 rubygems

Version Path
pwn-0.4.959 bin/pwn_simple_http_server
pwn-0.4.958 bin/pwn_simple_http_server
pwn-0.4.957 bin/pwn_simple_http_server
pwn-0.4.956 bin/pwn_simple_http_server
pwn-0.4.955 bin/pwn_simple_http_server
pwn-0.4.954 bin/pwn_simple_http_server
pwn-0.4.953 bin/pwn_simple_http_server
pwn-0.4.952 bin/pwn_simple_http_server
pwn-0.4.951 bin/pwn_simple_http_server
pwn-0.4.950 bin/pwn_simple_http_server
pwn-0.4.949 bin/pwn_simple_http_server
pwn-0.4.948 bin/pwn_simple_http_server
pwn-0.4.947 bin/pwn_simple_http_server
pwn-0.4.946 bin/pwn_simple_http_server
pwn-0.4.945 bin/pwn_simple_http_server
pwn-0.4.944 bin/pwn_simple_http_server
pwn-0.4.943 bin/pwn_simple_http_server
pwn-0.4.942 bin/pwn_simple_http_server
pwn-0.4.941 bin/pwn_simple_http_server
pwn-0.4.940 bin/pwn_simple_http_server