Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/lib/rex/proto/natpmp/packet_spec.rb
Views: 11789
# -*- coding: binary -*-1require 'spec_helper'23RSpec.describe Rex::Proto::NATPMP do4subject do5mod = Module.new6mod.extend described_class7mod8end910describe '#parse_external_address_response' do11it 'should properly parse non-error responses' do12data = "\x00\x80\x00\x00\x00\x33\x50\x53\xc0\xa8\x01\x02"13subject.parse_external_address_response(data)14ver, opcode, result, epoch, addr = subject.parse_external_address_response(data)15expect(ver).to eq(0)16expect(opcode).to eq(128)17expect(result).to eq(0)18expect(epoch).to eq(3362899)19expect(addr).to eq('192.168.1.2')20end21it 'should properly parse error responses' do22data = "\x00\x80\x00\x03\x00\x00\x70\x90\x00\x00\x00\x00"23subject.parse_external_address_response(data)24ver, opcode, result, epoch, addr = subject.parse_external_address_response(data)25expect(ver).to eq(0)26expect(opcode).to eq(128)27expect(result).to eq(3)28expect(epoch).to eq(28816)29expect(addr).to eq('0.0.0.0')30end31end3233describe '#parse_map_port_response' do34it 'should properly parse responses' do35data = "\x00\x82\x00\x00\x00\x33\x6f\xd8\x11\x5c\x15\xb3\x00\x36\xee\x80"36ver, opcode, result, epoch, internal, external, lifetime = subject.parse_map_port_response(data)37expect(ver).to eq(0)38expect(opcode).to eq(130)39expect(result).to eq(0)40expect(epoch).to eq(3370968)41expect(internal).to eq(4444)42expect(external).to eq(5555)43expect(lifetime).to eq(3600000)44end45end46end474849