Quiet up logs

This commit is contained in:
Owen
2025-12-22 14:31:44 -05:00
parent 3d5335f2cb
commit 5c94789d9a
7 changed files with 23 additions and 24 deletions

View File

@@ -24,7 +24,7 @@ func setupClients(client *websocket.Client) {
host = strings.TrimSuffix(host, "/") host = strings.TrimSuffix(host, "/")
logger.Info("Setting up clients with netstack2...") logger.Debug("Setting up clients with netstack2...")
// if useNativeInterface is true make sure we have permission to use native interface // if useNativeInterface is true make sure we have permission to use native interface
if useNativeInterface { if useNativeInterface {

View File

@@ -141,7 +141,7 @@ func NewWireGuardService(interfaceName string, port uint16, mtu int, host string
// Add a reference for the hole punch manager (creator already has one reference for WireGuard) // Add a reference for the hole punch manager (creator already has one reference for WireGuard)
sharedBind.AddRef() sharedBind.AddRef()
logger.Info("Created shared UDP socket on port %d (refcount: %d)", port, sharedBind.GetRefCount()) logger.Debug("Created shared UDP socket on port %d (refcount: %d)", port, sharedBind.GetRefCount())
// Parse DNS addresses // Parse DNS addresses
dnsAddrs := []netip.Addr{netip.MustParseAddr(dns)} dnsAddrs := []netip.Addr{netip.MustParseAddr(dns)}
@@ -294,7 +294,7 @@ func (s *WireGuardService) StartHolepunch(publicKey string, endpoint string, rel
logger.Warn("Failed to start hole punch: %v", err) logger.Warn("Failed to start hole punch: %v", err)
} }
logger.Info("Starting hole punch to %s with public key: %s", endpoint, publicKey) logger.Debug("Starting hole punch to %s with public key: %s", endpoint, publicKey)
} }
// StartDirectUDPRelay starts a direct UDP relay from the main tunnel netstack to the clients' WireGuard. // StartDirectUDPRelay starts a direct UDP relay from the main tunnel netstack to the clients' WireGuard.
@@ -341,7 +341,7 @@ func (s *WireGuardService) StartDirectUDPRelay(tunnelIP string) error {
// Set the netstack connection on the SharedBind so responses go back through the tunnel // Set the netstack connection on the SharedBind so responses go back through the tunnel
s.sharedBind.SetNetstackConn(listener) s.sharedBind.SetNetstackConn(listener)
logger.Info("Started direct UDP relay on %s:%d (bidirectional via SharedBind)", tunnelIP, s.Port) logger.Debug("Started direct UDP relay on %s:%d (bidirectional via SharedBind)", tunnelIP, s.Port)
// Start the relay goroutine to read from netstack and inject into SharedBind // Start the relay goroutine to read from netstack and inject into SharedBind
s.directRelayWg.Add(1) s.directRelayWg.Add(1)
@@ -359,7 +359,7 @@ func (s *WireGuardService) runDirectUDPRelay(listener net.PacketConn) {
// Note: Don't close listener here - it's also used by SharedBind for sending responses // Note: Don't close listener here - it's also used by SharedBind for sending responses
// It will be closed when the relay is stopped // It will be closed when the relay is stopped
logger.Info("Direct UDP relay started (bidirectional through SharedBind)") logger.Debug("Direct UDP relay started (bidirectional through SharedBind)")
buf := make([]byte, 65535) // Max UDP packet size buf := make([]byte, 65535) // Max UDP packet size
@@ -445,7 +445,7 @@ func (s *WireGuardService) LoadRemoteConfig() error {
"port": s.Port, "port": s.Port,
}, 2*time.Second) }, 2*time.Second)
logger.Info("Requesting WireGuard configuration from remote server") logger.Debug("Requesting WireGuard configuration from remote server")
go s.periodicBandwidthCheck() go s.periodicBandwidthCheck()
return nil return nil
@@ -455,7 +455,7 @@ func (s *WireGuardService) handleConfig(msg websocket.WSMessage) {
var config WgConfig var config WgConfig
logger.Debug("Received message: %v", msg) logger.Debug("Received message: %v", msg)
logger.Info("Received WireGuard clients configuration from remote server") logger.Debug("Received WireGuard clients configuration from remote server")
jsonData, err := json.Marshal(msg.Data) jsonData, err := json.Marshal(msg.Data)
if err != nil { if err != nil {
@@ -488,6 +488,8 @@ func (s *WireGuardService) handleConfig(msg websocket.WSMessage) {
if err := s.ensureTargets(config.Targets); err != nil { if err := s.ensureTargets(config.Targets); err != nil {
logger.Error("Failed to ensure WireGuard targets: %v", err) logger.Error("Failed to ensure WireGuard targets: %v", err)
} }
logger.Info("Client connectivity setup. Ready to accept connections from clients!")
} }
func (s *WireGuardService) ensureWireguardInterface(wgconfig WgConfig) error { func (s *WireGuardService) ensureWireguardInterface(wgconfig WgConfig) error {
@@ -635,7 +637,7 @@ func (s *WireGuardService) ensureWireguardInterface(wgconfig WgConfig) error {
return fmt.Errorf("failed to bring up WireGuard device: %v", err) return fmt.Errorf("failed to bring up WireGuard device: %v", err)
} }
logger.Info("WireGuard netstack device created and configured") logger.Debug("WireGuard netstack device created and configured")
// Release the mutex before calling the callback // Release the mutex before calling the callback
s.mu.Unlock() s.mu.Unlock()

View File

@@ -295,7 +295,7 @@ func (m *Manager) StartMultipleExitNodes(exitNodes []ExitNode) error {
m.updateChan = make(chan struct{}, 1) m.updateChan = make(chan struct{}, 1)
m.mu.Unlock() m.mu.Unlock()
logger.Info("Starting UDP hole punch to %d exit nodes with shared bind", len(exitNodes)) logger.Debug("Starting UDP hole punch to %d exit nodes with shared bind", len(exitNodes))
go m.runMultipleExitNodes() go m.runMultipleExitNodes()
@@ -373,7 +373,7 @@ func (m *Manager) runMultipleExitNodes() {
publicKey: exitNode.PublicKey, publicKey: exitNode.PublicKey,
endpointName: exitNode.Endpoint, endpointName: exitNode.Endpoint,
}) })
logger.Info("Resolved exit node: %s -> %s", exitNode.Endpoint, remoteAddr.String()) logger.Debug("Resolved exit node: %s -> %s", exitNode.Endpoint, remoteAddr.String())
} }
return resolvedNodes return resolvedNodes
} }

