2020-07-18 19:26:54 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Genera una versión onion
|
|
|
|
class DeployHiddenService < DeployWww
|
2023-03-28 18:28:46 +00:00
|
|
|
store :values, accessors: %i[onion], coder: JSON
|
|
|
|
|
|
|
|
before_create :create_hidden_service!
|
|
|
|
|
2020-07-18 19:26:54 +00:00
|
|
|
def fqdn
|
2023-03-28 18:28:46 +00:00
|
|
|
onion.tap do |onion|
|
2023-03-18 18:10:32 +00:00
|
|
|
raise ArgumentError, 'Aun no se generó la dirección .onion' if onion.blank?
|
|
|
|
end
|
2020-07-18 19:26:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def url
|
2022-04-06 23:07:14 +00:00
|
|
|
"http://#{fqdn}"
|
2020-07-18 19:26:54 +00:00
|
|
|
end
|
2023-03-28 18:28:46 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_hidden_service!
|
|
|
|
onion_address = HiddenServiceClient.new.create(site.name)
|
|
|
|
|
|
|
|
if ONION_RE =~ onion_address
|
|
|
|
self.onion = onion_address
|
|
|
|
|
|
|
|
usuarie = GitAuthor.new email: "tor@#{Site.domain}", name: 'Tor'
|
|
|
|
params = { onion: onion_address, deploy: self }
|
|
|
|
|
|
|
|
SiteService.new(site: site, usuarie: usuarie, params: params).add_onion
|
|
|
|
end
|
|
|
|
end
|
2020-07-18 19:26:54 +00:00
|
|
|
end
|