diff --git a/lib/wire_guard/config_builder.rb b/lib/wire_guard/client_config_builder.rb similarity index 97% rename from lib/wire_guard/config_builder.rb rename to lib/wire_guard/client_config_builder.rb index a666872..db99932 100644 --- a/lib/wire_guard/config_builder.rb +++ b/lib/wire_guard/client_config_builder.rb @@ -2,7 +2,7 @@ module WireGuard # The class generates a config file for the client - class ConfigBuilder + class ClientConfigBuilder attr_reader :config def initialize(configs, params) diff --git a/lib/wire_guard/server.rb b/lib/wire_guard/server.rb index 1925a1d..84fc008 100644 --- a/lib/wire_guard/server.rb +++ b/lib/wire_guard/server.rb @@ -112,7 +112,7 @@ def dump_json_config(config) end def dump_wireguard_config - ConfigUpdater.update + ServerConfigUpdater.update end def update_json_config(config) @@ -134,7 +134,7 @@ def configs_empty? end def build_new_config(configs, params) - ConfigBuilder.new(configs, params).config + ClientConfigBuilder.new(configs, params).config end end end diff --git a/lib/wire_guard/config_updater.rb b/lib/wire_guard/server_config_updater.rb similarity index 99% rename from lib/wire_guard/config_updater.rb rename to lib/wire_guard/server_config_updater.rb index f693347..4544d27 100644 --- a/lib/wire_guard/config_updater.rb +++ b/lib/wire_guard/server_config_updater.rb @@ -5,7 +5,7 @@ module WireGuard # and reboots the WireGuard server # This class updates the config file of the server itself and not the clients. # And it is needed mainly to reboot the server after adding new clients (or deleting them) - class ConfigUpdater + class ServerConfigUpdater WG_CONF_PATH = "#{Settings.wg_path}/wg0.conf".freeze WG_PORT = Settings.wg_port WG_PRE_UP = Settings.wg_pre_up diff --git a/spec/app/clients_controller_spec.rb b/spec/app/clients_controller_spec.rb index 586c107..56da739 100644 --- a/spec/app/clients_controller_spec.rb +++ b/spec/app/clients_controller_spec.rb @@ -6,7 +6,7 @@ let(:wg_conf_path) { "#{Settings.wg_path}/wg0.json" } before do - allow(WireGuard::ConfigUpdater).to receive(:update) + allow(WireGuard::ServerConfigUpdater).to receive(:update) allow(WireGuard::StatGenerator).to receive_messages(show: '') allow(WireGuard::KeyGenerator).to receive_messages(wg_genkey: 'wg_genkey', wg_pubkey: 'wg_pubkey', wg_genpsk: 'wg_genpsk') diff --git a/spec/lib/wire_guard/config_builder_spec.rb b/spec/lib/wire_guard/client_config_builder_spec.rb similarity index 94% rename from spec/lib/wire_guard/config_builder_spec.rb rename to spec/lib/wire_guard/client_config_builder_spec.rb index ae35d53..61fcf55 100644 --- a/spec/lib/wire_guard/config_builder_spec.rb +++ b/spec/lib/wire_guard/client_config_builder_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe WireGuard::ConfigBuilder do +RSpec.describe WireGuard::ClientConfigBuilder do subject(:build) { described_class.new(configs, params).config } before do diff --git a/spec/lib/wire_guard/config_updater_spec.rb b/spec/lib/wire_guard/server_config_updater_spec.rb similarity index 93% rename from spec/lib/wire_guard/config_updater_spec.rb rename to spec/lib/wire_guard/server_config_updater_spec.rb index 6bc2199..325347e 100644 --- a/spec/lib/wire_guard/config_updater_spec.rb +++ b/spec/lib/wire_guard/server_config_updater_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -RSpec.describe WireGuard::ConfigUpdater do +RSpec.describe WireGuard::ServerConfigUpdater do subject(:update) { described_class.update } before do diff --git a/spec/lib/wire_guard/server_spec.rb b/spec/lib/wire_guard/server_spec.rb index 33ae00e..cc3bbdd 100644 --- a/spec/lib/wire_guard/server_spec.rb +++ b/spec/lib/wire_guard/server_spec.rb @@ -2,7 +2,7 @@ RSpec.describe WireGuard::Server do before do - allow(WireGuard::ConfigUpdater).to receive(:update) + allow(WireGuard::ServerConfigUpdater).to receive(:update) allow(WireGuard::KeyGenerator).to receive_messages(wg_genkey: 'wg_genkey', wg_pubkey: 'wg_pubkey', wg_genpsk: 'wg_genpsk') end @@ -130,7 +130,7 @@ it 'calls the configuration file update service WireGuard' do new_config - expect(WireGuard::ConfigUpdater).to have_received(:update) + expect(WireGuard::ServerConfigUpdater).to have_received(:update) end end @@ -294,7 +294,7 @@ it 'calls the configuration file update service WireGuard' do delete_config - expect(WireGuard::ConfigUpdater).to have_received(:update) + expect(WireGuard::ServerConfigUpdater).to have_received(:update) end end @@ -308,7 +308,7 @@ it 'no calls the configuration file update service WireGuard' do delete_config - expect(WireGuard::ConfigUpdater).not_to have_received(:update) + expect(WireGuard::ServerConfigUpdater).not_to have_received(:update) end end end @@ -402,7 +402,7 @@ it 'calls the configuration file update service WireGuard' do update_config - expect(WireGuard::ConfigUpdater).to have_received(:update) + expect(WireGuard::ServerConfigUpdater).to have_received(:update) end end @@ -425,7 +425,7 @@ it 'no calls the configuration file update service WireGuard' do update_config - expect(WireGuard::ConfigUpdater).not_to have_received(:update) + expect(WireGuard::ServerConfigUpdater).not_to have_received(:update) end end end