Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to obtain remote ip? #91

Open
mzdk100 opened this issue Aug 2, 2024 · 5 comments
Open

How to obtain remote ip? #91

mzdk100 opened this issue Aug 2, 2024 · 5 comments

Comments

@mzdk100
Copy link

mzdk100 commented Aug 2, 2024

How to determine which remote host (Remote IP Address) a request comes from?

@rklaehn
Copy link
Collaborator

rklaehn commented Aug 15, 2024

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.

@mzdk100
Copy link
Author

mzdk100 commented Aug 15, 2024

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.

@matheus23
Copy link
Contributor

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.

@mzdk100
Copy link
Author

mzdk100 commented Aug 15, 2024

Do you have any specific examples?

@matheus23
Copy link
Contributor

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 :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants