Sha256: 900a30dac741eeeb2fae36f783e5269362c8bf969a9b96954b9a21c403850952
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true # Ruby internal require 'pp' # Project internal require 'bigipcookie' # External require 'docopt' require 'paint' doc = <<~DOCOPT RABID (RApid Big IP Decoder) Usage: rabid [options] <raw_cookie> rabid -h | --help rabid --version Options: --ipv6-long-format Display IPv6 address in long format --no-color Disable colorized output --short Display in a short format: display only decoded cookies --debug Display arguments -h, --help Show this screen --version Show version Examples: rabid 'BIGipServer<pool_name>=1677787402.36895.0000' --no-color --short rabid 'rd5o00000000000000000000ffffc0000201o80' rabid 'CustomeCookieName=vi20010112000000000000000000000030.20480' --ipv6-long-format rabid 'BIGipServer~SuperPool=rd3o20010112000000000000000000000030o80' --debug rabid 'BIGipServerhttp-pool=!LHmYFDA0qZyj4NoylBEaDn0/k2wesiGt0ANZhWaAohjULoWFXRc1b/yfibypy1qfBzD51kqvmwzfcy4=' DOCOPT begin args = Docopt.docopt(doc, version: BigIPCookie::VERSION) Paint.mode = 0 if args['--no-color'] pp args if args['--debug'] # use case 1, using the tool if args['<raw_cookie>'] bip = BigIPCookie::Decode.new(args['<raw_cookie>']) opts = {} opts[:ipv6compression] = 0 if args['--ipv6-long-format'] bip.auto_decode(opts) # Display if args['--short'] puts Paint[bip.decoded_cookie, :green] else puts Paint['Pool name:', :white, :bold] + ' ' + bip.pool_name puts Paint['Cookie type:', :white, :bold] + ' ' + bip.cookie_type puts Paint['Raw cookie:', :white, :bold] + ' ' + bip.raw_cookie puts Paint['Decoded cookie:', :white, :bold] + ' ' + Paint[bip.decoded_cookie, :green] end end # use case 2, help: already handled by docopt # use case 3, version: already handled by docopt rescue Docopt::Exit => e puts e.message end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rabid-0.0.6 | bin/rabid |