| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3614f5a commit debf730
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,6 +142,12 @@ class InternalSocketAddress extends JSTransferable { | |||
| 142 | 142 | constructor(handle) { | |
| 143 | 143 | super(); | |
| 144 | 144 | this[kHandle] = handle; | |
| 145 | + this[kDetail] = this[kHandle]?.detail({ | ||
| 146 | + address: undefined, | ||
| 147 | + port: undefined, | ||
| 148 | + family: undefined, | ||
| 149 | + flowlabel: undefined, | ||
| 150 | + }); | ||
| 145 | 151 | } | |
| 146 | 152 | } | |
| 147 | 153 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + // Flags: --expose-internals | ||
| 1 | 2 | 'use strict'; | |
| 2 | 3 | ||
| 3 | 4 | const common = require('../common'); | |
@@ -10,6 +11,15 @@ const { | |||
| 10 | 11 | SocketAddress, | |
| 11 | 12 | } = require('net'); | |
| 12 | 13 | ||
| 14 | + const { | ||
| 15 | + InternalSocketAddress, | ||
| 16 | + } = require('internal/socketaddress'); | ||
| 17 | + const { internalBinding } = require('internal/test/binding'); | ||
| 18 | + const { | ||
| 19 | + SocketAddress: _SocketAddress, | ||
| 20 | + AF_INET | ||
| 21 | + } = internalBinding('block_list'); | ||
| 22 | + | ||
| 13 | 23 | { | |
| 14 | 24 | const sa = new SocketAddress(); | |
| 15 | 25 | strictEqual(sa.address, '127.0.0.1'); | |
@@ -108,3 +118,20 @@ const { | |||
| 108 | 118 | throws(() => new SocketAddress({ flowlabel: -1 }), { | |
| 109 | 119 | code: 'ERR_OUT_OF_RANGE' | |
| 110 | 120 | }); | |
| 121 | + | ||
| 122 | + { | ||
| 123 | + // Test that the internal helper class InternalSocketAddress correctly | ||
| 124 | + // inherits from SocketAddress and that it does not throw when its properties | ||
| 125 | + // are accessed. | ||
| 126 | + | ||
| 127 | + const address = '127.0.0.1'; | ||
| 128 | + const port = 8080; | ||
| 129 | + const flowlabel = 0; | ||
| 130 | + const handle = new _SocketAddress(address, port, AF_INET, flowlabel); | ||
| 131 | + const addr = new InternalSocketAddress(handle); | ||
| 132 | + ok(addr instanceof SocketAddress); | ||
| 133 | + strictEqual(addr.address, address); | ||
| 134 | + strictEqual(addr.port, port); | ||
| 135 | + strictEqual(addr.family, 'ipv4'); | ||
| 136 | + strictEqual(addr.flowlabel, flowlabel); | ||
| 137 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments