0

I am trying to follow this example:
https://docs.ar-soft.de/arsoft.tools.net/#SPF%20SenderIP%20Validation.html

var validator = new SpfValidator()
{
    HeloDomain = DomainName.Parse("example.com"),
    LocalDomain = DomainName.Parse("receivingmta.example.com"),
    LocalIP = IPAddress.Parse("192.0.2.1")
};

SpfQualifier result = validator.CheckHost(IPAddress.Parse("192.0.2.200"), 
DomainName.Parse("example.com"), "sender@example.com").Result; 

However, no matter what IPs and urls I use, CheckHost() method does not finish.

Does anybody know the correct use, or example input parameters for which this would complete?

I would expect an exception if inputs are invalid.

user5226582
  • 1,946
  • 1
  • 22
  • 37
  • 1
    I have just tested the code in VS 2013 on .NET 4.5 without problems. You can try to remove the Object Initializers from the constructor call, in case the LocalIP property has an effect on which IP the DNS requests are sent from. Without the Initializers the LocalIP should be set to the first IP of the computer. I got the same result from my test with and without the initializers. – Lars Lind Nilsson Nov 10 '16 at 15:03
  • Thank you. Did you use "example.com" and "192.0.2.200" or different values? I switched to CheckHostAsync(), which returns a "TempError" response after about 10 seconds. CheckHost() on the other hand seems to never finish. (Removing Object Initialisers did not help) – user5226582 Nov 10 '16 at 15:15
  • 1
    I first tried with the exact values from your code and received a Fail result, which makes sense since example.com's SPF only has "-all". I then tried with other values and got both PermError and SoftFail results (which I believe was correct with the values I used). I tried using WireShark to see which DNS requests were sent, and I saw the requests and answers I expected. – Lars Lind Nilsson Nov 10 '16 at 15:24
  • 1
    Thank you. I found https://interpcspf.codeplex.com/ which returns results consistent with yours. Will use that instead. – user5226582 Nov 10 '16 at 15:43
  • 1
    I have the same issue. Console app no problem. IIS app it' stuck with same parameters ... Did domaone find the solution ? – MichaelD Feb 17 '18 at 13:35
  • @MichaelD do you have to use the ARSoft implementation? – user5226582 Feb 20 '18 at 12:14
  • @user5226582 , I now also used the https://interpcspf.codeplex.com/ solution. This one works as a charm! – MichaelD Feb 25 '18 at 12:45

1 Answers1

1

You're using it the same way I'm using it. It works for perfectly for me. Maybe you have something in your firewall blocking it from performing the look up queries?

Henry
  • 2,953
  • 2
  • 21
  • 34