summaryrefslogtreecommitdiff
path: root/lib/hyperstack
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-25 21:10:58 +0300
committerPaul Buetow <paul@buetow.org>2026-05-25 21:10:58 +0300
commit2e3e01ccc851897b6e8552c15e118e82a9abb0f8 (patch)
treea1003d8caefa6df070b27d3075422be9cb09d9fd /lib/hyperstack
parent2aa71022ad2d9379cf38db522194f38c05115d26 (diff)
fix(wireguard): remove memoization from config_contents and hosts_contents
Stale external changes to wg1.conf or /etc/hosts were invisible because LocalWireGuard cached the first read forever. Remove the cache entirely so every operation sees the current file state. Also removed the now-unnecessary ivar updates after write_config/write_hosts.
Diffstat (limited to 'lib/hyperstack')
-rw-r--r--lib/hyperstack/wireguard.rb14
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/hyperstack/wireguard.rb b/lib/hyperstack/wireguard.rb
index 46bd682..bb845e9 100644
--- a/lib/hyperstack/wireguard.rb
+++ b/lib/hyperstack/wireguard.rb
@@ -36,7 +36,6 @@ module HyperstackVM
write_config(updated)
restart_service_if_active
- @config_contents = updated
removed
end
@@ -52,7 +51,6 @@ module HyperstackVM
return removed if dry_run
write_hosts(updated)
- @hosts_contents = updated
removed
end
@@ -177,21 +175,17 @@ module HyperstackVM
end
def config_contents
- return @config_contents if defined?(@config_contents)
-
- @config_contents = File.read(@config_path)
+ File.read(@config_path)
rescue Errno::EACCES, Errno::ENOENT
stdout, _stderr, status = Open3.capture3('sudo', '-n', 'cat', @config_path)
- @config_contents = status.success? ? stdout : nil
+ status.success? ? stdout : nil
end
def hosts_contents
- return @hosts_contents if defined?(@hosts_contents)
-
- @hosts_contents = File.read('/etc/hosts')
+ File.read('/etc/hosts')
rescue Errno::EACCES, Errno::ENOENT
stdout, _stderr, status = Open3.capture3('sudo', '-n', 'cat', '/etc/hosts')
- @hosts_contents = status.success? ? stdout : nil
+ status.success? ? stdout : nil
end
def prune_hosts_entries(content, hostnames)