X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FPlcapiUrlScanner.py;h=c790bd99ca2f7c1c3669927758d6c323744e494e;hb=dd5d5e99fe22b11fa9e2878172fd62515fd0b5bd;hp=d76355771c89ad84527460873da6be55d8ae36c7;hpb=074c867df244b46e3b0897744677ba4f2c0b61e8;p=tests.git diff --git a/system/PlcapiUrlScanner.py b/system/PlcapiUrlScanner.py index d763557..c790bd9 100755 --- a/system/PlcapiUrlScanner.py +++ b/system/PlcapiUrlScanner.py @@ -37,24 +37,26 @@ class PlcapiUrlScanner: print '... (http error %s)'%e.errcode,url return False except Exception as e: - print '---',type(e).__name__,url + print '---',type(e).__name__,url,e if self.verbose: traceback.print_exc() return False - def try_url_expected (self, url, expected): - return self.try_url(url)==expected + def try_url_required (self, url, required): + result=self.try_url(url) + if required and not result: return False + else: return True def scan(self): overall=True for protocol in ['http','https']: - expected= protocol=='https' for dest in [ self.hostname, self.ip ]: for port in [ '',':80',':443']: for path in ['PLCAPI','PLCAPI/']: if protocol=='http' and port==':443': continue if protocol=='https' and port==':80': continue + required = (protocol=='https') and (path=='PLCAPI/') url="%s://%s%s/%s"%(protocol,dest,port,path) - if not self.try_url_expected (url,expected): overall=False + if not self.try_url_required (url,required): overall=False return overall from optparse import OptionParser