Clean the hosts.txt file of any duplicate IP addresses
(self)
| 154 | lib.settings.cmdline(command, is_msf=False) |
| 155 | |
| 156 | def do_clean_hosts(self): |
| 157 | """ |
| 158 | Clean the hosts.txt file of any duplicate IP addresses |
| 159 | """ |
| 160 | retval = set() |
| 161 | current_size = len(self.loaded_hosts) |
| 162 | for host in self.loaded_hosts: |
| 163 | retval.add(host) |
| 164 | cleaned_size = len(retval) |
| 165 | with open(lib.settings.HOST_FILE, 'w') as hosts: |
| 166 | for item in list(retval): |
| 167 | hosts.write(item) |
| 168 | if current_size != cleaned_size: |
| 169 | lib.output.info("cleaned {} duplicate IP address(es) (total of {})".format( |
| 170 | current_size - cleaned_size, cleaned_size |
| 171 | ) |
| 172 | ) |
| 173 | self.__reload() |
| 174 | |
| 175 | def do_token_reset(self, api, token, username): |
| 176 | """ |
no test coverage detected