如何在Golang节俭服务器中获取客户端的IP [英] How to get client's IP in a golang thrift server
本文介绍了如何在Golang节俭服务器中获取客户端的IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用golang写一个节俭服务,我想了解如何在处理程序函数上下文中获取客户端的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.
谢谢,爱.
推荐答案
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.
根据Thrift Go 图书馆文档-
As per Thrift Go library doc-
func(p * TSocket)Addr()net.Addr
func (p *TSocket) Addr() net.Addr
返回套接字的远程地址.
Returns the remote address of the socket.
因此,如果您有权访问 TSocket
,则可以获取远程地址.
So if you have access to TSocket
then you can get remote address.
这篇关于如何在Golang节俭服务器中获取客户端的IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文