Commit Graph

10 Commits

Author SHA1 Message Date
evazion
d946a84480 iqdb: download files inside danbooru, not inside iqdb.
Instead of sending IQDB the image url and letting it download the file,
download the file on Danbooru's end and send IQDB the downloaded file.

This fixes several issues:

* Some sites need the referer header set to avoid hotlink protection
  when downloading the file. Danbooru knows how to deal with this but
  IQDB doesn't.

* We need to enforce certain restrictions when downloading files,
  including setting max filesize limits, setting max timeouts, and not
  allowing downloads from forbidden IPs (to avoid SSRF attacks).
  Danbooru knows how to handle these things but IQDB doesn't.
2019-10-26 15:02:07 -05:00
evazion
ecfeaca7d4 iqdb: fix handling of error responses.
Handle JSON error responses returned by IQDB: `{ "error": <message> }`.
2019-10-26 13:01:08 -05:00
evazion
abee048de5 iqdb: use preview image url for iqdb lookups.
* Fix the IQDB lookup to handle error messages returned by IQDB.

* Fix `undefined method `>=' for nil:NilClass` error when trying to upload
  ugoiras. Using the preview image for IQDB lookups should be faster and
  give the same results as the full image, plus it should work with things
  like ugoiras and videos that IQDB can't handle.

  Also add an image_url param so that API users can continue using the
  full image if needed.
2019-10-22 13:07:21 -05:00
evazion
d2c6d6d17b iqdb: hide low similarity results behind "show" link. 2019-10-16 23:53:09 -05:00
evazion
958ba0f8b7 iqdb: delete leftover unused code.
* Delete unused Iqdb::Download module.
* Fix N+1 query in decorate_posts.
* /iqdb_queries: Raise max value of `limit` param to 1000.
2019-10-16 23:52:39 -05:00
evazion
ae521e600e iqdb: proxy iqdb searches through danbooru.
Previously the search form on the /iqdb_queries page submitted directly
to the iqdb service (karasuma.donmai.us), which redirected back to
Danbooru with the search results.

This was different than API requests, which submitted to
/iqdb_queries.json which proxied the call to iqdb through Danbooru.
Because of this, searches on the /iqdb_queries page had different
behavior than API requests. Things like filesize limits and referrer
spoofing were handled differently.

Now searches on the /iqdb_queries page submit directly to Danbooru. This
is simpler and it means that API requests and HTML requests have the
same behavior.
2019-10-14 21:16:04 -05:00
evazion
fa37b1edcd iqdb: lower similarity cutoff, return more results (fix #4190).
* Change cutoffs on upload page to max 5 results, min. 20% similarity.
* Change cutoffs on standalone /iqdb_queries page to max 20 results, min. 0% similarity.
* /iqdb_queries.json: add `limit` and `similarity` params to change default cutoffs.
2019-10-14 21:16:04 -05:00
r888888888
62235e215e iqdb fixes 2018-06-23 11:15:14 -07:00
r888888888
8f2f418613 fix iqdbproxy 2018-06-23 11:09:03 -07:00
r888888888
3ba5c6fb51 refactor iqdb endpoints 2018-06-23 10:59:04 -07:00