anyproxy icon indicating copy to clipboard operation
anyproxy copied to clipboard

hi, 请问我如何获取client IP?

Open irich8 opened this issue 7 years ago • 11 comments
trafficstars

AnyProxy 4.x 在rule中,如何能够获取到通过anyproxy代理的client ip? 谢谢。

irich8 avatar Mar 25 '18 15:03 irich8

在AnyProxy的接口 beforeSendRequest 中,通过_req将request对象返回, 这是原始的http request 对象,可以通过它来获取client ip, 似乎是 request.connection.remoteAddress?

codingfishman avatar Mar 28 '18 12:03 codingfishman

我测试是req._req.socket.remoteAddressreq._req.connection.remoteAddress都可以呢

huhuang03 avatar Apr 10 '18 02:04 huhuang03

请问如果是https代理。拿到的都是127.0.0.1怎么办?@codingfishman

原来和 #339 一样啊

huhuang03 avatar Apr 13 '18 06:04 huhuang03

requestDetail._req.socket.remoteAddress

KyleQiao1992 avatar Apr 19 '18 10:04 KyleQiao1992

@KyleQiao1992 我看到你提的issue也是https拿到127.0.0.1。我也碰到这个问题,请问你解决了吗。

huhuang03 avatar Apr 20 '18 09:04 huhuang03

@huhuang03 没有

KyleQiao1992 avatar Apr 20 '18 10:04 KyleQiao1992

请问这个问题解决了嘛?

luoshangyu avatar Aug 07 '18 03:08 luoshangyu

This problem is not solved. https requests show the ip as ::ffff:127.0.0.1

a normal node https request will show the real remote address

vitamindck avatar Aug 06 '19 19:08 vitamindck

this problem kill my so many time... there is a funciton called 'beforeDealHttpsRequest(req)' you can get currentip with req._req.connection.remoteAddress. and more, this function must return true

goddkiller avatar Feb 24 '20 02:02 goddkiller

for function beforeSendRequest(req).using the "req._req.connection.remoteAddress" gives the loopback address(127.0.01) however in function beforeDealHttpsRequest(req) the "req._req.connection.remoteAddress" gives right address

dawoodaijaz97 avatar Feb 29 '20 22:02 dawoodaijaz97

for function beforeSendRequest(req).using the "req._req.connection.remoteAddress" gives the loopback address(127.0.01) however in function beforeDealHttpsRequest(req) the "req._req.connection.remoteAddress" gives right address

U r right. And futher more, i read the source code. If the request's protocol is https , anyproxy will start a new request to the target host, which will passed to the function beforeSendRequest. That is why the remoteAddress is 127.0.0.1.

goddkiller avatar Mar 09 '20 01:03 goddkiller