View File

@@ -420,7 +420,7 @@ func runNewtMain(ctx context.Context) {
} }
if tel != nil { if tel != nil {
// Admin HTTP server (exposes /metrics when Prometheus exporter is enabled) // Admin HTTP server (exposes /metrics when Prometheus exporter is enabled)
logger.Info("Starting metrics server on %s", tcfg.AdminAddr) logger.Debug("Starting metrics server on %s", tcfg.AdminAddr)
mux := http.NewServeMux() mux := http.NewServeMux()
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) }) mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(200) })
if tel.PrometheusHandler != nil { if tel.PrometheusHandler != nil {

View File

@@ -372,7 +372,7 @@ func copyPacketData(dst, src net.PacketConn, to net.Addr, timeout time.Duration)
// InstallICMPHandler installs the ICMP handler on the stack // InstallICMPHandler installs the ICMP handler on the stack
func (h *ICMPHandler) InstallICMPHandler() error { func (h *ICMPHandler) InstallICMPHandler() error {
h.stack.SetTransportProtocolHandler(header.ICMPv4ProtocolNumber, h.handleICMPPacket) h.stack.SetTransportProtocolHandler(header.ICMPv4ProtocolNumber, h.handleICMPPacket)
logger.Info("ICMP Handler: Installed ICMP protocol handler") logger.Debug("ICMP Handler: Installed ICMP protocol handler")
return nil return nil
} }

View File

@@ -254,7 +254,7 @@ func NewProxyHandler(options ProxyHandlerOptions) (*ProxyHandler, error) {
if err := handler.icmpHandler.InstallICMPHandler(); err != nil { if err := handler.icmpHandler.InstallICMPHandler(); err != nil {
return nil, fmt.Errorf("failed to install ICMP handler: %v", err) return nil, fmt.Errorf("failed to install ICMP handler: %v", err)
} }
logger.Info("ProxyHandler: ICMP handler enabled") logger.Debug("ProxyHandler: ICMP handler enabled")
} }
// // Example 1: Add a rule with no port restrictions (all ports allowed) // // Example 1: Add a rule with no port restrictions (all ports allowed)

View File

@@ -38,7 +38,6 @@ type Server struct {
isRunning bool isRunning bool
runningLock sync.Mutex runningLock sync.Mutex
newtID string newtID string
outputPrefix string
useNetstack bool useNetstack bool
tnet interface{} // Will be *netstack2.Net when using netstack tnet interface{} // Will be *netstack2.Net when using netstack
} }
@@ -50,7 +49,6 @@ func NewServer(serverAddr string, serverPort uint16, newtID string) *Server {
serverPort: serverPort + 1, // use the next port for the server serverPort: serverPort + 1, // use the next port for the server
shutdownCh: make(chan struct{}), shutdownCh: make(chan struct{}),
newtID: newtID, newtID: newtID,
outputPrefix: "[WGTester] ",
useNetstack: false, useNetstack: false,
tnet: nil, tnet: nil,
} }
@@ -63,7 +61,6 @@ func NewServerWithNetstack(serverAddr string, serverPort uint16, newtID string,
serverPort: serverPort + 1, // use the next port for the server serverPort: serverPort + 1, // use the next port for the server
shutdownCh: make(chan struct{}), shutdownCh: make(chan struct{}),
newtID: newtID, newtID: newtID,
outputPrefix: "[WGTester] ",
useNetstack: true, useNetstack: true,
tnet: tnet, tnet: tnet,
} }
@@ -109,7 +106,7 @@ func (s *Server) Start() error {
s.isRunning = true s.isRunning = true
go s.handleConnections() go s.handleConnections()
logger.Info("%sServer started on %s:%d", s.outputPrefix, s.serverAddr, s.serverPort) logger.Debug("WGTester Server started on %s:%d", s.serverAddr, s.serverPort)
return nil return nil
} }
@@ -127,7 +124,7 @@ func (s *Server) Stop() {
s.conn.Close() s.conn.Close()
} }
s.isRunning = false s.isRunning = false
logger.Info("%sServer stopped", s.outputPrefix) logger.Info("WGTester Server stopped")
} }
// RestartWithNetstack stops the current server and restarts it with netstack // RestartWithNetstack stops the current server and restarts it with netstack
@@ -162,7 +159,7 @@ func (s *Server) handleConnections() {
// Set read deadline to avoid blocking forever // Set read deadline to avoid blocking forever
err := s.conn.SetReadDeadline(time.Now().Add(1 * time.Second)) err := s.conn.SetReadDeadline(time.Now().Add(1 * time.Second))
if err != nil { if err != nil {
logger.Error("%sError setting read deadline: %v", s.outputPrefix, err) logger.Error("Error setting read deadline: %v", err)
continue continue
} }
@@ -192,7 +189,7 @@ func (s *Server) handleConnections() {
if err == io.EOF { if err == io.EOF {
return return
} }
logger.Error("%sError reading from UDP: %v", s.outputPrefix, err) logger.Error("Error reading from UDP: %v", err)
} }
continue continue
} }
@@ -224,7 +221,7 @@ func (s *Server) handleConnections() {
copy(responsePacket[5:13], buffer[5:13]) copy(responsePacket[5:13], buffer[5:13])
// Log response being sent for debugging // Log response being sent for debugging
// logger.Debug("%sSending response to %s", s.outputPrefix, addr.String()) // logger.Debug("Sending response to %s", addr.String())
// Send the response packet - handle both regular UDP and netstack UDP // Send the response packet - handle both regular UDP and netstack UDP
if s.useNetstack { if s.useNetstack {
@@ -238,9 +235,9 @@ func (s *Server) handleConnections() {
} }
if err != nil { if err != nil {
logger.Error("%sError sending response: %v", s.outputPrefix, err) logger.Error("Error sending response: %v", err)
} else { } else {
// logger.Debug("%sResponse sent successfully", s.outputPrefix) // logger.Debug("Response sent successfully")
} }
} }
} }