fix(sensor-proxy): add --proxy-url flag for manual URL override
Closes #826 The error messages suggested using --proxy-url but the flag was never implemented. This adds the flag so users can manually specify the proxy URL when: - Auto IP detection produces malformed results - The desired IP is not the primary IP - Multi-homed hosts need a specific interface
This commit is contained in:
parent
ce10dbad60
commit
4d7285613f
1 changed files with 37 additions and 26 deletions
|
|
@ -1163,6 +1163,7 @@ UNINSTALL=false
|
||||||
PURGE=false
|
PURGE=false
|
||||||
CONTROL_PLANE_TOKEN=""
|
CONTROL_PLANE_TOKEN=""
|
||||||
CONTROL_PLANE_REFRESH=""
|
CONTROL_PLANE_REFRESH=""
|
||||||
|
PROXY_URL="" # Manual override for advertised proxy URL
|
||||||
SHORT_HOSTNAME=$(hostname -s 2>/dev/null || hostname | cut -d'.' -f1)
|
SHORT_HOSTNAME=$(hostname -s 2>/dev/null || hostname | cut -d'.' -f1)
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
|
|
@ -1215,6 +1216,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
PURGE=true
|
PURGE=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--proxy-url)
|
||||||
|
PROXY_URL="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
print_error "Unknown option: $1"
|
print_error "Unknown option: $1"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -1964,7 +1969,12 @@ if [[ "$HTTP_MODE" == true ]]; then
|
||||||
# Setup TLS certificates
|
# Setup TLS certificates
|
||||||
setup_tls_certificates "" "" # Empty params = auto-generate
|
setup_tls_certificates "" "" # Empty params = auto-generate
|
||||||
|
|
||||||
# Determine proxy URL - use IP address for reliable network access
|
# Determine proxy URL - use provided URL or auto-detect IP address
|
||||||
|
if [[ -n "$PROXY_URL" ]]; then
|
||||||
|
# User provided --proxy-url, use it directly
|
||||||
|
print_info "Using manually specified proxy URL: $PROXY_URL"
|
||||||
|
else
|
||||||
|
# Auto-detect from primary IP
|
||||||
PRIMARY_IP=$(hostname -I 2>/dev/null | awk '{print $1}')
|
PRIMARY_IP=$(hostname -I 2>/dev/null | awk '{print $1}')
|
||||||
if [[ -z "$PRIMARY_IP" ]]; then
|
if [[ -z "$PRIMARY_IP" ]]; then
|
||||||
print_error "Failed to determine primary IP address"
|
print_error "Failed to determine primary IP address"
|
||||||
|
|
@ -1995,6 +2005,7 @@ if [[ "$HTTP_MODE" == true ]]; then
|
||||||
|
|
||||||
PROXY_URL="https://${PRIMARY_IP}:${PORT_NUMBER}"
|
PROXY_URL="https://${PRIMARY_IP}:${PORT_NUMBER}"
|
||||||
print_info "Proxy will be accessible at: $PROXY_URL"
|
print_info "Proxy will be accessible at: $PROXY_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
# Register with Pulse and get auth/control tokens
|
# Register with Pulse and get auth/control tokens
|
||||||
registration_response=$(register_with_pulse "$PULSE_SERVER" "$SHORT_HOSTNAME" "$PROXY_URL" "http")
|
registration_response=$(register_with_pulse "$PULSE_SERVER" "$SHORT_HOSTNAME" "$PROXY_URL" "http")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue