From 15985763a6d8b7f783821cf04daa7e5006970eb4 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 3 Mar 2026 23:19:43 -0600 Subject: [PATCH 1/3] connmgr: Move to internal. This makes the connmgr package an internal package such that it will no longer be an exported module. The only place its functionality is really needed is for the internal implementation of dcrd itself and thus having an unnecessary exported module significantly increases the maintenance burden. It is worth noting that there are a few things, which will be listed below, that were exported from this module that callers might have previously relied upon. These things have been moved to the address manager module. The aforementioned methods and types are: - TorLookupIP method and all associated ErrX constants - HttpsSeederFilters struct - DialFunc method - SeedFilterIPVersion method - SeedFilterProtocolVersion method - SeedFilterServices method - SeedAddrs method Overview of the major changes: - Move the following files from connmgr -> internal/connmgr: - README.md - connmanager.go - connmanager_test.go - doc.go - dynamicbanscore.go - dynamicbanscore_test.go - error.go - error_test.go - log.go - Remove connmgr/go.mod and connmgr/go.sum - Make the README.md and docs.go files match the new reality - Update all import paths in the repository accordingly - Remove the dependency from the root go.mod - Run go mod tidy on all modules --- connmgr/go.mod | 19 -- connmgr/go.sum | 19 -- connmgr/seed.go | 202 ------------------ connmgr/tor.go | 137 ------------ go.mod | 2 - {connmgr => internal/connmgr}/README.md | 13 +- {connmgr => internal/connmgr}/connmanager.go | 0 .../connmgr}/connmanager_test.go | 0 {connmgr => internal/connmgr}/doc.go | 0 .../connmgr}/dynamicbanscore.go | 0 .../connmgr}/dynamicbanscore_test.go | 0 {connmgr => internal/connmgr}/error.go | 0 {connmgr => internal/connmgr}/error_test.go | 0 {connmgr => internal/connmgr}/log.go | 0 log.go | 4 +- rpcadaptors.go | 2 +- server.go | 2 +- 17 files changed, 5 insertions(+), 395 deletions(-) delete mode 100644 connmgr/go.mod delete mode 100644 connmgr/go.sum delete mode 100644 connmgr/seed.go delete mode 100644 connmgr/tor.go rename {connmgr => internal/connmgr}/README.md (76%) rename {connmgr => internal/connmgr}/connmanager.go (100%) rename {connmgr => internal/connmgr}/connmanager_test.go (100%) rename {connmgr => internal/connmgr}/doc.go (100%) rename {connmgr => internal/connmgr}/dynamicbanscore.go (100%) rename {connmgr => internal/connmgr}/dynamicbanscore_test.go (100%) rename {connmgr => internal/connmgr}/error.go (100%) rename {connmgr => internal/connmgr}/error_test.go (100%) rename {connmgr => internal/connmgr}/log.go (100%) diff --git a/connmgr/go.mod b/connmgr/go.mod deleted file mode 100644 index f844bf881e..0000000000 --- a/connmgr/go.mod +++ /dev/null @@ -1,19 +0,0 @@ -// Deprecated: Use github.com/decred/dcrd/addrmgr/vX instead. -module github.com/decred/dcrd/connmgr/v3 - -go 1.18 - -require ( - github.com/decred/dcrd/crypto/rand v1.0.1 - github.com/decred/dcrd/wire v1.7.1 - github.com/decred/slog v1.2.0 -) - -require ( - github.com/decred/dcrd/chaincfg/chainhash v1.0.5 // indirect - github.com/decred/dcrd/crypto/blake256 v1.1.0 // indirect - github.com/klauspost/cpuid/v2 v2.0.9 // indirect - golang.org/x/crypto v0.33.0 // indirect - golang.org/x/sys v0.30.0 // indirect - lukechampine.com/blake3 v1.3.0 // indirect -) diff --git a/connmgr/go.sum b/connmgr/go.sum deleted file mode 100644 index 16a88493d6..0000000000 --- a/connmgr/go.sum +++ /dev/null @@ -1,19 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/decred/dcrd/chaincfg/chainhash v1.0.5 h1:GwzXLsZoemdDxFdtj3GdW25Z+NXdN6nD3OjVtA+UwiE= -github.com/decred/dcrd/chaincfg/chainhash v1.0.5/go.mod h1:vCqZMGtKbyxJkdcVzP3Ryc9IvaspVUb7hO6t+rjxmcs= -github.com/decred/dcrd/crypto/blake256 v1.1.0 h1:zPMNGQCm0g4QTY27fOCorQW7EryeQ/U0x++OzVrdms8= -github.com/decred/dcrd/crypto/blake256 v1.1.0/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= -github.com/decred/dcrd/crypto/rand v1.0.1 h1:pYMgDRmRv1z1RNgAAs8izJstm4B+fLFiqGD5btOt2Wg= -github.com/decred/dcrd/crypto/rand v1.0.1/go.mod h1:MsA2XySk/4KpCOYW6vsNYTGuOYRK1wpvulaWCuW7RyI= -github.com/decred/dcrd/wire v1.7.1 h1:kDuHBiY1Qv9rBxYKgC2RgyPy7IOA2WRf00jqHwpr16I= -github.com/decred/dcrd/wire v1.7.1/go.mod h1:eP9XRsMloy+phlntkTAaAm611JgLv8NqY1YJoRxkNKU= -github.com/decred/slog v1.2.0 h1:soHAxV52B54Di3WtKLfPum9OFfWqwtf/ygf9njdfnPM= -github.com/decred/slog v1.2.0/go.mod h1:kVXlGnt6DHy2fV5OjSeuvCJ0OmlmTF6LFpEPMu/fOY0= -github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= -lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= diff --git a/connmgr/seed.go b/connmgr/seed.go deleted file mode 100644 index 37a2ef1bab..0000000000 --- a/connmgr/seed.go +++ /dev/null @@ -1,202 +0,0 @@ -// Copyright (c) 2016 The btcsuite developers -// Copyright (c) 2019-2024 The Decred developers -// Use of this source code is governed by an ISC -// license that can be found in the LICENSE file. - -package connmgr - -import ( - "context" - "encoding/json" - "fmt" - "io" - "net" - "net/http" - "strconv" - "time" - - "github.com/decred/dcrd/crypto/rand" - "github.com/decred/dcrd/wire" -) - -const ( - // These constants are used by the seed code to pick a random last - // seen time. - duration3Days = 24 * time.Hour * 3 - duration4Days = 24 * time.Hour * 4 -) - -// DialFunc is the signature of the Dialer function. -type DialFunc func(context.Context, string, string) (net.Conn, error) - -// HttpsSeederFilters houses filter parameters for use when making a request to -// an HTTPS seeder. It can be configured via the various exported functions -// that start with the prefix SeedFilter. -type HttpsSeederFilters struct { - ipVersion uint16 - hasIPVersion bool - pver uint32 - hasPver bool - services wire.ServiceFlag - hasServices bool -} - -// SeedFilterIPVersion configures a request to an HTTPS seeder to filter all -// results that are not the provided ip version, which is expected to be either -// 4 or 6, to indicate IPv4 or IPv6 addresses, respectively. The HTTPS seeder -// may choose to ignore other IP versions. -func SeedFilterIPVersion(ipVersion uint16) func(f *HttpsSeederFilters) { - return func(f *HttpsSeederFilters) { - f.ipVersion = ipVersion - f.hasIPVersion = true - } -} - -// SeedFilterProtocolVersion configures a request to an HTTPS seeder to filter -// all results that are not the provided peer-to-peer protocol version. This -// can be useful to discover peers that support specific peer versions. -func SeedFilterProtocolVersion(pver uint32) func(f *HttpsSeederFilters) { - return func(f *HttpsSeederFilters) { - f.pver = pver - f.hasPver = true - } -} - -// SeedFilterServices configures a request to an HTTPS seeder to filter all -// results that do not support the provided service flags. This can be useful -// to discover peers that support specific services such as fully-validating -// nodes. -func SeedFilterServices(services wire.ServiceFlag) func(f *HttpsSeederFilters) { - return func(f *HttpsSeederFilters) { - f.services = services - f.hasServices = true - } -} - -// node defines a single JSON object returned by the https seeders. -type node struct { - Host string `json:"host"` - Services uint64 `json:"services"` - ProtocolVersion uint32 `json:"pver"` -} - -// SeedAddrs uses HTTPS seeding to return a list of addresses of p2p peers on -// the network. -// -// The seeder parameter specifies the domain name of the seed. The dial -// function specifies the dialer to use to contact the HTTPS seeder and allows -// the caller to use whatever configuration it deems fit such as using a proxy, -// like Tor. -// -// The variadic filters parameter allows additional query filters to be applied. -// The available filters can be set via the exported functions that start with -// the prefix SeedFilter. See the documentation for each function for more -// details. -func SeedAddrs(ctx context.Context, seeder string, dialFn DialFunc, filters ...func(f *HttpsSeederFilters)) ([]*wire.NetAddress, error) { - // Set any caller provided filters. - var seederFilters HttpsSeederFilters - for _, f := range filters { - f(&seederFilters) - } - - // Setup the HTTPS request. - url := "https://" + seeder - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) - if err != nil { - return nil, err - } - req.URL.Path = "/api/addrs" - - // Configure the query parameters based on the caller-provided filters. - queryParams := req.URL.Query() - if seederFilters.hasIPVersion { - ipVersionStr := strconv.FormatInt(int64(seederFilters.ipVersion), 10) - queryParams.Add("ipversion", ipVersionStr) - } - if seederFilters.hasPver { - pverStr := strconv.FormatInt(int64(seederFilters.pver), 10) - queryParams.Add("pver", pverStr) - } - if seederFilters.hasServices { - servicesStr := strconv.FormatUint(uint64(seederFilters.services), 10) - queryParams.Add("services", servicesStr) - } - req.URL.RawQuery = queryParams.Encode() - - // Make the request. - client := &http.Client{ - Transport: &http.Transport{ - DialContext: dialFn, - }, - } - resp, err := client.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("seeder %s returned invalid status code '%d': %v", - seeder, resp.StatusCode, http.StatusText(resp.StatusCode)) - } - - // Parse the JSON response. - const maxNodes = 16 - const maxRespSize = maxNodes * 256 - var nodes []node - dec := json.NewDecoder(io.LimitReader(resp.Body, maxRespSize)) - for ctx.Err() == nil && dec.More() { - var node node - if err = dec.Decode(&node); err != nil { - return nil, fmt.Errorf("unable to parse response: %w", err) - } - nodes = append(nodes, node) - if len(nodes) >= maxNodes { - break - } - } - - // Nothing more to do when no addresses are returned. - if len(nodes) == 0 { - log.Infof("0 addresses found from seeder %s", seeder) - return nil, nil - } - - // Convert the response to net addresses. - addrs := make([]*wire.NetAddress, 0, len(nodes)) - for _, node := range nodes { - host, portStr, err := net.SplitHostPort(node.Host) - if err != nil { - log.Warnf("seeder returned invalid host %q", node.Host) - continue - } - port, err := strconv.ParseUint(portStr, 10, 16) - if err != nil { - log.Warnf("seeder returned invalid port %q", node.Host) - continue - } - ip := net.ParseIP(host) - if ip == nil { - log.Warnf("seeder returned a hostname that is not an IP address %q", - host) - continue - } - - // Set the timestamp to a value randomly selected between 3 and 7 days - // ago in order to improve the ranking of peers discovered from seeders - // since they are a more authoritative source than other random peers. - ts := time.Now().Add(-1 * (duration3Days + rand.Duration(duration4Days))) - na := wire.NewNetAddressTimestamp(ts, wire.ServiceFlag(node.Services), - ip, uint16(port)) - addrs = append(addrs, na) - } - - if len(addrs) < len(nodes) { - log.Infof("%d addresses found from seeder %s (excluded %d invalid)", - len(addrs), seeder, len(nodes)-len(addrs)) - } else { - log.Infof("%d addresses found from seeder %s", len(addrs), seeder) - } - - return addrs, nil -} diff --git a/connmgr/tor.go b/connmgr/tor.go deleted file mode 100644 index b58bb35a88..0000000000 --- a/connmgr/tor.go +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) 2013-2016 The btcsuite developers -// Copyright (c) 2015-2019 The Decred developers -// Use of this source code is governed by an ISC -// license that can be found in the LICENSE file. - -package connmgr - -import ( - "context" - "encoding/binary" - "net" -) - -const ( - torGeneralError = 0x01 - torNotAllowed = 0x02 - torNetUnreachable = 0x03 - torHostUnreachable = 0x04 - torConnectionRefused = 0x05 - torTTLExpired = 0x06 - torCmdNotSupported = 0x07 - torAddrNotSupported = 0x08 - - torATypeIPv4 = 1 - torATypeDomainName = 3 - torATypeIPv6 = 4 - - torCmdResolve = 240 -) - -var ( - torStatusErrors = map[byte]error{ - torGeneralError: MakeError(ErrTorGeneralError, "tor general error"), - torNotAllowed: MakeError(ErrTorNotAllowed, "tor not allowed"), - torNetUnreachable: MakeError(ErrTorNetUnreachable, "tor network is unreachable"), - torHostUnreachable: MakeError(ErrTorHostUnreachable, "tor host is unreachable"), - torConnectionRefused: MakeError(ErrTorConnectionRefused, "tor connection refused"), - torTTLExpired: MakeError(ErrTorTTLExpired, "tor TTL expired"), - torCmdNotSupported: MakeError(ErrTorCmdNotSupported, "tor command not supported"), - torAddrNotSupported: MakeError(ErrTorAddrNotSupported, "tor address type not supported"), - } -) - -// TorLookupIP uses Tor to resolve DNS via the passed SOCKS proxy. -func TorLookupIP(ctx context.Context, host, proxy string) ([]net.IP, error) { - var dialer net.Dialer - conn, err := dialer.DialContext(ctx, "tcp", proxy) - if err != nil { - return nil, err - } - defer conn.Close() - - buf := []byte{0x05, 0x01, 0x00} - _, err = conn.Write(buf) - if err != nil { - return nil, err - } - - buf = make([]byte, 2) - _, err = conn.Read(buf) - if err != nil { - return nil, err - } - if buf[0] != 0x05 { - return nil, MakeError(ErrTorInvalidProxyResponse, - "invalid SOCKS proxy version") - } - if buf[1] != 0x00 { - return nil, MakeError(ErrTorUnrecognizedAuthMethod, - "invalid proxy authentication method") - } - - buf = make([]byte, 7+len(host)) - buf[0] = 5 // socks protocol version - buf[1] = torCmdResolve - buf[2] = 0 // reserved - buf[3] = torATypeDomainName - buf[4] = byte(len(host)) - copy(buf[5:], host) - buf[5+len(host)] = 0 // Port 0 - - _, err = conn.Write(buf) - if err != nil { - return nil, err - } - - buf = make([]byte, 4) - _, err = conn.Read(buf) - if err != nil { - return nil, err - } - if buf[0] != 5 { - return nil, MakeError(ErrTorInvalidProxyResponse, - "invalid SOCKS proxy version") - } - if buf[1] != 0 { - err, exists := torStatusErrors[buf[1]] - if !exists { - err = MakeError(ErrTorInvalidProxyResponse, - "invalid SOCKS proxy version") - } - return nil, err - } - if buf[3] != torATypeIPv4 && buf[3] != torATypeIPv6 { - return nil, MakeError(ErrTorInvalidAddressResponse, - "invalid IP address") - } - - var reply [32 + 2]byte - replyLen, err := conn.Read(reply[:]) - if err != nil { - return nil, err - } - - var addr net.IP - switch buf[3] { - case torATypeIPv4: - if replyLen != 4+2 { - return nil, MakeError(ErrTorInvalidAddressResponse, - "invalid IPV4 address") - } - r := binary.BigEndian.Uint32(reply[0:4]) - addr = net.IPv4(byte(r>>24), byte(r>>16), - byte(r>>8), byte(r)) - case torATypeIPv6: - if replyLen <= 4+2 { - return nil, MakeError(ErrTorInvalidAddressResponse, - "invalid IPV6 address") - } - addr = net.IP(reply[0 : replyLen-2]) - default: - return nil, MakeError(ErrTorInvalidAddressResponse, - "unknown address type") - } - - return []net.IP{addr}, nil -} diff --git a/go.mod b/go.mod index 84527268d4..c19e23bcb8 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( github.com/decred/dcrd/certgen v1.2.0 github.com/decred/dcrd/chaincfg/chainhash v1.0.5 github.com/decred/dcrd/chaincfg/v3 v3.3.0 - github.com/decred/dcrd/connmgr/v3 v3.1.3 github.com/decred/dcrd/container/apbf v1.0.1 github.com/decred/dcrd/container/lru v1.0.0 github.com/decred/dcrd/crypto/blake256 v1.1.0 @@ -69,7 +68,6 @@ replace ( github.com/decred/dcrd/certgen => ./certgen github.com/decred/dcrd/chaincfg/chainhash => ./chaincfg/chainhash github.com/decred/dcrd/chaincfg/v3 => ./chaincfg - github.com/decred/dcrd/connmgr/v3 => ./connmgr github.com/decred/dcrd/container/apbf => ./container/apbf github.com/decred/dcrd/container/lru => ./container/lru github.com/decred/dcrd/crypto/blake256 => ./crypto/blake256 diff --git a/connmgr/README.md b/internal/connmgr/README.md similarity index 76% rename from connmgr/README.md rename to internal/connmgr/README.md index 000a9f8d06..46114366ae 100644 --- a/connmgr/README.md +++ b/internal/connmgr/README.md @@ -3,16 +3,10 @@ connmgr [![Build Status](https://github.com/decred/dcrd/workflows/Build%20and%20Test/badge.svg)](https://github.com/decred/dcrd/actions) [![ISC License](https://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) -[![Doc](https://img.shields.io/badge/doc-reference-blue.svg)](https://pkg.go.dev/github.com/decred/dcrd/connmgr/v3) +[![Doc](https://img.shields.io/badge/doc-reference-blue.svg)](https://pkg.go.dev/github.com/decred/dcrd/internal/connmgr) Package connmgr implements a generic Decred network connection manager. -## Deprecated - -This module is deprecated and is no longer maintained. Callers are encouraged -to use `github.com/decred/dcrd/addrmgr/vX` for methods that were moved to it -instead. - ## Overview This package handles all the general connection concerns such as maintaining a @@ -32,11 +26,6 @@ In addition the connection manager provides the following utilities: - Permanent connections with increasing backoff retry timers - Disconnect or Remove an established connection -## Installation and Updating - -This package is part of the `github.com/decred/dcrd/connmgr/v3` module. Use the -standard go tooling for working with modules to incorporate it. - ## License Package connmgr is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/connmgr/connmanager.go b/internal/connmgr/connmanager.go similarity index 100% rename from connmgr/connmanager.go rename to internal/connmgr/connmanager.go diff --git a/connmgr/connmanager_test.go b/internal/connmgr/connmanager_test.go similarity index 100% rename from connmgr/connmanager_test.go rename to internal/connmgr/connmanager_test.go diff --git a/connmgr/doc.go b/internal/connmgr/doc.go similarity index 100% rename from connmgr/doc.go rename to internal/connmgr/doc.go diff --git a/connmgr/dynamicbanscore.go b/internal/connmgr/dynamicbanscore.go similarity index 100% rename from connmgr/dynamicbanscore.go rename to internal/connmgr/dynamicbanscore.go diff --git a/connmgr/dynamicbanscore_test.go b/internal/connmgr/dynamicbanscore_test.go similarity index 100% rename from connmgr/dynamicbanscore_test.go rename to internal/connmgr/dynamicbanscore_test.go diff --git a/connmgr/error.go b/internal/connmgr/error.go similarity index 100% rename from connmgr/error.go rename to internal/connmgr/error.go diff --git a/connmgr/error_test.go b/internal/connmgr/error_test.go similarity index 100% rename from connmgr/error_test.go rename to internal/connmgr/error_test.go diff --git a/connmgr/log.go b/internal/connmgr/log.go similarity index 100% rename from connmgr/log.go rename to internal/connmgr/log.go diff --git a/log.go b/log.go index 879cf26c3b..0ece7c99be 100644 --- a/log.go +++ b/log.go @@ -1,5 +1,5 @@ // Copyright (c) 2013-2017 The btcsuite developers -// Copyright (c) 2015-2025 The Decred developers +// Copyright (c) 2015-2026 The Decred developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. @@ -12,10 +12,10 @@ import ( "github.com/decred/dcrd/addrmgr/v4" "github.com/decred/dcrd/blockchain/stake/v5" - "github.com/decred/dcrd/connmgr/v3" "github.com/decred/dcrd/database/v3" "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/blockchain/indexers" + "github.com/decred/dcrd/internal/connmgr" "github.com/decred/dcrd/internal/fees" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" diff --git a/rpcadaptors.go b/rpcadaptors.go index 981014c47a..4fc908de05 100644 --- a/rpcadaptors.go +++ b/rpcadaptors.go @@ -13,9 +13,9 @@ import ( "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" - "github.com/decred/dcrd/connmgr/v3" "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/dcrd/internal/blockchain" + "github.com/decred/dcrd/internal/connmgr" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" "github.com/decred/dcrd/internal/mining/cpuminer" diff --git a/server.go b/server.go index 2bdaf91900..d10c47d3dc 100644 --- a/server.go +++ b/server.go @@ -30,7 +30,6 @@ import ( "github.com/decred/dcrd/certgen" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/decred/dcrd/chaincfg/v3" - "github.com/decred/dcrd/connmgr/v3" "github.com/decred/dcrd/container/apbf" "github.com/decred/dcrd/container/lru" "github.com/decred/dcrd/crypto/rand" @@ -38,6 +37,7 @@ import ( "github.com/decred/dcrd/dcrutil/v4" "github.com/decred/dcrd/internal/blockchain" "github.com/decred/dcrd/internal/blockchain/indexers" + "github.com/decred/dcrd/internal/connmgr" "github.com/decred/dcrd/internal/fees" "github.com/decred/dcrd/internal/mempool" "github.com/decred/dcrd/internal/mining" From 640327e2367d1f0e5fe4140f72b2c3c8b0cf4328 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Tue, 3 Mar 2026 23:47:06 -0600 Subject: [PATCH 2/3] docs: Update for removal of connmgr module. --- docs/README.md | 2 - docs/assets/module_hierarchy.gv | 5 +- docs/assets/module_hierarchy.svg | 350 +++++++++++++++---------------- 3 files changed, 167 insertions(+), 190 deletions(-) diff --git a/docs/README.md b/docs/README.md index 26a47f693f..da8556a9e8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -213,8 +213,6 @@ The following versioned modules are provided by dcrd repository: encrypting RPC and websocket communications * [addrmgr/v3](https://github.com/decred/dcrd/tree/master/addrmgr) - Provides a concurrency safe Decred network address manager -* [connmgr/v3](https://github.com/decred/dcrd/tree/master/connmgr) - Implements - a generic Decred network connection manager * [hdkeychain/v3](https://github.com/decred/dcrd/tree/master/hdkeychain) - Provides an API for working with Decred hierarchical deterministic extended keys diff --git a/docs/assets/module_hierarchy.gv b/docs/assets/module_hierarchy.gv index 1efdbd7aa9..0d7eeb2518 100644 --- a/docs/assets/module_hierarchy.gv +++ b/docs/assets/module_hierarchy.gv @@ -27,7 +27,6 @@ digraph { peer [label="peer/v3" fillcolor=khaki] rpcclient [label="rpcclient/v8" fillcolor=mediumseagreen] addrmgr [label="addrmgr/v3" fillcolor=lightsalmon] - connmgr [label="connmgr/v3" fillcolor=mistyrose] blockchain [label="blockchain/v5" fillcolor=orchid] apbf [label="container/apbf" fillcolor=goldenrod] uint256 [label="math/uint256" fillcolor=lightgreen] @@ -36,7 +35,7 @@ digraph { {rank=same blake256 chainhash} {rank=same dcrec secp256k1} {rank=same certgen bech32 apbf uint256 mixing} - {rank=same addrmgr connmgr hdkeychain peer blockchain standalone rpcclient} + {rank=same addrmgr hdkeychain peer blockchain standalone rpcclient} certgen bech32 @@ -47,7 +46,6 @@ digraph { chainhash -> wire [dir=back color=aquamarine] wire -> addrmgr [dir=back color=coral] wire -> chaincfg [dir=back color=coral] - wire -> connmgr [dir=back color=coral] wire -> standalone [dir=back color=coral] ripemd160 -> txscript [dir=back color=darkturquoise] dcrec -> txscript [dir=back color=mediumpurple] @@ -75,7 +73,6 @@ digraph { bech32 -> dcrd [dir=back color=antiquewhite3] addrmgr -> dcrd [dir=back color=lightsalmon] hdkeychain -> dcrd [dir=back color=deepskyblue] - connmgr -> dcrd [dir=back color=mistyrose] rpcclient -> dcrd [dir=back color=mediumseagreen] peer -> dcrd [dir=back color=khaki] apbf -> dcrd [dir=back color=goldenrod] diff --git a/docs/assets/module_hierarchy.svg b/docs/assets/module_hierarchy.svg index 543b205480..f772ebde7b 100644 --- a/docs/assets/module_hierarchy.svg +++ b/docs/assets/module_hierarchy.svg @@ -4,418 +4,400 @@ - + - -Module Hierarchy + +Module Hierarchy blake256 - -crypto/blake256 + +crypto/blake256 chainhash - -chaincfg/chainhash + +chaincfg/chainhash blake256->chainhash - - + + secp256k1 - -dcrec/secp256k1/v4 + +dcrec/secp256k1/v4 blake256->secp256k1 - - + + ripemd160 - -crypto/ripemd160 + +crypto/ripemd160 txscript - -txscript/v4 + +txscript/v4 - + ripemd160->txscript - - + + rand -crypto/rand +crypto/rand - + dcrd - -dcrd + +dcrd - + rand->dcrd - - + + certgen - -certgen + +certgen - + certgen->dcrd - - + + bech32 - -bech32 + +bech32 - + bech32->dcrd - - + + dcrjson - -dcrjson/v4 + +dcrjson/v4 chainhash->dcrjson - - + + wire - -wire + +wire chainhash->wire - - + + types - -rpc/jsonrpc/types/v4 + +rpc/jsonrpc/types/v4 - + dcrjson->types - - + + rpcclient - -rpcclient/v8 + +rpcclient/v8 - + types->rpcclient - - + + chaincfg - -chaincfg/v3 + +chaincfg/v3 wire->chaincfg - - + + standalone - -blockchain/standalone/v2 + +blockchain/standalone/v2 - + wire->standalone - - + + addrmgr - -addrmgr/v3 + +addrmgr/v3 wire->addrmgr - - - - - -connmgr - -connmgr/v3 - - - -wire->connmgr - - + + chaincfg->txscript - - + + dcrec - -dcrec + +dcrec - + dcrec->txscript - - + + edwards - -dcrec/edwards/v2 + +dcrec/edwards/v2 - + edwards->txscript - - + + - + secp256k1->txscript - - + + dcrutil - -dcrutil/v4 + +dcrutil/v4 mixing - -mixing + +mixing - + dcrutil->mixing - - + + database - -database/v3 + +database/v3 - + dcrutil->database - - + + - + blockchain - -blockchain/v5 + +blockchain/v5 - + dcrutil->blockchain - - + + - + mixing->dcrd - - + + stake - -blockchain/stake/v5 + +blockchain/stake/v5 - + database->stake - - + + hdkeychain - -hdkeychain/v3 + +hdkeychain/v3 - + hdkeychain->dcrd - - + + - + txscript->dcrutil - - + + - + txscript->hdkeychain - - + + peer - -peer/v3 + +peer/v3 - + txscript->peer - - + + gcs - -gcs/v4 + +gcs/v4 - + stake->gcs - - + + - + gcs->rpcclient - - + + - + standalone->dcrd - - + + lru - -container/lru + +container/lru - + lru->peer - - + + - + peer->dcrd - - + + - + rpcclient->dcrd - - + + - + addrmgr->dcrd - - - - - -connmgr->dcrd - - + + - + blockchain->dcrd - - + + - + apbf - -container/apbf + +container/apbf - + apbf->dcrd - - + + - + uint256 - -math/uint256 + +math/uint256 - + uint256->dcrd - - + + From 5e1b5d89a48102f8b5ab305984ad8f8bf7d9b194 Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Wed, 4 Mar 2026 12:52:09 -0600 Subject: [PATCH 3/3] contrib: Drop connmgr in workspace script. This modifies the multimod go workspace setup script to remove the connmgr module now that it is an internal package. It also adds a directive to drop the use of the connmgr module from existing go.work files. --- contrib/devtools/dcr_setup_go_workspace.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/devtools/dcr_setup_go_workspace.sh b/contrib/devtools/dcr_setup_go_workspace.sh index 13fd9e0ff9..ac74abcaf3 100755 --- a/contrib/devtools/dcr_setup_go_workspace.sh +++ b/contrib/devtools/dcr_setup_go_workspace.sh @@ -32,12 +32,12 @@ if [ ! -f "go.work" ]; then fi # Remove old modules as needed -go work edit -dropuse ./lru +go work edit -dropuse ./lru -dropuse ./connmgr # Add all of the modules as needed go work use . ./addrmgr ./bech32 ./blockchain ./blockchain/stake go work use ./blockchain/standalone ./certgen ./chaincfg ./chaincfg/chainhash -go work use ./connmgr ./container/apbf ./container/lru ./crypto/blake256 +go work use ./container/apbf ./container/lru ./crypto/blake256 go work use ./crypto/rand ./crypto/ripemd160 ./database ./dcrec ./dcrec/edwards go work use ./dcrec/secp256k1 ./dcrjson ./dcrutil ./gcs ./hdkeychain go work use ./math/uint256 ./mixing ./peer ./rpc/jsonrpc/types ./rpcclient