diff --git a/lib/request.js b/lib/request.js index 18f0f75..911009f 100644 --- a/lib/request.js +++ b/lib/request.js @@ -307,7 +307,7 @@ Request.prototype = { */ get ip() { - return this.ips[0] || this.connection.remoteAddress; + return this.ips[0] || this.socket.remoteAddress; }, /** diff --git a/lib/response.js b/lib/response.js index 479e7fc..a63245d 100644 --- a/lib/response.js +++ b/lib/response.js @@ -42,6 +42,18 @@ function Response(ctx){ Response.prototype = { + /** + * Return the request socket. + * + * @return {Connection} + * @api public + */ + + get socket() { + // TODO: TLS + return this.ctx.req.socket; + }, + /** * Return response header. *