UNPKG

proxy-protocol-js

Version:

A PROXY protocol builder and parser for JavaScript

37 lines 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.IPv4ProxyAddress = exports.IPv4Address = void 0; var AddressFamily_1 = require("../enum/AddressFamily"); var IPv4Address = (function () { function IPv4Address(address) { this.address = address; } IPv4Address.createFrom = function (address) { return new IPv4Address([address[0] || 0, address[1] || 0, address[2] || 0, address[3] || 0]); }; IPv4Address.createWithEmptyAddress = function () { return IPv4Address.createFrom([]); }; return IPv4Address; }()); exports.IPv4Address = IPv4Address; var IPv4ProxyAddress = (function () { function IPv4ProxyAddress(sourceAddress, sourcePort, destinationAddress, destinationPort) { this.sourceAddress = sourceAddress; this.sourcePort = sourcePort; this.destinationAddress = destinationAddress; this.destinationPort = destinationPort; } IPv4ProxyAddress.from = function (data) { return new IPv4ProxyAddress(new IPv4Address([data[0], data[1], data[2], data[3]]), (data[8] << 8) + data[9], new IPv4Address([data[4], data[5], data[6], data[7]]), (data[10] << 8) + data[11]); }; IPv4ProxyAddress.prototype.getLength = function () { return new AddressFamily_1.AddressFamily(this.getAddressFamilyType()).getLength(); }; IPv4ProxyAddress.prototype.getAddressFamilyType = function () { return AddressFamily_1.AddressFamilyType.INET; }; return IPv4ProxyAddress; }()); exports.IPv4ProxyAddress = IPv4ProxyAddress; //# sourceMappingURL=IPv4ProxyAddress.js.map