Commit Graph

858 Commits

Author SHA1 Message Date
Clemens Klein-Robbenhaar ed332bcb9e Add support for DNS-over-HTTPS lookups
- scrap setter for "enableDnsOverHttpResolve", too
2022-04-09 23:26:07 +02:00
Clemens Klein-Robbenhaar fdde6d87a0 Add support for DNS-over-HTTPS lookups
- instead of "borrowing" the configured proxy from
  the fetchHttp bean, use proxy values defined via
  global options, to avoid interference with other
  jobs running in parallel (or at least make them
  explicit).
  The "fetchHttp" bean also uses these settings,
  if no bean specific settings are used.
- remove the "enableDnsOverHttpResolves", and rely
  on a non-empty "dnsOverHttpServer" value to signal
  that DoH should be used.
2022-04-09 23:04:37 +02:00
Clemens Klein-Robbenhaar 2144abb2cb Add support for DNS-over-HTTPS lookups
- use the "DohResolver" from the dnsjava library
  to make DoH lookups
- to enable and configure it, add two new
  properties
  * "enableDnsOverHttpResolves" (boolean)
  * "dnsOverHttpServer" URL to the DoH Server
- as one use case for DoH is being located
  behind a firewall, also support using a proxy
  to access the DoH server; the proxy from
  the FetchHTTP bean is reused in that case

Fixes #211
2022-04-08 11:48:52 +02:00
Alex Osborne 971f04dd23 TransclusionDecideRule: Don't treat sitemap links ('M') as transclusions
We should only crawl sitemaps and sitemap links if they are in the
primary SURT scope. Otherwise we'll start crawling the sitemaps of
every site an embedded resource is pulled in from even when they
should be out of scope.

Fixes #469
2022-03-28 13:47:49 +09:00
Alex Osborne d796491995 FetchHTTPTest: Fix SOCKS server startup race
testSocksProxy() is failing on the GitHub action CI runs but I can't
reproduce the issue locally. I'm just guessing this is what's causing it
but this should be fixed anyway to avoid future intermittent failures.
2022-03-28 13:26:53 +09:00
Alex Osborne 0dc05408da FetchHTTPTest: Don't test IP binding on macOS utun network interfaces
This avoids a test failure on macOS machines that are running Wireguard.
2022-03-28 11:40:48 +09:00
Alex Osborne 0d6c04fda5 FetchHTTPTest: Update to junit 4
By replacing the custom TestSuite with junit 4 @BeforeClass and
@AfterClass annotations running individual tests by themselves now works
correctly.

Since FetchHTTPTest now just contains the utility code for the test
servers we rename it to FetchHTTPTestServers. FetchHTTPTests (which
contains the actual tests) can now follow the standard naming
scheme as FetchHTTPTest.
2022-03-28 11:35:45 +09:00
Jamie Hoyle dd01689ace FetchHTTP: SOCKS5 proxy support
Closes #454
2022-03-28 10:24:07 +09:00
Alex Osborne 1c4831d6e9 JerichoExtractorHTML: Determine LINK tag type by parsing REL attribute
This commit extends ExtractorHTML's link[rel] parsing support added in
dcf9b040 to also cover JerichoExtractorHTML.
2022-01-27 12:07:07 +09:00
Alex Osborne dcf9b04007 ExtractorHTML: Determine LINK tag type by parsing REL attribute
Only treat icons, stylesheets and (tentatively) resource preloads as
embedded resources. Treat most other link types as navigation links.

Previously we were treating all link tags as embedded resources
including links like 'next', 'prev', 'canonical', 'author' which could
pull in resources that should normally be considered out of scope.

For example crawling a page containing an author link lke:

   <link href="http://twitter.com/example" rel="author">

Would end up transitively pulling 200+ MB of Twitter profile pages in
multiple languages into a crawl for which twitter.com is not even
supposed to be in scope at all.

Fixes #263
2022-01-25 17:57:54 +09:00
Alex Osborne d40a025692 Merge pull request #452 from internetarchive/handle-nulls-in-content-length-header
FetchHTTP: Handle null characters in the Content-Length header
2022-01-17 16:20:12 +09:00
Clemens Klein-Robbenhaar 261fa318b4 FetchHTTPRequest: handle HTTPS requests via proxy
- do not send the scheme/host/port part of the request
  even when using a proxy, if the scheme is https
