Cleanup.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user