mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Rename metrics update functions
This changes the metrics update functions to UpdateProxyStats and UpdateClientStats, which is more accurate and clear than the previous CountryStats and RendezvousStats names.
This commit is contained in:
parent
78cf8e68b2
commit
1d73e14f34
3 changed files with 7 additions and 7 deletions
|
@ -97,7 +97,7 @@ func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
|
|||
if err != nil {
|
||||
log.Println("Warning: cannot process proxy IP: ", err.Error())
|
||||
} else {
|
||||
i.ctx.metrics.UpdateCountryStats(remoteIP, proxyType, natType)
|
||||
i.ctx.metrics.UpdateProxyStats(remoteIP, proxyType, natType)
|
||||
}
|
||||
|
||||
var b []byte
|
||||
|
@ -184,7 +184,7 @@ func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error {
|
|||
if snowflake != nil {
|
||||
snowflake.offerChannel <- offer
|
||||
} else {
|
||||
i.ctx.metrics.UpdateRendezvousStats(arg.RemoteAddr, arg.RendezvousMethod, offer.natType, "denied")
|
||||
i.ctx.metrics.UpdateClientStats(arg.RemoteAddr, arg.RendezvousMethod, offer.natType, "denied")
|
||||
resp := &messages.ClientPollResponse{Error: messages.StrNoProxies}
|
||||
return sendClientResponse(resp, response)
|
||||
}
|
||||
|
@ -192,11 +192,11 @@ func (i *IPC) ClientOffers(arg messages.Arg, response *[]byte) error {
|
|||
// Wait for the answer to be returned on the channel or timeout.
|
||||
select {
|
||||
case answer := <-snowflake.answerChannel:
|
||||
i.ctx.metrics.UpdateRendezvousStats(arg.RemoteAddr, arg.RendezvousMethod, offer.natType, "matched")
|
||||
i.ctx.metrics.UpdateClientStats(arg.RemoteAddr, arg.RendezvousMethod, offer.natType, "matched")
|
||||
resp := &messages.ClientPollResponse{Answer: answer}
|
||||
err = sendClientResponse(resp, response)
|
||||
case <-arg.Context.Done():
|
||||
i.ctx.metrics.UpdateRendezvousStats(arg.RemoteAddr, arg.RendezvousMethod, offer.natType, "timeout")
|
||||
i.ctx.metrics.UpdateClientStats(arg.RemoteAddr, arg.RendezvousMethod, offer.natType, "timeout")
|
||||
resp := &messages.ClientPollResponse{Error: messages.StrTimedOut}
|
||||
err = sendClientResponse(resp, response)
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ func (m *Metrics) IncrementCounter(key string) {
|
|||
incrementMapCounter(m.counters, key)
|
||||
}
|
||||
|
||||
func (m *Metrics) UpdateCountryStats(addr string, proxyType string, natType string) {
|
||||
func (m *Metrics) UpdateProxyStats(addr string, proxyType string, natType string) {
|
||||
|
||||
// perform geolocation of IP address
|
||||
ip := net.ParseIP(addr)
|
||||
|
@ -140,7 +140,7 @@ func (m *Metrics) UpdateCountryStats(addr string, proxyType string, natType stri
|
|||
}).Inc()
|
||||
}
|
||||
|
||||
func (m *Metrics) UpdateRendezvousStats(addr string, rendezvousMethod messages.RendezvousMethod, natType, status string) {
|
||||
func (m *Metrics) UpdateClientStats(addr string, rendezvousMethod messages.RendezvousMethod, natType, status string) {
|
||||
ip := net.ParseIP(addr)
|
||||
country := "??"
|
||||
if m.geoipdb != nil {
|
||||
|
|
|
@ -651,7 +651,7 @@ func TestInvalidGeoipFile(t *testing.T) {
|
|||
if err := ctx.metrics.LoadGeoipDatabases("invalid_filename", "invalid_filename6"); err != nil {
|
||||
log.Printf("loading geo ip databases returned error: %v", err)
|
||||
}
|
||||
ctx.metrics.UpdateCountryStats("127.0.0.1", "", NATUnrestricted)
|
||||
ctx.metrics.UpdateProxyStats("127.0.0.1", "", NATUnrestricted)
|
||||
So(ctx.metrics.geoipdb, ShouldBeNil)
|
||||
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue