alanmcgovern / Mono.Nat

UPNP and NAT-PMP port forwarding for .NET
https://github.com/mono/Mono.Nat
MIT License
160 stars 156 forks source link

[Feature Request] Expose ISearcher and the searcher types or something similar publicly for DI (among other things) #36

Open nike4613 opened 3 years ago

nike4613 commented 3 years ago

I am currently working on an application which uses uPNP to open ports for P2P communication. I am using DI quite heavily, and would like to be able to inject the uPNP searcher through that, rather than going through the global. Because I need to perform operations based primarily on the capabilities of the network adapter, I am currently manually polling with NatUtility.Search(gatewayIp), using the gateway I've identified for the interface I'm targeting.

In addition, having a public API that does not have global state makes it much easier to test around, as well as being easier to write code with thread-safety.

Of course, I could also just be missing something that is already present that does exactly this. 😄