package dcsimport ()// FindDCs searches DCs candidates from given config.func ( []tg.DCOption, int, bool) []tg.DCOption {// Preallocate slice. := make([]tg.DCOption, 0, 32)for , := range {if .ID != {continue } = append(, ) }iflen() < 1 {returnnil }sort.Slice(, func(, int) bool { , := [], []// If we prefer IPv6 and left is IPv6 and right is not, so then // left is smaller (would be before right).if {if .Ipv6 && !.Ipv6 {returntrue }if !.Ipv6 && .Ipv6 {returnfalse } }// Also we prefer static addresses.return .Static && !.Static })return}// FindPrimaryDCs searches new primary DC from given config.// Unlike FindDC, it filters CDNs and MediaOnly servers, returns error// if not found.func ( []tg.DCOption, int, bool) []tg.DCOption { := FindDCs(, , )// Filter (in place) from SliceTricks. := 0for , := range {if !.MediaOnly && !.CDN { [] = ++ } }return [:]}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.