fix: use pkill -HUP dnsmasq instead of systemctl (no polkit needed), display pinned hostname in table
This commit is contained in:
parent
db081b6b04
commit
5e742cbe2d
2 changed files with 14 additions and 12 deletions
13
install.sh
13
install.sh
|
|
@ -520,9 +520,9 @@ RestartSec=5
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
PrivateTmp=true
|
PrivateTmp=true
|
||||||
|
|
||||||
# Capabilities: bind low ports + talk to systemd for plugin reloads
|
# Capabilities: bind low ports
|
||||||
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SYS_ADMIN
|
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
||||||
AmbientCapabilities=CAP_NET_BIND_SERVICE CAP_SYS_ADMIN
|
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
@ -595,11 +595,8 @@ install_plugin() {
|
||||||
# Set group on plugin binary dir
|
# Set group on plugin binary dir
|
||||||
chgrp -R "$group" "$plugin_dir" 2>/dev/null || true
|
chgrp -R "$group" "$plugin_dir" 2>/dev/null || true
|
||||||
|
|
||||||
# Note: reload uses Linux capabilities (CAP_SYS_ADMIN), not sudo.
|
# Note: reload uses SIGHUP (pkill -HUP dnsmasq), not systemctl.
|
||||||
# The Zoraxy systemd service must include:
|
# This works without polkit or extra capabilities.
|
||||||
# CapabilityBoundingSet=CAP_SYS_ADMIN
|
|
||||||
# AmbientCapabilities=CAP_SYS_ADMIN
|
|
||||||
# (already configured by this installer).
|
|
||||||
|
|
||||||
log "Plugin installed at: $plugin_dir"
|
log "Plugin installed at: $plugin_dir"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
server.go
13
server.go
|
|
@ -24,8 +24,8 @@ var (
|
||||||
// Override via environment: LEASE_FILE, CONF_FILE, RELOAD_CMD, RELOAD_ARGS
|
// Override via environment: LEASE_FILE, CONF_FILE, RELOAD_CMD, RELOAD_ARGS
|
||||||
leasesFile = envOrDefault("LEASE_FILE", "/opt/zoraxy/conf/dhcp/dnsmasq.leases")
|
leasesFile = envOrDefault("LEASE_FILE", "/opt/zoraxy/conf/dhcp/dnsmasq.leases")
|
||||||
confFile = envOrDefault("CONF_FILE", "/opt/zoraxy/conf/dhcp/dnsmasq.conf")
|
confFile = envOrDefault("CONF_FILE", "/opt/zoraxy/conf/dhcp/dnsmasq.conf")
|
||||||
reloadCmd = envOrDefault("RELOAD_CMD", "/usr/bin/systemctl")
|
reloadCmd = envOrDefault("RELOAD_CMD", "pkill")
|
||||||
reloadArgs = strings.Fields(envOrDefault("RELOAD_ARGS", "reload dnsmasq"))
|
reloadArgs = strings.Fields(envOrDefault("RELOAD_ARGS", "-HUP dnsmasq"))
|
||||||
)
|
)
|
||||||
|
|
||||||
func envOrDefault(key, fallback string) string {
|
func envOrDefault(key, fallback string) string {
|
||||||
|
|
@ -323,11 +323,16 @@ func getAllLeases() ([]LeaseEntry, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status := PinStatusActive
|
status := PinStatusActive
|
||||||
if _, ok := pinned[lease.MAC]; ok {
|
hostname := lease.Hostname
|
||||||
|
if pinnedHost, ok := pinned[lease.MAC]; ok {
|
||||||
status = PinStatusPermanent
|
status = PinStatusPermanent
|
||||||
|
// Use the pinned hostname if one was set (overrides DHCP client hostname).
|
||||||
|
if pinnedHost != "" {
|
||||||
|
hostname = pinnedHost
|
||||||
|
}
|
||||||
}
|
}
|
||||||
entries = append(entries, LeaseEntry{
|
entries = append(entries, LeaseEntry{
|
||||||
Hostname: lease.Hostname,
|
Hostname: hostname,
|
||||||
IP: lease.IP,
|
IP: lease.IP,
|
||||||
MAC: lease.MAC,
|
MAC: lease.MAC,
|
||||||
Expiry: lease.Expiry,
|
Expiry: lease.Expiry,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue