webfinger_helper.rb 540 B

12345678910111213141516171819
  1. # frozen_string_literal: true
  2. module WebfingerHelper
  3. def webfinger!(uri)
  4. hidden_service_uri = /\.(onion|i2p)(:\d+)?$/.match(uri)
  5. raise Mastodon::HostValidationError, 'Instance does not support hidden service connections' if !Rails.configuration.x.access_to_hidden_service && hidden_service_uri
  6. opts = {
  7. ssl: !hidden_service_uri,
  8. headers: {
  9. 'User-Agent': Mastodon::Version.user_agent,
  10. },
  11. }
  12. Goldfinger::Client.new(uri, opts.merge(Rails.configuration.x.http_client_proxy)).finger
  13. end
  14. end