about summary refs log tree commit diff
path: root/app/helpers/webfinger_helper.rb
blob: 70c4932100516657122a67dc608f36f25505d017 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module WebfingerHelper
  def webfinger!(uri)
    hidden_service_uri = /\.(onion|i2p)(:\d+)?$/.match(uri)

    raise Mastodon::HostValidationError, 'Instance does not support hidden service connections' if !Rails.configuration.x.access_to_hidden_service && hidden_service_uri

    opts = {
      ssl: !hidden_service_uri,

      headers: {
        'User-Agent': Mastodon::Version.user_agent,
      },
    }

    Goldfinger::Client.new(uri, opts.merge(Rails.configuration.x.http_client_proxy)).finger
  end
end