Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
401 stars 143 forks source link

Question: Can I get IP of a user that is connecting to my AMQP Broker? #473

Closed gorazspajzer closed 3 years ago

gorazspajzer commented 3 years ago

HI!

I have public class CBroker : IContainer and I would like to get user IP in method Link IContainer.CreateLink(ListenerConnection connection, ListenerSession session, Attach attach)

Or maybe in my class sealed class APISaslProfile : SaslProfile, IAuthenticated in method SaslCode ValidateCredentials(SaslInit init)

I tried to find a way to get client IP but without success :(

Any thoughts? any suggestions?

Thenx!

Gorazd

xinchen10 commented 3 years ago

This information is not exposed today. We can look into a way to expose that. Should not be too difficult.

xinchen10 commented 3 years ago

With ffc33658b59e57493cd4beb8fdb82d97bbafa203, transport objects are exposed to IHandler implementation. When you create the ConnectionListener, provide a HandlerFactory. The implementation will get notified for events and it can handle those of interests. In this scenario, you would be interested in the following events:

If you need extra information from the client to make a decision, you can set some custom properties (e.g. the IP address) in ListenerConnection.Properties in ConnectionAccept, and then handle the following event,

gorazspajzer commented 3 years ago

The speed of response shocked me in a positive way!!! Thanx!!!!!