Giter Site home page Giter Site logo

spf2ip's People

Contributors

nathandines avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

cschramm simonvik

spf2ip's Issues

Is this syntax supported?

I just saw this in an spf record:

# dig -t TXT sendgrid.com|grep spf1
sendgrid.com.		264	IN	TXT	"v=spf1 include:sendgrid.com._nspf.vali.email include:%{i}._ip.%{h}._ehlo.%{d}._spf.vali.email include:stspg-customer.com ~all"

So I started searching in https://tools.ietf.org/html/rfc7208 and lo and behold: 7.3. Macro Processing Details show there is a complete macro processing ruleset in spf. Is that supported in SPF2IP?

spf2ip fails on certain domains.

For example:

# SPF2IP --domain linkedin.com --ip-version 4
Traceback (most recent call last):
  File "/usr/local/bin/SPF2IP", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/SPF2IP.py", line 169, in main
    for ip in lookup.IPArray(args.ip_version):
  File "/usr/local/lib/python3.6/dist-packages/SPF2IP.py", line 70, in IPArray
    NewIncludes = self.FindIncludes(domain)
  File "/usr/local/lib/python3.6/dist-packages/SPF2IP.py", line 84, in FindIncludes
    entries = self.GetSPFArray(domain)
  File "/usr/local/lib/python3.6/dist-packages/SPF2IP.py", line 94, in GetSPFArray
    results = dns_request_unicode(domain,'TXT')
  File "/usr/local/lib/python3.6/dist-packages/SPF2IP.py", line 17, in dns_request_unicode
    result = dns.resolver.query(hostname,record_type,*args,**kwargs)
  File "/usr/local/lib/python3.6/dist-packages/dns/resolver.py", line 1223, in query
    True)
  File "/usr/local/lib/python3.6/dist-packages/dns/resolver.py", line 1207, in resolve
    lifetime, search)
  File "/usr/local/lib/python3.6/dist-packages/dns/resolver.py", line 1040, in resolve
    (nameserver, port, tcp, backoff) = resolution.next_nameserver()
  File "/usr/local/lib/python3.6/dist-packages/dns/resolver.py", line 598, in next_nameserver
    raise NoNameservers(request=self.request, errors=self.errors)
dns.resolver.NoNameservers: All nameservers failed to answer the query linkedin.com. IN TXT: Server 10.10.10.11 UDP port 53 answered ; Server 10.10.10.11 TCP port 53 answered [Errno 111] Connection refused; Server 10.10.10.12 UDP port 53 answered ; Server 10.10.10.12 TCP port 53 answered [Errno 111] Connection refused

I somewhat suspect this problem might be caused by the unbound nameservers that don't like all these recursions, but I checked the config and rate limiting is disabled. So my question is, can you repeat this or is this a local problem?

Broken on 3.6

The current code always returns an empty answer on Python 3.6. This fixes it for me:

diff --git a/SPF2IP.py b/SPF2IP.py
index e6210f3..84683ff 100644
--- a/SPF2IP.py
+++ b/SPF2IP.py
@@ -34,7 +34,7 @@ def dns_request_unicode(hostname,record_type,*args,**kwargs):
         value = value.__str__().encode('utf-8').decode('utf-8')
       output.append(value)
     elif record_type == "TXT":
-      value = ''.join([str(ent) for ent in entry.strings])
+      value = ''.join([str(ent, encoding='ascii') for ent in entry.strings])
       if type(value) is not unicode:
         value = value.decode('utf-8')
       output.append(value)

I only know python3 so I can't give good advice on making code that works on both 2 and 3. But a friend of mine's package has this function that you might find useful:

def to_native_str(value, encoding='utf-8'):
    if isinstance(value, str):
        return value

    if six.PY3 and isinstance(value, six.binary_type):  #pragma: no cover                                                                                      
        return value.decode(encoding)
    elif six.PY2 and isinstance(value, six.text_type):  #pragma: no cover                                                                                      
        return value.encode(encoding)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.