Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de88255

Browse filesBrowse files
committed
Revert "lib,src: add unix socket getsockname/getpeername"
This reverts commit 6cd0e26. This reverts commit 7a999a1. This reverts commit f337595. It turns out that on Windows, uv_pipe_getsockname() is a no-op for client sockets. It slipped through testing because of a CI snafu. PR-URL: #2584 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
1 parent 6cd0e26 commit de88255
Copy full SHA for de88255

File tree

Expand file treeCollapse file tree

8 files changed

+15
-65
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

8 files changed

+15
-65
lines changed
Open diff view settings
Collapse file

‎doc/api/net.markdown‎

Copy file name to clipboardExpand all lines: doc/api/net.markdown
+5-20Lines changed: 5 additions & 20 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,6 @@ Example:
255255

256256
Don't call `server.address()` until the `'listening'` event has been emitted.
257257

258-
This method used to return the file path as a string for UNIX sockets and
259-
Windows pipes. As of Node.js v4.0.0, it returns the expected object.
260-
261258
### server.unref()
262259

263260
Calling `unref` on a server will allow the program to exit if this is the only
@@ -511,37 +508,25 @@ Returns `socket`.
511508
The string representation of the remote IP address. For example,
512509
`'74.125.127.100'` or `'2001:4860:a005::68'`.
513510

514-
For UNIX sockets and Windows pipes, the file path the socket is connected
515-
to. The remote address for server sockets is always `''`, the empty string.
516-
517511
### socket.remoteFamily
518512

519-
The string representation of the remote IP family. `'IPv4'` or `'IPv6'`
520-
for TCP sockets, `'pipe'` for UNIX sockets and Windows pipes.
513+
The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
521514

522515
### socket.remotePort
523516

524-
The numeric representation of the remote port. For example, `80` or `21`.
525-
`undefined` for UNIX sockets and Windows pipes.
517+
The numeric representation of the remote port. For example,
518+
`80` or `21`.
526519

527520
### socket.localAddress
528521

529522
The string representation of the local IP address the remote client is
530523
connecting on. For example, if you are listening on `'0.0.0.0'` and the
531524
client connects on `'192.168.1.1'`, the value would be `'192.168.1.1'`.
532525

533-
For UNIX sockets and Windows pipes, the file path the socket is listening
534-
on. The local address for client sockets is always `''`, the empty string.
535-
536-
### socket.localFamily
537-
538-
The string representation of the local IP family. `'IPv4'` or `'IPv6'`
539-
for TCP sockets, `'pipe'` for UNIX sockets and Windows pipes.
540-
541526
### socket.localPort
542527

543-
The numeric representation of the local port. For example, `80` or `21`.
544-
`undefined` for UNIX sockets and Windows pipes.
528+
The numeric representation of the local port. For example,
529+
`80` or `21`.
545530

546531
### socket.bytesRead
547532

Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,6 @@ Socket.prototype.__defineGetter__('localAddress', function() {
606606
return this._getsockname().address;
607607
});
608608

609-
Socket.prototype.__defineGetter__('localFamily', function() {
610-
return this._getsockname().family;
611-
});
612609

613610
Socket.prototype.__defineGetter__('localPort', function() {
614611
return this._getsockname().port;
@@ -1342,14 +1339,16 @@ Server.prototype.listen = function() {
13421339
else
13431340
listen(self, null, h.port | 0, 4, backlog, undefined, h.exclusive);
13441341
} else if (h.path && isPipeName(h.path)) {
1345-
listen(self, h.path, -1, -1, backlog, undefined, h.exclusive);
1342+
var pipeName = self._pipeName = h.path;
1343+
listen(self, pipeName, -1, -1, backlog, undefined, h.exclusive);
13461344
} else {
13471345
throw new Error('Invalid listen argument: ' + h);
13481346
}
13491347
}
13501348
} else if (isPipeName(arguments[0])) {
13511349
// UNIX socket or Windows pipe.
1352-
listen(self, arguments[0], -1, -1, backlog);
1350+
var pipeName = self._pipeName = arguments[0];
1351+
listen(self, pipeName, -1, -1, backlog);
13531352

13541353
} else if (arguments[1] === undefined ||
13551354
typeof arguments[1] === 'function' ||
@@ -1382,6 +1381,8 @@ Server.prototype.address = function() {
13821381
this._handle.getsockname(out);
13831382
// TODO(bnoordhuis) Check err and throw?
13841383
return out;
1384+
} else if (this._pipeName) {
1385+
return this._pipeName;
13851386
} else {
13861387
return null;
13871388
}
Collapse file

‎src/pipe_wrap.cc‎

Copy file name to clipboardExpand all lines: src/pipe_wrap.cc
-26Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ void PipeWrap::Initialize(Handle<Object> target,
8989
env->SetProtoMethod(t, "listen", Listen);
9090
env->SetProtoMethod(t, "connect", Connect);
9191
env->SetProtoMethod(t, "open", Open);
92-
env->SetProtoMethod(t, "getpeername",
93-
GetSockOrPeerName<uv_pipe_getpeername>);
94-
env->SetProtoMethod(t, "getsockname",
95-
GetSockOrPeerName<uv_pipe_getsockname>);
9692

9793
#ifdef _WIN32
9894
env->SetProtoMethod(t, "setPendingInstances", SetPendingInstances);
@@ -280,28 +276,6 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
280276
}
281277

282278

283-
template <int (*F)(const uv_pipe_t*, char*, size_t*)>
284-
void PipeWrap::GetSockOrPeerName(
285-
const v8::FunctionCallbackInfo<v8::Value>& args) {
286-
CHECK(args[0]->IsObject());
287-
char buffer[1024];
288-
size_t size = sizeof(buffer);
289-
const PipeWrap* wrap = Unwrap<PipeWrap>(args.Holder());
290-
const int err = F(&wrap->handle_, buffer, &size);
291-
if (err == 0) {
292-
const uint8_t* data = reinterpret_cast<const uint8_t*>(buffer);
293-
const String::NewStringType type = String::kNormalString;
294-
Local<String> path =
295-
String::NewFromOneByte(args.GetIsolate(), data, type, size);
296-
Environment* env = Environment::GetCurrent(args);
297-
Local<Object> out = args[0].As<Object>();
298-
out->Set(env->address_string(), path);
299-
out->Set(env->family_string(), env->pipe_string());
300-
}
301-
args.GetReturnValue().Set(err);
302-
}
303-
304-
305279
} // namespace node
306280

