|
58 | 58 | from .whoisParser import WhoisParser |
59 | 59 |
|
60 | 60 | log = logging.getLogger(__name__) |
61 | | -logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO")) |
62 | 61 |
|
63 | 62 | HAS_REDIS = False |
64 | 63 | try: |
@@ -197,21 +196,31 @@ def q2( |
197 | 196 | pc: ParameterContext, |
198 | 197 | ) -> Domain | None: |
199 | 198 | if pc.verbose is True: |
200 | | - os.putenv("LOGLEVEL", "DEBUG") |
201 | | - os.environ["LOGLEVEL"] = "DEBUG" |
202 | 199 | logging.basicConfig(level="DEBUG") |
203 | 200 |
|
204 | 201 | gc.collect(0) |
205 | 202 | gc.collect(1) |
206 | 203 | gc.collect(2) |
207 | 204 |
|
208 | | - initLastWhois() |
209 | | - |
210 | 205 | dc = DataContext( |
211 | 206 | domain=domain, |
212 | 207 | hasLibTld=TLD_LIB_PRESENT, |
213 | 208 | ) |
214 | 209 |
|
| 210 | + wr = WhoisRdap() |
| 211 | + dd = wr.do_one_domain(domain) |
| 212 | + if dd.status: |
| 213 | + with_rdap_whois = True |
| 214 | + d: dict[str, Any] = wr.map_data_to_whoisdomain(dd.data, with_rdap_whois=with_rdap_whois) |
| 215 | + rr = Domain(pc=pc, dc=dc) |
| 216 | + rr.from_whodap_dict(d) |
| 217 | + msg = f"lookup: {domain} using whodap" |
| 218 | + log.info(msg) |
| 219 | + return rr # also show the raw data from whodap |
| 220 | + log.warning(dd) # no proper answer from rdap try whois |
| 221 | + |
| 222 | + initLastWhois() |
| 223 | + |
215 | 224 | dom = Domain( |
216 | 225 | pc=pc, |
217 | 226 | dc=dc, |
@@ -250,68 +259,90 @@ def q2( |
250 | 259 | return result |
251 | 260 |
|
252 | 261 |
|
| 262 | +# force: bool = False, |
| 263 | +# cache_file: str | None = None, |
| 264 | +# cache_age: int = 60 * 60 * 48, |
| 265 | +# slow_down: int = 0, |
| 266 | +# ignore_returncode: bool = False, |
| 267 | +# server: str | None = None, |
| 268 | +# verbose: bool = False, |
| 269 | +# with_cleanup_results: bool = False, |
| 270 | +# internationalized: bool = False, |
| 271 | +# include_raw_whois_text: bool = False, |
| 272 | +# return_raw_text_for_unsupported_tld: bool = False, |
| 273 | +# timeout: float | None = None, |
| 274 | +# parse_partial_response: bool = False, |
| 275 | +# cmd: str = "whois", |
| 276 | +# simplistic: bool = False, |
| 277 | +# withRedacted: bool = False, |
| 278 | +# tryInstallMissingWhoisOnWindows: bool = False, |
| 279 | +# shortResponseLen: int = 5, |
| 280 | +# withPublicSuffix: bool = False, |
| 281 | +# extractServers: bool = False, |
| 282 | +# stripHttpStatus: bool = False, |
| 283 | +# noIgnoreWww: bool = False, |
| 284 | + |
| 285 | + |
253 | 286 | def query( |
254 | 287 | domain: str, |
255 | 288 | *, |
256 | | - force: bool = False, |
257 | | - cache_file: str | None = None, |
258 | | - cache_age: int = 60 * 60 * 48, |
259 | | - slow_down: int = 0, |
260 | | - ignore_returncode: bool = False, |
261 | | - server: str | None = None, |
262 | | - verbose: bool = False, |
263 | | - with_cleanup_results: bool = False, |
264 | | - internationalized: bool = False, |
265 | | - include_raw_whois_text: bool = False, |
266 | | - return_raw_text_for_unsupported_tld: bool = False, |
267 | | - timeout: float | None = None, |
268 | | - parse_partial_response: bool = False, |
269 | | - cmd: str = "whois", |
270 | | - simplistic: bool = False, |
271 | | - withRedacted: bool = False, |
272 | 289 | pc: ParameterContext | None = None, |
273 | | - tryInstallMissingWhoisOnWindows: bool = False, |
274 | | - shortResponseLen: int = 5, |
275 | | - withPublicSuffix: bool = False, |
276 | | - extractServers: bool = False, |
277 | | - stripHttpStatus: bool = False, |
278 | | - noIgnoreWww: bool = False, |
279 | | - # if you use pc as argument all above params (except domain are ignored) |
| 290 | + verbose: bool = False, |
| 291 | + **kwargs: Any, |
| 292 | + # force: bool = False, |
| 293 | + # cache_file: str | None = None, |
| 294 | + # cache_age: int = 60 * 60 * 48, |
| 295 | + # slow_down: int = 0, |
| 296 | + # ignore_returncode: bool = False, |
| 297 | + # server: str | None = None, |
| 298 | + # with_cleanup_results: bool = False, |
| 299 | + # internationalized: bool = False, |
| 300 | + # include_raw_whois_text: bool = False, |
| 301 | + # return_raw_text_for_unsupported_tld: bool = False, |
| 302 | + # timeout: float | None = None, |
| 303 | + # parse_partial_response: bool = False, |
| 304 | + # cmd: str = "whois", |
| 305 | + # simplistic: bool = False, |
| 306 | + # withRedacted: bool = False, |
| 307 | + # tryInstallMissingWhoisOnWindows: bool = False, |
| 308 | + # shortResponseLen: int = 5, |
| 309 | + # withPublicSuffix: bool = False, |
| 310 | + # extractServers: bool = False, |
| 311 | + # stripHttpStatus: bool = False, |
| 312 | + # noIgnoreWww: bool = False, |
280 | 313 | ) -> Domain | None: |
281 | 314 | # see documentation about paramaters in parameterContext.py |
282 | 315 |
|
283 | 316 | assert isinstance(domain, str), Exception("`domain` - must be <str>") |
284 | 317 |
|
285 | 318 | if verbose is True: |
286 | | - os.putenv("LOGLEVEL", "DEBUG") |
287 | | - os.environ["LOGLEVEL"] = "DEBUG" |
288 | 319 | logging.basicConfig(level="DEBUG") |
289 | 320 |
|
290 | 321 | if pc is None: |
291 | | - pc = ParameterContext( |
292 | | - force=force, |
293 | | - cache_file=cache_file, |
294 | | - cache_age=cache_age, |
295 | | - slow_down=slow_down, |
296 | | - ignore_returncode=ignore_returncode, |
297 | | - server=server, |
298 | | - verbose=verbose, |
299 | | - with_cleanup_results=with_cleanup_results, |
300 | | - internationalized=internationalized, |
301 | | - include_raw_whois_text=include_raw_whois_text, |
302 | | - return_raw_text_for_unsupported_tld=return_raw_text_for_unsupported_tld, |
303 | | - timeout=timeout, |
304 | | - parse_partial_response=parse_partial_response, |
305 | | - cmd=cmd, |
306 | | - simplistic=simplistic, |
307 | | - withRedacted=withRedacted, |
308 | | - withPublicSuffix=withPublicSuffix, |
309 | | - shortResponseLen=shortResponseLen, |
310 | | - tryInstallMissingWhoisOnWindows=tryInstallMissingWhoisOnWindows, |
311 | | - extractServers=extractServers, |
312 | | - stripHttpStatus=stripHttpStatus, |
313 | | - noIgnoreWww=noIgnoreWww, |
314 | | - ) |
| 322 | + pc = ParameterContext(**kwargs) |
| 323 | + # force=force, |
| 324 | + # cache_file=cache_file, |
| 325 | + # cache_age=cache_age, |
| 326 | + # slow_down=slow_down, |
| 327 | + # ignore_returncode=ignore_returncode, |
| 328 | + # server=server, |
| 329 | + # verbose=verbose, |
| 330 | + # with_cleanup_results=with_cleanup_results, |
| 331 | + # internationalized=internationalized, |
| 332 | + # include_raw_whois_text=include_raw_whois_text, |
| 333 | + # return_raw_text_for_unsupported_tld=return_raw_text_for_unsupported_tld, |
| 334 | + # timeout=timeout, |
| 335 | + # parse_partial_response=parse_partial_response, |
| 336 | + # cmd=cmd, |
| 337 | + # simplistic=simplistic, |
| 338 | + # withRedacted=withRedacted, |
| 339 | + # withPublicSuffix=withPublicSuffix, |
| 340 | + # shortResponseLen=shortResponseLen, |
| 341 | + # tryInstallMissingWhoisOnWindows=tryInstallMissingWhoisOnWindows, |
| 342 | + # extractServers=extractServers, |
| 343 | + # stripHttpStatus=stripHttpStatus, |
| 344 | + # noIgnoreWww=noIgnoreWww, |
| 345 | + # ) |
315 | 346 |
|
316 | 347 | msg = f"{pc}" |
317 | 348 | log.debug(msg) |
|
0 commit comments