Commit a9864eba authored by Matt Joiner's avatar Matt Joiner
Browse files

Add the noseed and scrape krpc message arguments and count their usage

parent bafd01b6
......@@ -35,6 +35,8 @@ type MsgArgs struct {
Port int `bencode:"port,omitempty"` // Senders torrent port
ImpliedPort bool `bencode:"implied_port,omitempty"` // Use senders apparent DHT port
Want []Want `bencode:"want,omitempty"` // Contains strings like "n4" and "n6" from BEP 32.
NoSeed int `bencode:"noseed,omitempty"` // BEP 33
Scrape int `bencode:"scrape,omitempty"` // BEP 33
}
type Want string
......
......@@ -351,6 +351,17 @@ func (s *Server) setReturnNodes(r *krpc.Return, queryMsg krpc.Msg, querySource A
// TODO: Probably should write error messages back to senders if something is
// wrong.
func (s *Server) handleQuery(source Addr, m krpc.Msg) {
go func() {
expvars.Add(fmt.Sprintf("received query %s", m.Q), 1)
if a := m.A; a != nil {
if a.NoSeed != 0 {
expvars.Add("received argument noseed", 1)
}
if a.Scrape != 0 {
expvars.Add("received argument scrape", 1)
}
}
}()
if m.SenderID() != nil {
if n, _ := s.getNode(source, int160FromByteArray(*m.SenderID()), !m.ReadOnly); n != nil {
n.lastGotQuery = time.Now()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment