2017-08-22 12:49:37 +05:30
|
|
|
require 'resolv'
|
|
|
|
|
|
2017-08-19 13:57:09 +05:30
|
|
|
class ConferenceDomainsService
|
2017-08-22 12:49:37 +05:30
|
|
|
def initialize(conference, resolver = Resolv::DNS.new)
|
|
|
|
|
@conference = conference
|
|
|
|
|
@resolver = resolver
|
2017-08-19 13:57:09 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
# Checks if domain correctly points to the hosted version
|
|
|
|
|
# This feature is enabled only if ENV['OSEM_HOSTNAME'] is present
|
|
|
|
|
#
|
|
|
|
|
# ====Returns
|
|
|
|
|
# * +true+ -> If the custom domain has a CNAME record for the hosted version
|
|
|
|
|
# * +false+ -> If the custom domain does not have a CNAME record for the hosted version
|
|
|
|
|
def check_custom_domain
|
2017-08-22 12:49:37 +05:30
|
|
|
cname_record = @resolver.getresources(@conference.custom_domain, Resolv::DNS::Resource::IN::CNAME)
|
|
|
|
|
cname_record.present? ? ENV['OSEM_HOSTNAME'] == cname_record.name.to_s : false
|
2017-08-19 13:57:09 +05:30
|
|
|
end
|
|
|
|
|
end
|