问题
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