简体   繁体   English

RPC窗口获取客户端IP地址

[英]RPC windows get client IP address

I have read loads of Microsoft documentation regarding RPC programming and still do not figure out how do we get from RPC server the IP address of the connecting client. 我已经阅读了大量关于RPC编程的Microsoft文档 ,但仍然没有弄清楚我们如何从RPC服务器获取连接客户端的IP地址。

I am sure there is a simple way to get client IP address from server when connecting, but do not know how to do this :/ 我确信有一种简单的方法可以在连接时从服务器获取客户端IP地址,但不知道如何执行此操作:/

Thanks for helping, a simple pointer to a documentation would be great. 感谢您的帮助,一个指向文档的简单指针会很棒。

No - there is no documented way to accomplish this. 不 - 没有记录的方法来实现这一目标。 Windows RPC by design abstracts the network transport (and associated metadata like network addresses) from it's clients. Windows RPC by design从其客户端抽象出网络传输(以及网络地址等相关元数据)。

If you really need something like this, you could bake it into your interface (eg implement a Connect() method where your client provides it's IP address that you could stash in a Context Handle ). 如果你真的需要这样的东西,你可以将它烘焙到你的界面中(例如实现一个Connect()方法,你的客户端提供它可以隐藏在Context Handle中的IP地址)。 This assumes of course, that you can trust your clients to provide valid IP addresses... 当然,这假定您可以信任您的客户提供有效的IP地址......

It should be possible using RpcBindingServerFromClient. 应该可以使用RpcBindingServerFromClient。 Quoting documentation for RpcBindingServerFromClient : 引用RpcBindingServerFromClient的文档:

To query a client's address, an application starts by calling the RpcBindingServerFromClient function to obtain a partially bound server binding handle. 要查询客户端的地址,应用程序首先调用RpcBindingServerFromClient函数以获取部分绑定的服务器绑定句柄。 The server binding handle can be used to obtain a string binding by invoking RpcBindingToStringBinding. 服务器绑定句柄可用于通过调用RpcBindingToStringBinding来获取字符串绑定。 The server can then call RpcStringBindingParse to extract the client's network address from the string binding. 然后,服务器可以调用RpcStringBindingParse从字符串绑定中提取客户端的网络地址。

UPDATE 16/05/2017: There is also undocumented function I_RpcServerInqRemoteConnAddress() that most likely return client IP address. 更新16/05/2017:还有未记录的函数I_RpcServerInqRemoteConnAddress(),它最有可能返回客户端IP地址。 But I didn't try it yet. 但我还没试过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM