示例#1
0
文件: server.go 项目: shizhh/lantern
func onBytesGiven(destAddr string, req *http.Request, bytes int64) {
	host, port, _ := net.SplitHostPort(destAddr)
	if port == "" {
		port = "0"
	}

	given := statreporter.CountryDim().
		And("flserver", globals.InstanceId).
		And("destport", port)
	given.Increment("bytesGiven").Add(bytes)
	given.Increment("bytesGivenByFlashlight").Add(bytes)

	clientCountry := req.Header.Get("Cf-Ipcountry")
	if clientCountry != "" {
		givenTo := statreporter.Country(clientCountry)
		givenTo.Increment("bytesGivenTo").Add(bytes)
		givenTo.Increment("bytesGivenToByFlashlight").Add(bytes)
		givenTo.Member("distinctDestHosts", host)

		clientIp := getClientIp(req)
		if clientIp != "" {
			givenTo.Member("distinctClients", clientIp)
		}
	}
}
示例#2
0
文件: stats.go 项目: shizhh/lantern
func onBytesGotten(bytes int64) {
	dims := statreporter.CountryDim()
	dims.Increment("bytesGotten").Add(bytes)
}