mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-19 06:36:22 +00:00
Merge branch 'issue-12773' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
commit
069e8d5869
2 changed files with 24 additions and 1 deletions
13
app/lib/hidden_service_client.rb
Normal file
13
app/lib/hidden_service_client.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'httparty'
|
||||
|
||||
class HiddenServiceClient
|
||||
include HTTParty
|
||||
|
||||
base_uri ENV.fetch('HIDDEN_SERVICE', 'http://tor:3000')
|
||||
|
||||
def create(name)
|
||||
self.class.get("/#{name}")
|
||||
end
|
||||
end
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
# Genera una versión onion
|
||||
class DeployHiddenService < DeployWww
|
||||
store :values, accessors: %i[onion], coder: JSON
|
||||
|
||||
before_create :create_hidden_service!
|
||||
|
||||
def fqdn
|
||||
values[:onion].tap do |onion|
|
||||
onion.tap do |onion|
|
||||
raise ArgumentError, 'Aun no se generó la dirección .onion' if onion.blank?
|
||||
end
|
||||
end
|
||||
|
@ -11,4 +15,10 @@ class DeployHiddenService < DeployWww
|
|||
def url
|
||||
"http://#{fqdn}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_hidden_service!
|
||||
self.onion = HiddenServiceClient.new.create(site.name)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue