1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
19 | exports.stringToSubchannelAddress = exports.subchannelAddressToString = exports.subchannelAddressEqual = exports.isTcpSubchannelAddress = void 0;
|
20 | const net_1 = require("net");
|
21 | function isTcpSubchannelAddress(address) {
|
22 | return 'port' in address;
|
23 | }
|
24 | exports.isTcpSubchannelAddress = isTcpSubchannelAddress;
|
25 | function subchannelAddressEqual(address1, address2) {
|
26 | if (!address1 && !address2) {
|
27 | return true;
|
28 | }
|
29 | if (!address1 || !address2) {
|
30 | return false;
|
31 | }
|
32 | if (isTcpSubchannelAddress(address1)) {
|
33 | return (isTcpSubchannelAddress(address2) &&
|
34 | address1.host === address2.host &&
|
35 | address1.port === address2.port);
|
36 | }
|
37 | else {
|
38 | return !isTcpSubchannelAddress(address2) && address1.path === address2.path;
|
39 | }
|
40 | }
|
41 | exports.subchannelAddressEqual = subchannelAddressEqual;
|
42 | function subchannelAddressToString(address) {
|
43 | if (isTcpSubchannelAddress(address)) {
|
44 | return address.host + ':' + address.port;
|
45 | }
|
46 | else {
|
47 | return address.path;
|
48 | }
|
49 | }
|
50 | exports.subchannelAddressToString = subchannelAddressToString;
|
51 | const DEFAULT_PORT = 443;
|
52 | function stringToSubchannelAddress(addressString, port) {
|
53 | if ((0, net_1.isIP)(addressString)) {
|
54 | return {
|
55 | host: addressString,
|
56 | port: port !== null && port !== void 0 ? port : DEFAULT_PORT,
|
57 | };
|
58 | }
|
59 | else {
|
60 | return {
|
61 | path: addressString,
|
62 | };
|
63 | }
|
64 | }
|
65 | exports.stringToSubchannelAddress = stringToSubchannelAddress;
|
66 |
|
\ | No newline at end of file |