mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 14:11:23 -04:00
Add distinct IP counter
This commit is contained in:
parent
97dea533da
commit
211254fa98
8 changed files with 307 additions and 0 deletions
37
distinctcounter/counter.go
Normal file
37
distinctcounter/counter.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/ipsetsink/sinkcluster"
|
||||
)
|
||||
|
||||
func main() {
|
||||
inputFile := flag.String("in", "", "")
|
||||
start := flag.String("start", "", "")
|
||||
end := flag.String("end", "", "")
|
||||
flag.Parse()
|
||||
startTime, err := time.Parse(time.UnixDate, *start)
|
||||
if err != nil {
|
||||
log.Fatal("unable to parse start time:", err)
|
||||
}
|
||||
endTime, err := time.Parse(time.UnixDate, *end)
|
||||
if err != nil {
|
||||
log.Fatal("unable to parse end time:", err)
|
||||
}
|
||||
fd, err := os.Open(*inputFile)
|
||||
if err != nil {
|
||||
log.Fatal("unable to open input file:", err)
|
||||
}
|
||||
counter := sinkcluster.NewClusterCounter(startTime, endTime)
|
||||
result, err := counter.Count(fd)
|
||||
if err != nil {
|
||||
log.Fatal("unable to count:", err)
|
||||
}
|
||||
fmt.Printf("sum = %v\n", result.Sum)
|
||||
fmt.Printf("chunkIncluded = %v\n", result.ChunkIncluded)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue