mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-11 02:58:11 -07:00
log->glog; more bencode fixes
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
log "github.com/golang/glog"
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/chihaya/chihaya/bencode"
|
||||
"github.com/chihaya/chihaya/drivers/tracker"
|
||||
@@ -74,19 +74,14 @@ func (s Server) serveAnnounce(w http.ResponseWriter, r *http.Request) {
|
||||
w.(http.Flusher).Flush()
|
||||
|
||||
if s.conf.Private {
|
||||
|
||||
log.V(5).Infof(
|
||||
glog.V(5).Infof(
|
||||
"announce: ip: %s user: %s torrent: %s",
|
||||
announce.IP,
|
||||
user.ID,
|
||||
torrent.ID,
|
||||
)
|
||||
} else {
|
||||
log.V(5).Infof(
|
||||
"announce: ip: %s torrent: %s",
|
||||
announce.IP,
|
||||
torrent.ID,
|
||||
)
|
||||
glog.V(5).Infof("announce: ip: %s torrent: %s", announce.IP, torrent.ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-9
@@ -10,7 +10,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
log "github.com/golang/glog"
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/chihaya/chihaya/bencode"
|
||||
"github.com/chihaya/chihaya/models"
|
||||
@@ -52,21 +52,29 @@ func (s *Server) serveScrape(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
bencoder := bencode.NewEncoder(w)
|
||||
bencoder.Encode("d")
|
||||
fmt.Fprintf(w, "d")
|
||||
bencoder.Encode("files")
|
||||
for _, torrent := range torrents {
|
||||
writeTorrentStatus(w, torrent)
|
||||
}
|
||||
bencoder.Encode("e")
|
||||
fmt.Fprintf(w, "e")
|
||||
|
||||
w.(http.Flusher).Flush()
|
||||
|
||||
log.V(5).Infof(
|
||||
"scrape: ip: %s user: %s torrents: %s",
|
||||
r.RemoteAddr,
|
||||
user.ID,
|
||||
strings.Join(torrentIDs, ", "),
|
||||
)
|
||||
if s.conf.Private {
|
||||
glog.V(5).Infof(
|
||||
"scrape: ip: %s user: %s torrents: %s",
|
||||
r.RemoteAddr,
|
||||
user.ID,
|
||||
strings.Join(torrentIDs, ", "),
|
||||
)
|
||||
} else {
|
||||
glog.V(5).Infof(
|
||||
"scrape: ip: %s torrents: %s",
|
||||
r.RemoteAddr,
|
||||
strings.Join(torrentIDs, ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func writeTorrentStatus(w io.Writer, t *models.Torrent) {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/etix/stoppableListener"
|
||||
log "github.com/golang/glog"
|
||||
"github.com/golang/glog"
|
||||
|
||||
"github.com/chihaya/chihaya/config"
|
||||
"github.com/chihaya/chihaya/drivers/backend"
|
||||
@@ -130,7 +130,7 @@ func fail(err error, w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.(http.Flusher).Flush()
|
||||
|
||||
log.V(5).Infof(
|
||||
glog.V(5).Infof(
|
||||
"failed request: ip: %s failure: %s",
|
||||
r.RemoteAddr,
|
||||
errmsg,
|
||||
|
||||
Reference in New Issue
Block a user