Proxy Anonymity Detector
Detect the proxy's anonymity
Features
Detect the anonymity or proxy
Detect from request object
Installation
pip install -U proxyAnonymityDetector
Usage
from ProxyAnonymityDetector import Detector as AnonymityDetector, Request as DetectorRequest
# detect anonymity
# # no or elite proxy
detector = AnonymityDetector({' REMOTE_ADDR' : ' 128.101.101.101' })
print (detector.using_proxy) # probably
print (detector.anonymity) # ['no', 'elite']
# # no proxy
detector = AnonymityDetector({' REMOTE_ADDR' : ' 128.101.101.101' }, real_ip_address = ' 128.101.101.101' )
print (detector.using_proxy) # no
print (detector.anonymity) # ['no']
# # elite proxy
detector = AnonymityDetector({' REMOTE_ADDR' : ' 128.101.101.101' }, real_ip_address = ' 128.101.101.100' )
print (detector.using_proxy) # yes
print (detector.anonymity) # ['elite']
# transparent or anonymous proxy
detector = AnonymityDetector({
' REMOTE_ADDR' : ' 128.101.101.102' ,
' HTTP_VIA' : ' 1.1 128.101.101.102' ,
' HTTP_X_FORWARD_FOR' : ' 128.101.101.101'
})
print (detector.anonymity) # ['anonymous', 'transparent']
# # anonymous proxy
detector = AnonymityDetector({
' REMOTE_ADDR' : ' 128.101.101.102' ,
' HTTP_VIA' : ' 1.1 128.101.101.101, 1.1 128.101.101.102' ,
' HTTP_X_FORWARD_FOR' : ' 128.101.101.101, 128.101.101.102'
}, ' 128.101.101.100)
print (detector.anonymity) # ['anonymous']
# # transparent proxy
detector = AnonymityDetector({
' REMOTE_ADDR' : ' 128.101.101.102' ,
' HTTP_VIA' : ' 1.1 128.101.101.100, 1.1 128.101.101.102' ,
' HTTP_X_FORWARD_FOR' : ' 128.101.101.100, 128.101.101.102'
}, ' 128.101.101.100' )
print (detector.anonymity) # ['transparent']
# use DetectorRequest to detect framework request
# # set field
request = DetectorRequest()
request.remote_addr = ' 128.101.101.101'
request.http_via = ' 128.101.101.101'
request.http_x_forwarded_for = ' 128.101.101.101'
# # use dict to init
request = DetectorRequest({
' REMOTE_ADDR' : ' 128.101.101.102' ,
' HTTP_VIA' : ' 1.1 128.101.101.102' ,
' HTTP_X_FORWARD_FOR' : ' 128.101.102.101, 128.101.201.101'
})
# # from bottle request
request = DetectorRequest.from_bottle(bottle.request)
# # from flask request
request = DetectorRequest.from_flask(flask.request)
# detect with DetectorRequest
# # create new detector
request = DetectorRequest.from_bottle(bottle.request)
detector = AnonymityDetector(request)
print (detector.anonymity)
# # use class method
request = DetectorRequest.from_bottle(bottle.request)
print (AnonymityDetector.detect(request, ' 128.101.101.101' ))
License
MIT license
References
HTTP_VIA
X_FORWARDED_FOR