소스 검색

Use github.com/Psiphon-Labs/consistent

mirokuratczyk 2 년 전
부모
커밋
0a49f229db

+ 1 - 1
go.mod

@@ -9,12 +9,12 @@ replace github.com/pion/dtls/v2 => github.com/mingyech/dtls/v2 v2.0.0
 require (
 	github.com/Psiphon-Inc/rotate-safe-writer v0.0.0-20210303140923-464a7a37606e
 	github.com/Psiphon-Labs/bolt v0.0.0-20200624191537-23cedaef7ad7
+	github.com/Psiphon-Labs/consistent v0.0.0-20240322131436-20aaa4e05737
 	github.com/Psiphon-Labs/goptlib v0.0.0-20200406165125-c0e32a7a3464
 	github.com/Psiphon-Labs/psiphon-tls v0.0.0-20240305020009-09f917290799
 	github.com/Psiphon-Labs/quic-go v0.0.0-20240305203241-7c4a760d03cc
 	github.com/armon/go-proxyproto v0.0.0-20180202201750-5b7edb60ff5f
 	github.com/bifurcation/mint v0.0.0-20180306135233-198357931e61
-	github.com/buraksezer/consistent v0.10.0
 	github.com/cespare/xxhash v1.1.0
 	github.com/cheekybits/genny v0.0.0-20170328200008-9127e812e1e9
 	github.com/cognusion/go-cache-lru v0.0.0-20170419142635-f73e2280ecea

+ 2 - 2
go.sum

@@ -13,6 +13,8 @@ github.com/Psiphon-Inc/rotate-safe-writer v0.0.0-20210303140923-464a7a37606e h1:
 github.com/Psiphon-Inc/rotate-safe-writer v0.0.0-20210303140923-464a7a37606e/go.mod h1:ZdY5pBfat/WVzw3eXbIf7N1nZN0XD5H5+X8ZMDWbCs4=
 github.com/Psiphon-Labs/bolt v0.0.0-20200624191537-23cedaef7ad7 h1:Hx/NCZTnvoKZuIBwSmxE58KKoNLXIGG6hBJYN7pj9Ag=
 github.com/Psiphon-Labs/bolt v0.0.0-20200624191537-23cedaef7ad7/go.mod h1:alTtZBo3j4AWFvUrAH6F5ZaHcTj4G5Y01nHz8dkU6vU=
+github.com/Psiphon-Labs/consistent v0.0.0-20240322131436-20aaa4e05737 h1:QTMy7Uc2Xc7fz6O/Khy1xi0VBND13GqzLUE2mHw6HUU=
+github.com/Psiphon-Labs/consistent v0.0.0-20240322131436-20aaa4e05737/go.mod h1:Enj/Gszv2zCbuRbHbabmNvfO9EM+5kmaGj8CyjwNPlY=
 github.com/Psiphon-Labs/goptlib v0.0.0-20200406165125-c0e32a7a3464 h1:VmnMMMheFXwLV0noxYhbJbLmkV4iaVW3xNnj6xcCNHo=
 github.com/Psiphon-Labs/goptlib v0.0.0-20200406165125-c0e32a7a3464/go.mod h1:Pe5BqN2DdIdChorAXl6bDaQd/wghpCleJfid2NoSli0=
 github.com/Psiphon-Labs/psiphon-tls v0.0.0-20240305020009-09f917290799 h1:dHFQz6jeIr2RdtlioyGIdJw2UfKF7G+g7GYnQxhbgrk=
@@ -25,8 +27,6 @@ github.com/armon/go-proxyproto v0.0.0-20180202201750-5b7edb60ff5f h1:SaJ6yqg936T
 github.com/armon/go-proxyproto v0.0.0-20180202201750-5b7edb60ff5f/go.mod h1:QmP9hvJ91BbJmGVGSbutW19IC0Q9phDCLGaomwTJbgU=
 github.com/bifurcation/mint v0.0.0-20180306135233-198357931e61 h1:BU+NxuoaYPIvvp8NNkNlLr8aA0utGyuunf4Q3LJ0bh0=
 github.com/bifurcation/mint v0.0.0-20180306135233-198357931e61/go.mod h1:zVt7zX3K/aDCk9Tj+VM7YymsX66ERvzCJzw8rFCX2JU=
-github.com/buraksezer/consistent v0.10.0 h1:hqBgz1PvNLC5rkWcEBVAL9dFMBWz6I0VgUCW25rrZlU=
-github.com/buraksezer/consistent v0.10.0/go.mod h1:6BrVajWq7wbKZlTOUPs/XVfR8c0maujuPowduSpZqmw=
 github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
 github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
 github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=

+ 3 - 3
psiphon/server/discovery/consistent.go

@@ -23,8 +23,8 @@ import (
 	"net"
 	"sync"
 
+	"github.com/Psiphon-Labs/consistent"
 	"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/server/psinet"
-	"github.com/buraksezer/consistent"
 	"github.com/cespare/xxhash"
 )
 
@@ -68,8 +68,8 @@ func (c *consistentHashingDiscovery) serversChanged(newServers []*psinet.Discove
 		// Note: requires full reinitialization because we cannot change
 		// PartitionCount on the fly. Add/Remove do not update PartitionCount
 		// and updating ParitionCount is required to ensure that there is not
-		// a panic in the buraksezer/consistent package and that all servers
-		// are discoverable.
+		// a panic in the consistent package and that all servers are
+		// discoverable.
 		c.config.PartitionCount = len(newServers)
 
 		c.RWMutex.Lock()

+ 1 - 1
psiphon/server/psinet/psinet.go

@@ -140,7 +140,7 @@ func NewDatabase(filename string) (*Database, error) {
 			//
 			// Also ensure that no servers share the same IP address, which is
 			// a requirement of consistent hashing discovery; otherwise it will
-			// panic in the underlying buraksezer/consistent package.
+			// panic in the underlying Psiphon-Labs/consistent package.
 			serverIPToDiagnosticID := make(map[string]string)
 			for i, server := range database.DiscoveryServers {
 

+ 0 - 0
vendor/github.com/buraksezer/consistent/.gitignore → vendor/github.com/Psiphon-Labs/consistent/.gitignore


+ 0 - 0
vendor/github.com/buraksezer/consistent/.travis.yml → vendor/github.com/Psiphon-Labs/consistent/.travis.yml


+ 0 - 0
vendor/github.com/buraksezer/consistent/LICENSE → vendor/github.com/Psiphon-Labs/consistent/LICENSE


+ 1 - 0
vendor/github.com/buraksezer/consistent/README.md → vendor/github.com/Psiphon-Labs/consistent/README.md

@@ -53,6 +53,7 @@ Notable Users
 
 * [buraksezer/olric](https://github.com/buraksezer/olric): Embeddable, distributed data structures in Go.
 * [open-telemetry/opentelemetry-operator](https://github.com/open-telemetry/opentelemetry-operator): Kubernetes Operator for OpenTelemetry Collector.
+* [giantswarm/starboard-exporter](https://github.com/giantswarm/starboard-exporter): Exposes Prometheus metrics from [Starboard](https://github.com/aquasecurity/starboard)'s `VulnerabilityReport`, `ConfigAuditReport`, and other custom resources (CRs).
 * [megaease/easegress](https://github.com/megaease/easegress): A Cloud Native traffic orchestration system.
 * [chrislusf/seaweedfs](https://github.com/chrislusf/seaweedfs): SeaweedFS is a distributed storage system for blobs, objects, files, and data warehouse, to store and serve billions of files fast!.
 * [erda-project/erda](https://github.com/erda-project/erda): An enterprise-grade Cloud-Native application platform for Kubernetes.

+ 5 - 1
vendor/github.com/buraksezer/consistent/consistent.go → vendor/github.com/Psiphon-Labs/consistent/consistent.go

@@ -186,7 +186,11 @@ func (c *Consistent) distributeWithLoad(partID, idx int, partitions map[int]*Mem
 	var count int
 	for {
 		count++
-		if count >= len(c.sortedSet) {
+		// [Psiphon]
+		// Fix: changed ">=" to ">"; otherwise tests showed that 1 member may
+		// be excluded when there is more than one member and that using a
+		// single member results in a crash.
+		if count > len(c.sortedSet) {
 			// User needs to decrease partition count, increase member count or increase load factor.
 			panic("not enough room to distribute partitions")
 		}

+ 3 - 3
vendor/modules.txt

@@ -17,6 +17,9 @@ github.com/Psiphon-Inc/rotate-safe-writer
 # github.com/Psiphon-Labs/bolt v0.0.0-20200624191537-23cedaef7ad7
 ## explicit; go 1.12
 github.com/Psiphon-Labs/bolt
+# github.com/Psiphon-Labs/consistent v0.0.0-20240322131436-20aaa4e05737
+## explicit; go 1.9
+github.com/Psiphon-Labs/consistent
 # github.com/Psiphon-Labs/goptlib v0.0.0-20200406165125-c0e32a7a3464
 ## explicit
 github.com/Psiphon-Labs/goptlib
@@ -51,9 +54,6 @@ github.com/armon/go-proxyproto
 ## explicit
 github.com/bifurcation/mint
 github.com/bifurcation/mint/syntax
-# github.com/buraksezer/consistent v0.10.0
-## explicit; go 1.9
-github.com/buraksezer/consistent
 # github.com/cespare/xxhash v1.1.0
 ## explicit
 github.com/cespare/xxhash