Refactor a few more method names
This commit is contained in:
parent
4d21473a02
commit
b88c4d4de1
4 changed files with 9 additions and 9 deletions
|
@ -263,11 +263,11 @@ func (s Server) validateAnnounceQuery(r *http.Request) (compact bool, numWant in
|
|||
}
|
||||
|
||||
compact = pq.Params["compact"] == "1"
|
||||
numWant = determineNumWant(s.conf.DefaultNumWant, pq)
|
||||
numWant = requestedPeerCount(s.conf.DefaultNumWant, pq)
|
||||
infohash, _ = pq.Params["info_hash"]
|
||||
peerID, _ = pq.Params["peer_id"]
|
||||
event, _ = pq.Params["event"]
|
||||
ip, _ = determineIP(r, pq)
|
||||
ip, _ = requestedIP(r, pq)
|
||||
port, portErr := pq.getUint64("port")
|
||||
uploaded, uploadedErr := pq.getUint64("uploaded")
|
||||
downloaded, downloadedErr := pq.getUint64("downloaded")
|
||||
|
@ -285,7 +285,7 @@ func (s Server) validateAnnounceQuery(r *http.Request) (compact bool, numWant in
|
|||
return
|
||||
}
|
||||
|
||||
func determineNumWant(fallback int, pq *parsedQuery) int {
|
||||
func requestedPeerCount(fallback int, pq *parsedQuery) int {
|
||||
if numWantStr, exists := pq.Params["numWant"]; exists {
|
||||
numWant, err := strconv.Atoi(numWantStr)
|
||||
if err != nil {
|
||||
|
@ -296,7 +296,7 @@ func determineNumWant(fallback int, pq *parsedQuery) int {
|
|||
return fallback
|
||||
}
|
||||
|
||||
func determineIP(r *http.Request, pq *parsedQuery) (string, error) {
|
||||
func requestedIP(r *http.Request, pq *parsedQuery) (string, error) {
|
||||
ip, ok := pq.Params["ip"]
|
||||
ipv4, okv4 := pq.Params["ipv4"]
|
||||
xRealIPs, xRealOk := pq.Params["X-Real-Ip"]
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
zmq "github.com/alecthomas/gozmq"
|
||||
)
|
||||
|
||||
func (s *Server) publish() {
|
||||
func (s *Server) publishQueue() {
|
||||
context, err := zmq.NewContext()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -68,8 +68,8 @@ func (s *Server) ListenAndServe() error {
|
|||
s.serving = true
|
||||
s.startTime = time.Now()
|
||||
|
||||
go s.updateRPM()
|
||||
go s.publish()
|
||||
go s.updateStats()
|
||||
go s.publishQueue()
|
||||
s.Serve(s.listener)
|
||||
|
||||
s.waitgroup.Wait()
|
||||
|
@ -137,7 +137,7 @@ func validateUser(tx storage.Tx, dir string) (*storage.User, error) {
|
|||
log.Panicf("server: %s", err)
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.New("Passkey not found")
|
||||
return nil, errors.New("User not found")
|
||||
}
|
||||
|
||||
return user, nil
|
||||
|
|
|
@ -31,7 +31,7 @@ func (s *Server) serveStats(w http.ResponseWriter, r *http.Request) {
|
|||
w.(http.Flusher).Flush()
|
||||
}
|
||||
|
||||
func (s *Server) updateRPM() {
|
||||
func (s *Server) updateStats() {
|
||||
for _ = range time.NewTicker(time.Minute).C {
|
||||
s.rpm = s.deltaRequests
|
||||
atomic.StoreInt64(&s.deltaRequests, 0)
|
||||
|
|
Loading…
Reference in a new issue