log->glog; more bencode fixes

This commit is contained in:
Jimmy Zelinskie
2014-06-30 23:21:08 -04:00
parent 834e584f2d
commit 9cb5b82dc7
5 changed files with 36 additions and 33 deletions
+3 -8
View File
@@ -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
View File
@@ -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
View File
@@ -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,