我使用grpc-java并通过ServerInterceptor获取元数据,但是我在没有客户端IP地址的情况下获取了以下信息,权限是服务器ip,如何获得客户端ip?
元数据({:scheme = [http] 、: method = [POST] 、: path = [/ test / test1] 、: authority = [192.168.199.9:50051],grpc-encoding = [identity],grpc-accept-编码= [身份,放气,gzip],te = [预告片],内容类型= [应用程序/ grpc],用户代理= [grpc-objc / 0.13.0 grpc-c / 0.13.0(ios)]} )
如果在 python grpc 中,您将使用 获取客户端 IP 地址和端口context.peer()。
def your_method(self, request, context):
...
context.peer() # return 'ipv4:49.123.106.100:44420'
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5953 次 |
| 最近记录: |