This commit is contained in:
jdl
2026-06-15 19:06:12 +02:00
parent 458e1ac603
commit c47d00e694
7 changed files with 13 additions and 13 deletions

View File

@@ -46,7 +46,6 @@ func (a *App) _signinSubmit(s *api.Session, w http.ResponseWriter, r *http.Reque
sess, err := a.api.Session_SignIn(pwd)
if err != nil {
time.Sleep(time.Duration(rand.Int64N(int64(4 * time.Second))))
return err
}

View File

@@ -34,7 +34,7 @@ func withLogging(inner http.HandlerFunc) http.HandlerFunc {
wrapper := responseWriterWrapper{w, 0, 0}
inner(&wrapper, r)
_log.Printf("%s \"%s %s %s\" %d %d %v\n",
_log.Printf("%s \"%s %s %s\" %d %d %v",
r.RemoteAddr,
r.Method,
r.URL.Path,

View File

@@ -3,7 +3,7 @@ package hub
import "net/http"
func (a *App) registerRoutes() {
a.mux.Handle("GET /static/", http.FileServerFS(staticFS))
a.mux.Handle("GET /static/", withLogging(http.FileServerFS(staticFS).ServeHTTP))
a.handlePub("GET /", a._root)
a.handleNotSignedIn("GET /sign-in/", a._signin)

View File

@@ -62,13 +62,15 @@ func (hp *HubPoller) Run() {
hp.apply(state)
}
hp.poll()
client := &http.Client{Timeout: 32 * time.Second}
hp.poll(client)
for range time.Tick(hubPollInterval) {
hp.poll()
hp.poll(client)
}
}
func (hp *HubPoller) poll() {
func (hp *HubPoller) poll(client *http.Client) {
req, err := http.NewRequest(http.MethodGet, hp.hubURL, nil)
if err != nil {
log.Printf("[HubPoller] build request: %v", err)
@@ -76,7 +78,6 @@ func (hp *HubPoller) poll() {
}
req.SetBasicAuth("", hp.apiKey)
client := &http.Client{Timeout: 32 * time.Second}
resp, err := client.Do(req)
if err != nil {
log.Printf("[HubPoller] fetch: %v", err)

View File

@@ -28,7 +28,7 @@ func broadcast(selfVPNIP netip.Addr, pubKey wgtypes.Key, wgPort uint16, signKey
conn, err := net.ListenMulticastUDP("udp", nil, addr)
if err != nil {
log.Printf("[MCBroadcast] bind: %v", err)
log.Printf("[MC Broadcast] bind: %v", err)
return
}
defer conn.Close()
@@ -50,12 +50,12 @@ func broadcast(selfVPNIP netip.Addr, pubKey wgtypes.Key, wgPort uint16, signKey
}
if err := send(); err != nil {
log.Printf("[MCBroadcast] write: %v", err)
log.Printf("[MC Broadcast] write: %v", err)
}
for range time.Tick(broadcastInterval) {
if err := send(); err != nil {
log.Printf("[MCBroadcast] write: %v", err)
log.Printf("[MC Broadcast] write: %v", err)
return
}
}

View File

@@ -14,7 +14,7 @@ import (
func Receiver(selfVPNIP netip.Addr, ch chan<- Packet) {
for {
if err := receiver(selfVPNIP, ch); err != nil {
log.Printf("[MCReader] %v", err)
log.Printf("[MC Receiver] %v", err)
}
time.Sleep(errorTimeout)
}
@@ -74,7 +74,7 @@ func receiver(selfVPNIP netip.Addr, ch chan<- Packet) error {
}
if err := lim.Limit(); err != nil {
log.Printf("Rate limited packet from peer IP %d.", packet.PeerIP)
log.Printf("[MC Receiver] Rate limited packet from peer IP %d.", packet.PeerIP)
continue
}

View File

@@ -41,7 +41,7 @@ func (a *App) onPing(e PingEvent) {
// We make sure we don't set a private address as our public address since we
// may be connected via LAN to some peers.
if peer.State == StateDirect {
if dst := e.ping.Dst; addrIsRoutable(e.ping.Dst) {
if dst := e.ping.Dst; addrIsRoutable(dst) {
if dst.Addr().Is4() {
if dst != a.selfV4 {
log.Printf("Local IPv4 updated: %s -> %s", a.selfV4, dst)