How to get client's IP in a golang thrift server

北战南征 提交于 2020-01-17 07:47:17

问题


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:


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.



来源:https://stackoverflow.com/questions/44962798/how-to-get-clients-ip-in-a-golang-thrift-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!