update server

This commit is contained in:
Torsten 2022-04-02 21:49:32 +03:00
parent 8e88fc7ac6
commit 29003907aa
3 changed files with 13 additions and 9 deletions

View File

@ -9,7 +9,7 @@ class DnsUpdateJob < ApplicationJob
Rails.application.credentials.simple_id
end
def my_ip
HTTParty.get("http://icanhazip.com").strip
HTTParty.get("https://jsonip.com/")["ip"]
end
def find_record(name , host)
@ -17,6 +17,10 @@ class DnsUpdateJob < ApplicationJob
zones.data.first
end
def same_ip
my_ip == find_record("gateway" , "hubfeenix.fi").content
end
def update_ip
record = find_record("gateway" , "hubfeenix.fi")
client.zones.update_zone_record(simple_id,"hubfeenix.fi", record.id , content: my_ip)

View File

@ -9,7 +9,7 @@ require 'mina/rbenv' # for rbenv support. (https://rbenv.org)
# branch - Branch name to deploy. (needed by mina/git)
set :application_name, 'gateway'
set :domain, 'web-server.local'
set :domain, '192.168.128.3'
set :deploy_to, '/home/feenix/gateway'
set :repository, "https://github.com/rubydesign/gateway.git"
set :branch, 'passenger'

View File

@ -4,6 +4,13 @@ RSpec.describe DnsUpdateJob, type: :job do
ActiveJob::Base.queue_adapter = :test
let(:my_ip){"85.76.133.88"}
it "update ip" do
updater = DnsUpdateJob.new
updater.update_ip
zone = updater.find_record("gateway","hubfeenix.fi")
expect(zone.content).to eq my_ip
end
it "should get ip" do
res = DnsUpdateJob.new.my_ip
expect(res).to eq my_ip
@ -20,11 +27,4 @@ RSpec.describe DnsUpdateJob, type: :job do
expect(zone.name).to eq "gateway"
expect(zone.content).to eq my_ip
end
it "update ip" do
updater = DnsUpdateJob.new
updater.update_ip
zone = updater.find_record("gateway","hubfeenix.fi")
expect(zone.content).to eq my_ip
end
end