- in case of a https request send over a proxy, do not
  wrap the first input/output streams (which only contain
  the data for the `CONNECT` request), but the ones after
  them, which contain the actual data

Fixes #191
2022-01-10 08:57:22 +01:00
Alex Osborne a3d651ba46 FetchHTTP: Handle null characters in the Content-Length header
If a null character appears in the Content-Length header Firefox and
Chrome seem to ignore the rest of the value so let's do the same.
Let's also handle the exception when parsing the content-length fails.

Fixes #449
2021-12-13 15:41:38 +09:00
Alex Osborne d63cb9af8b Merge pull request #444 from internetarchive/fix-dnsjava-selector-thread
FetchDNS: Keep dnsjava selector thread out of ToePool
2021-11-27 12:41:11 +09:00
Alex Osborne c46cfd1c31 Merge pull request #441 from netarchivesuite/iipc-master
Enabled configurable url-matching and extraction for sitemaps.
2021-11-02 10:34:26 +09:00
Alex Osborne 1832c5ef89 FetchDNS: Keep dnsjava selector thread out of ToePool
dnsjava will create its global selector thread on first DNS lookup.
Since the first lookup occurs on a toe thread then this will cause the
selector thead to join the job's toe thread group. This is a problem
because when the job is terminated ToePool sends an interrupt to all
threads in the thread group which the dnsjava selector thread is
not expected and never clears. The interrupted state then causes
select() to return immediately instead of sleeping so it consumes
100% CPU.

So workaround this by doing a dummy lookup when FetchDNS is loaded,
this ensures the first lookup happens on the web server thread that
handles the job build action instead of a toe thread.

Fixes: 045b2516da ("Update to latest version of dnsjava")
2021-11-01 16:15:27 +09:00
Alex Osborne 513c5fc487 FetchDNS: Move DNS cache init from CrawlController
Since the cache is global we only need to configure it once, not every
time we start a job. By moving it we keep the code that interfaces with
dnsjava centralized in FetchDNS.

Looks like dnsjava no longer uses a cleaner thread so remove the comment
referring to it.
2021-11-01 16:15:27 +09:00
Andy Jackson 3f4535a933 Add safer cookie iteration, as per #427. 2021-09-06 11:05:12 +01:00
Alex Osborne eb67cfb215 Merge pull request #423 from internetarchive/dont-extract-data-uris
Don't extract data URIs
2021-08-03 07:43:17 +09:00
Andy Jackson 4d5b2dc3fe Merge pull request #397 from ukwa/upgrade-httpclient-4-5
Upgrade httpclient to 4.5
2021-08-02 09:19:30 +01:00
Alex Osborne 33a5d70209 ExtractorSitemap: Use logUriError() helper like other extractors 2021-07-30 15:57:09 +09:00
Alex Osborne 1032c0ec40 ExtractorHTML: Avoid allocating strings for data: URIs when possible
Data URIs can be very large. ExtractorHTML mostly works with off-heap
CharSequences so by delaying the conversion of outlinks to strings
until after filtering out data URIs we can potentially avoid some
very large String allocations.
2021-07-30 15:57:09 +09:00
Alex Osborne e33e1ff398 Extractor: ignore data URIs when adding outlinks 2021-07-30 15:57:09 +09:00
Alex Osborne 91ef23eddf ExtractorPDFContext, ExtractorYoutubeDL: use addOutlink() helper method 2021-07-30 14:25:34 +09:00
csrster 523200ada6 Enabled configurable url-matching and extraction for sitemaps. 2021-07-15 15:35:03 +02:00
Alex Osborne 09e3ff3568 Everywhere: Fix dangling JavaDoc comments
JavaDoc comments need to be directly above a class, method or field
declaration to be used by IDEs and generated documentation. We had some
doc comments that were attached to instance initialization blocks and
thus were being ignored. This invalid doc comment positioning was
presumably an accidental consequence of the conversion of fields to
KeyedProperties.

This change moves most of the dangling doc comments to setter methods
where it can be seen by tools. There were a couple of dangling doc
comments above package statements. These are moved above the class
declaration or removed entirely when empty.
2021-07-12 21:38:48 +09:00
Andrew Jackson 0640cae4a9 Enabled AuthCache but not for DigestScheme. 2021-07-05 21:29:16 +01:00
Adam Miller ca3397e346 Fixing race condition on totalBytesWritten 2021-07-03 12:10:21 +09:00
Adam Miller 111b77b4aa Add checkpoint store/load functionality for warc writer stats 2021-07-03 12:10:21 +09:00
Alex Osborne 200f1cf38f DNS: Use the new protocol-agnostic server IP attribute
Also fixes an issue where in some cases we would incorrectly output
WARC-IP-Address for DNS records as "/127.0.0.53:53" instead of
"127.0.0.53".
2021-06-25 16:39:59 +09:00
Alex Osborne c378c46e49 WHOIS: Replace A_WHOIS_SERVER_IP with the generic A_SERVER_IP one 2021-06-25 14:39:26 +09:00
Alex Osborne 6b42c608a5 BaseWARCRecordBuilder: remove now unused getHostAddress(curi) helper
We now save the server IP at fetch time and retrieve it with
CrawlURI.getServerIP()
2021-06-25 14:39:26 +09:00
Alex Osborne ef3b428061 FTP: Save server IP at fetch time and use in WARC-IP-Address 2021-06-25 14:39:26 +09:00
Alex Osborne 13c0f65294 FTP: Implement a basic fetch test 2021-06-25 14:09:38 +09:00
Alex Osborne 28ea9c4ba5 HTTP: Populate WARC-IP-Address with server's IP address
Fixes #396
2021-06-25 13:34:40 +09:00
Alex Osborne 5a6531b296 CrawlURI: Introduce a protocol-agnostic server-ip attribute
The vast majority of protocols we use will have a server IP address,
so rather than having a separate one for each protocol let's just use
a single common one.
2021-06-25 13:24:20 +09:00
Andrew Jackson d372aacc33 Fix merge error. 2021-06-21 13:50:58 +01:00
Andrew Jackson 1e144e23dc Merge branch 'upgrade-httpclient-4-5' of github.com:ukwa/heritrix3 into upgrade-httpclient-4-5 2021-06-21 13:49:43 +01:00
Andrew Jackson 595c8d1293 Resolve issues raised during review by @ato. 2021-06-21 13:49:21 +01:00
Andy Jackson bd6b4f1e0f Switch to StandardCharsets to avoid try/catch.
Co-authored-by: Alex Osborne <ato@meshy.org>
2021-06-21 13:42:13 +01:00
Andrew Jackson df4a328048 Fix imports. 2021-06-20 23:16:42 +01:00
Andy Jackson a9002e1e3b Merge branch 'master' into upgrade-httpclient-4-5 2021-06-20 23:09:59 +01:00
Alex Osborne 5d0a5b2ec4 Remove dependency on mg4j
This eliminates one of the jars that Heritrix depends on that isn't in
Maven Central.

There were only two usages. The first usage was a method in a
CrawlerJournal which as far as I can tell is unused and can be removed.

The second usage was an unnecessary use of MutableString as a line
buffer when saving cookies to a file. Since there doesn't seem any
particular reason buffer per-line here let's just use a BufferedWriter
instead on the whole file which is also slightly simpler and more
efficient.
2021-06-20 23:30:41 +09:00
Andrew Jackson e3b2eea12d Merge branch 'master' into upgrade-httpclient-4-5 2021-06-18 10:22:31 +01:00
Kristinn Sigurdsson 627befe07e Remove unnecessary fiddling with VIA path 2021-06-18 08:42:05 +00:00
Andrew Jackson 998eaa3ed8 Merge branch 'master' into upgrade-httpclient-4-5 2021-06-17 14:32:43 +01:00
Andrew Jackson e07b1bb938 Support cookie expiration and extend testing to cover that case. 2021-06-17 14:23:42 +01:00
Andrew Jackson 2d64e005cb Switch to standard cookie handling. 2021-06-17 14:23:20 +01:00
Andrew Jackson 4cd416a5e4 Update complier plugin and use compatible flip(). 2021-06-17 14:01:04 +01:00
Kristinn Sigurdsson 81bef22270 Mark nested sitemap links as sitemaps 2021-06-16 13:07:18 +00:00