英文:
How to get client's IP in a golang thrift server
问题
我正在使用golang编写一个thrift服务,我想了解如何在处理函数的上下文中获取客户端的IP地址。
谢谢,祝好。
英文:
I'm writing a thrift service in golang and I would like to understand how I can get the client's IP address in the handler functions context.
Thanks, Love.
答案1
得分: 1
我认为你正在使用这个Godoc Thrift库。在你的问题中包含代码片段会很好,比如thrift server
的类型、handler
的定义等等。
根据Thrift Go 库文档的描述:
func (p *TSocket) Addr() net.Addr
返回套接字的远程地址。
所以如果你可以访问TSocket
,你就可以获取远程地址。
英文:
I think you're using this Godoc Thrift library. It would be good to have code snippets in your question; such as type of thrift server
, handler
definition, etc.
As per Thrift Go library doc-
> func (p *TSocket) Addr() net.Addr
>
> Returns the remote address of the socket.
So if you have access to TSocket
then you can get remote address.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论