Open mzdk100 opened 3 months ago
It is currently not possible to do this in general. The connection could be non ip-based, like for example in-memory.
For a network-based connection like a quinn connection you could add this, but so far we have not seen a need to do so.
Can we implement a similar interface function 'get_remote_addr()' on RpcChannel? If it is an in memory connection, calling this function can be an undefined behavior. Because I need to track the IP address requested by the user.
I think it should be possible to write your own struct, let's say MyServerEndpoint
, that stores a QuinnServerEndpoint
and implements the ServerEndpoint
trait.
This way you can intercept quinn's Incoming
values from its accept
function, and you thus get access to its remote_address
.
This doesn't help you get the IP address information to the RPC service interfaces, but it's good enough for e.g. IP address allow-listing.
Do you have any specific examples?
You could take a look at the QuinnServerEndpoint
implementation for ServerEndpoint
.
Otherwise to get a feeling for ServerEndpoint
, you can look at the source code for the memory-based implementations, too.
I don't have a specific example for you're asking for right now :/
How to determine which remote host (Remote IP Address) a request comes from?