307281
NODE_MODULE_CONTEXT_AWARE_BUILTIN(pipe_wrap, node::PipeWrap::Initialize)
Collapse file

‎src/pipe_wrap.h‎

Copy file name to clipboardExpand all lines: src/pipe_wrap.h
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ class PipeWrap : public StreamWrap {
3030
static void Connect(const v8::FunctionCallbackInfo<v8::Value>& args);
3131
static void Open(const v8::FunctionCallbackInfo<v8::Value>& args);
3232

33-
template <int (*F)(const uv_pipe_t*, char*, size_t*)>
34-
static void GetSockOrPeerName(const v8::FunctionCallbackInfo<v8::Value>&);
35-
3633
#ifdef _WIN32
3734
static void SetPendingInstances(
3835
const v8::FunctionCallbackInfo<v8::Value>& args);
Collapse file

‎test/common.js‎

Copy file name to clipboardExpand all lines: test/common.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Object.defineProperty(exports, 'hasCrypto', {get: function() {
134134
}});
135135

136136
if (exports.isWindows) {
137-
exports.PIPE = '\\\\?\\pipe\\libuv-test';
137+
exports.PIPE = '\\\\.\\pipe\\libuv-test';
138138
} else {
139139
exports.PIPE = exports.tmpDir + '/test.sock';
140140
}
Collapse file

‎test/parallel/test-cluster-http-pipe.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-cluster-http-pipe.js
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ if (cluster.isMaster) {
2929
}
3030

3131
http.createServer(function(req, res) {
32-
assert.equal(req.connection.remoteAddress, '');
33-
assert.equal(req.connection.remoteFamily, 'pipe');
34-
assert.equal(req.connection.remotePort, undefined);
35-
assert.equal(req.connection.localAddress, common.PIPE);
36-
assert.equal(req.connection.localFamily, 'pipe');
37-
assert.equal(req.connection.localPort, undefined);
32+
assert.equal(req.connection.remoteAddress, undefined);
33+
assert.equal(req.connection.localAddress, undefined); // TODO common.PIPE?
3834
res.writeHead(200);
3935
res.end('OK');
4036
}).listen(common.PIPE, function() {
Collapse file

‎test/parallel/test-http-unix-socket.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-unix-socket.js
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var headers_ok = false;
99
var body_ok = false;
1010

1111
var server = http.createServer(function(req, res) {
12-
assert.equal(req.socket.address().address, common.PIPE);
1312
res.writeHead(200, {
1413
'Content-Type': 'text/plain',
1514
'Connection': 'close'
@@ -20,7 +19,6 @@ var server = http.createServer(function(req, res) {
2019
});
2120

2221
server.listen(common.PIPE, function() {
23-
assert.equal(server.address().address, common.PIPE);
2422

2523
var options = {
2624
socketPath: common.PIPE,
Collapse file

‎test/sequential/test-pipe-address.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-pipe-address.js
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ server.listen(common.PIPE, function() {
1515
});
1616

1717
process.on('exit', function() {
18-
assert.equal(address.address, common.PIPE);
19-
assert.equal(address.family, 'pipe');
18+
assert.equal(address, common.PIPE);
2019
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.