mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-08-23 17:47:24 +00:00
Convert to default net ports provided by btcnet.
ok @jrick
This commit is contained in:
parent
74303966c0
commit
252c022644
4 changed files with 19 additions and 27 deletions
|
@ -481,7 +481,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
// we are to connect to.
|
// we are to connect to.
|
||||||
if len(cfg.Listeners) == 0 {
|
if len(cfg.Listeners) == 0 {
|
||||||
cfg.Listeners = []string{
|
cfg.Listeners = []string{
|
||||||
net.JoinHostPort("", activeNetParams.listenPort),
|
net.JoinHostPort("", activeNetParams.DefaultPort),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
// Add default port to all listener addresses if needed and remove
|
// Add default port to all listener addresses if needed and remove
|
||||||
// duplicate addresses.
|
// duplicate addresses.
|
||||||
cfg.Listeners = normalizeAddresses(cfg.Listeners,
|
cfg.Listeners = normalizeAddresses(cfg.Listeners,
|
||||||
activeNetParams.listenPort)
|
activeNetParams.DefaultPort)
|
||||||
|
|
||||||
// Add default port to all rpc listener addresses if needed and remove
|
// Add default port to all rpc listener addresses if needed and remove
|
||||||
// duplicate addresses.
|
// duplicate addresses.
|
||||||
|
@ -555,9 +555,9 @@ func loadConfig() (*config, []string, error) {
|
||||||
// Add default port to all added peer addresses if needed and remove
|
// Add default port to all added peer addresses if needed and remove
|
||||||
// duplicate addresses.
|
// duplicate addresses.
|
||||||
cfg.AddPeers = normalizeAddresses(cfg.AddPeers,
|
cfg.AddPeers = normalizeAddresses(cfg.AddPeers,
|
||||||
activeNetParams.peerPort)
|
activeNetParams.DefaultPort)
|
||||||
cfg.ConnectPeers = normalizeAddresses(cfg.ConnectPeers,
|
cfg.ConnectPeers = normalizeAddresses(cfg.ConnectPeers,
|
||||||
activeNetParams.peerPort)
|
activeNetParams.DefaultPort)
|
||||||
|
|
||||||
// Setup dial and DNS resolution (lookup) functions depending on the
|
// Setup dial and DNS resolution (lookup) functions depending on the
|
||||||
// specified options. The default is to use the standard net.Dial
|
// specified options. The default is to use the standard net.Dial
|
||||||
|
|
26
params.go
26
params.go
|
@ -17,10 +17,8 @@ var activeNetParams = &mainNetParams
|
||||||
// network and test networks.
|
// network and test networks.
|
||||||
type params struct {
|
type params struct {
|
||||||
*btcnet.Params
|
*btcnet.Params
|
||||||
peerPort string
|
rpcPort string
|
||||||
listenPort string
|
dnsSeeds []string
|
||||||
rpcPort string
|
|
||||||
dnsSeeds []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mainNetParams contains parameters specific to the main network
|
// mainNetParams contains parameters specific to the main network
|
||||||
|
@ -30,10 +28,8 @@ type params struct {
|
||||||
// it does not handle on to btcd. This approach allows the wallet process
|
// it does not handle on to btcd. This approach allows the wallet process
|
||||||
// to emulate the full reference implementation RPC API.
|
// to emulate the full reference implementation RPC API.
|
||||||
var mainNetParams = params{
|
var mainNetParams = params{
|
||||||
Params: &btcnet.MainNetParams,
|
Params: &btcnet.MainNetParams,
|
||||||
listenPort: btcwire.MainPort,
|
rpcPort: "8334",
|
||||||
peerPort: btcwire.MainPort,
|
|
||||||
rpcPort: "8334",
|
|
||||||
dnsSeeds: []string{
|
dnsSeeds: []string{
|
||||||
"seed.bitcoin.sipa.be",
|
"seed.bitcoin.sipa.be",
|
||||||
"dnsseed.bluematt.me",
|
"dnsseed.bluematt.me",
|
||||||
|
@ -49,21 +45,17 @@ var mainNetParams = params{
|
||||||
// than the reference implementation - see the mainNetParams comment for
|
// than the reference implementation - see the mainNetParams comment for
|
||||||
// details.
|
// details.
|
||||||
var regressionNetParams = params{
|
var regressionNetParams = params{
|
||||||
Params: &btcnet.RegressionNetParams,
|
Params: &btcnet.RegressionNetParams,
|
||||||
listenPort: btcwire.RegressionTestPort,
|
rpcPort: "18334",
|
||||||
peerPort: btcwire.TestNetPort,
|
dnsSeeds: []string{},
|
||||||
rpcPort: "18334",
|
|
||||||
dnsSeeds: []string{},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// testNet3Params contains parameters specific to the test network (version 3)
|
// testNet3Params contains parameters specific to the test network (version 3)
|
||||||
// (btcwire.TestNet3). NOTE: The RPC port is intentionally different than the
|
// (btcwire.TestNet3). NOTE: The RPC port is intentionally different than the
|
||||||
// reference implementation - see the mainNetParams comment for details.
|
// reference implementation - see the mainNetParams comment for details.
|
||||||
var testNet3Params = params{
|
var testNet3Params = params{
|
||||||
Params: &btcnet.TestNet3Params,
|
Params: &btcnet.TestNet3Params,
|
||||||
listenPort: btcwire.TestNetPort,
|
rpcPort: "18334",
|
||||||
peerPort: btcwire.TestNetPort,
|
|
||||||
rpcPort: "18334",
|
|
||||||
dnsSeeds: []string{
|
dnsSeeds: []string{
|
||||||
"testnet-seed.bitcoin.petertodd.org",
|
"testnet-seed.bitcoin.petertodd.org",
|
||||||
"testnet-seed.bluematt.me",
|
"testnet-seed.bluematt.me",
|
||||||
|
|
|
@ -513,7 +513,7 @@ func handleAskWallet(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
||||||
func handleAddNode(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
func handleAddNode(s *rpcServer, cmd btcjson.Cmd) (interface{}, error) {
|
||||||
c := cmd.(*btcjson.AddNodeCmd)
|
c := cmd.(*btcjson.AddNodeCmd)
|
||||||
|
|
||||||
addr := normalizeAddress(c.Addr, activeNetParams.peerPort)
|
addr := normalizeAddress(c.Addr, activeNetParams.DefaultPort)
|
||||||
var err error
|
var err error
|
||||||
switch c.SubCmd {
|
switch c.SubCmd {
|
||||||
case "add":
|
case "add":
|
||||||
|
|
10
server.go
10
server.go
|
@ -468,7 +468,7 @@ func (s *server) seedFromDNS() {
|
||||||
}
|
}
|
||||||
addresses := make([]*btcwire.NetAddress, len(seedpeers))
|
addresses := make([]*btcwire.NetAddress, len(seedpeers))
|
||||||
// if this errors then we have *real* problems
|
// if this errors then we have *real* problems
|
||||||
intPort, _ := strconv.Atoi(activeNetParams.peerPort)
|
intPort, _ := strconv.Atoi(activeNetParams.DefaultPort)
|
||||||
for i, peer := range seedpeers {
|
for i, peer := range seedpeers {
|
||||||
addresses[i] = new(btcwire.NetAddress)
|
addresses[i] = new(btcwire.NetAddress)
|
||||||
addresses[i].SetAddress(peer, uint16(intPort))
|
addresses[i].SetAddress(peer, uint16(intPort))
|
||||||
|
@ -621,7 +621,7 @@ out:
|
||||||
|
|
||||||
// allow nondefault ports after 50 failed tries.
|
// allow nondefault ports after 50 failed tries.
|
||||||
if fmt.Sprintf("%d", addr.na.Port) !=
|
if fmt.Sprintf("%d", addr.na.Port) !=
|
||||||
activeNetParams.peerPort && tries < 50 {
|
activeNetParams.DefaultPort && tries < 50 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,7 +956,7 @@ func (s *server) upnpUpdateThread() {
|
||||||
// Go off immediately to prevent code duplication, thereafter we renew
|
// Go off immediately to prevent code duplication, thereafter we renew
|
||||||
// lease every 15 minutes.
|
// lease every 15 minutes.
|
||||||
timer := time.NewTimer(0 * time.Second)
|
timer := time.NewTimer(0 * time.Second)
|
||||||
lport, _ := strconv.ParseInt(activeNetParams.listenPort, 10, 16)
|
lport, _ := strconv.ParseInt(activeNetParams.DefaultPort, 10, 16)
|
||||||
first := true
|
first := true
|
||||||
out:
|
out:
|
||||||
for {
|
for {
|
||||||
|
@ -1028,7 +1028,7 @@ func newServer(listenAddrs []string, db btcdb.Db, netParams *btcnet.Params) (*se
|
||||||
discover = false
|
discover = false
|
||||||
// if this fails we have real issues.
|
// if this fails we have real issues.
|
||||||
port, _ := strconv.ParseUint(
|
port, _ := strconv.ParseUint(
|
||||||
activeNetParams.listenPort, 10, 16)
|
activeNetParams.DefaultPort, 10, 16)
|
||||||
|
|
||||||
for _, sip := range cfg.ExternalIPs {
|
for _, sip := range cfg.ExternalIPs {
|
||||||
eport := uint16(port)
|
eport := uint16(port)
|
||||||
|
@ -1069,7 +1069,7 @@ func newServer(listenAddrs []string, db btcdb.Db, netParams *btcnet.Params) (*se
|
||||||
// TODO(oga) nonstandard port...
|
// TODO(oga) nonstandard port...
|
||||||
if wildcard {
|
if wildcard {
|
||||||
port, err :=
|
port, err :=
|
||||||
strconv.ParseUint(activeNetParams.listenPort,
|
strconv.ParseUint(activeNetParams.DefaultPort,
|
||||||
10, 16)
|
10, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// I can't think of a cleaner way to do this...
|
// I can't think of a cleaner way to do this...
|
||||||
|
|
Loading…
Add table
Reference in a new issue