Sha256: 0aa6e137d930ab8894d50983d3721b498b46072d620894bbba00f78a7c7911ad

Contents?: true

Size: 958 Bytes

Versions: 157

Compression:

Stored size: 958 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!

bind_ip = opts[:bind_ip] ||= '127.0.0.1'

port = opts[:port].to_i
port = 3333 if port.zero?

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

157 entries across 157 versions & 1 rubygems

Version Path
pwn-0.5.164 bin/pwn_simple_http_server
pwn-0.5.163 bin/pwn_simple_http_server
pwn-0.5.162 bin/pwn_simple_http_server
pwn-0.5.161 bin/pwn_simple_http_server
pwn-0.5.160 bin/pwn_simple_http_server
pwn-0.5.159 bin/pwn_simple_http_server
pwn-0.5.158 bin/pwn_simple_http_server
pwn-0.5.157 bin/pwn_simple_http_server
pwn-0.5.156 bin/pwn_simple_http_server
pwn-0.5.155 bin/pwn_simple_http_server
pwn-0.5.154 bin/pwn_simple_http_server
pwn-0.5.153 bin/pwn_simple_http_server
pwn-0.5.152 bin/pwn_simple_http_server
pwn-0.5.151 bin/pwn_simple_http_server
pwn-0.5.150 bin/pwn_simple_http_server
pwn-0.5.106 bin/pwn_simple_http_server
pwn-0.5.105 bin/pwn_simple_http_server
pwn-0.5.104 bin/pwn_simple_http_server
pwn-0.5.103 bin/pwn_simple_http_server
pwn-0.5.102 bin/pwn_simple_http_server