mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
[devnet] separate logging p2p (#7549)
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro-2.local>
This commit is contained in:
parent
7272c00681
commit
c919283b0c
@ -108,7 +108,7 @@ func main() {
|
|||||||
realaddr := conn.LocalAddr().(*net.UDPAddr)
|
realaddr := conn.LocalAddr().(*net.UDPAddr)
|
||||||
if natm != nil {
|
if natm != nil {
|
||||||
if !realaddr.IP.IsLoopback() && natm.SupportsMapping() {
|
if !realaddr.IP.IsLoopback() && natm.SupportsMapping() {
|
||||||
go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "ethereum discovery")
|
go nat.Map(natm, nil, "udp", realaddr.Port, realaddr.Port, "ethereum discovery", logger)
|
||||||
}
|
}
|
||||||
if ext, err := natm.ExternalIP(); err == nil {
|
if ext, err := natm.ExternalIP(); err == nil {
|
||||||
realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port}
|
realaddr = &net.UDPAddr{IP: ext, Port: realaddr.Port}
|
||||||
|
@ -133,7 +133,7 @@ func (server *Server) mapNATPort(ctx context.Context, realAddr *net.UDPAddr) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer debug.LogPanic()
|
defer debug.LogPanic()
|
||||||
nat.Map(server.natInterface, ctx.Done(), "udp", realAddr.Port, realAddr.Port, "ethereum discovery")
|
nat.Map(server.natInterface, ctx.Done(), "udp", realAddr.Port, realAddr.Port, "ethereum discovery", server.logger)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
"github.com/ledgerwatch/erigon/crypto"
|
"github.com/ledgerwatch/erigon/crypto"
|
||||||
"github.com/ledgerwatch/erigon/p2p/discover/v4wire"
|
"github.com/ledgerwatch/erigon/p2p/discover/v4wire"
|
||||||
"github.com/ledgerwatch/erigon/p2p/enode"
|
"github.com/ledgerwatch/erigon/p2p/enode"
|
||||||
|
"github.com/ledgerwatch/log/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUDPv4_Lookup(t *testing.T) {
|
func TestUDPv4_Lookup(t *testing.T) {
|
||||||
@ -36,11 +37,12 @@ func TestUDPv4_Lookup(t *testing.T) {
|
|||||||
t.Skip("fix me on win please")
|
t.Skip("fix me on win please")
|
||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
logger := log.New()
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = contextWithReplyTimeout(ctx, time.Second)
|
ctx = contextWithReplyTimeout(ctx, time.Second)
|
||||||
|
|
||||||
test := newUDPTestContext(ctx, t)
|
test := newUDPTestContext(ctx, t, logger)
|
||||||
defer test.close()
|
defer test.close()
|
||||||
|
|
||||||
// Lookup on empty table returns no nodes.
|
// Lookup on empty table returns no nodes.
|
||||||
@ -74,6 +76,7 @@ func TestUDPv4_LookupIterator(t *testing.T) {
|
|||||||
t.Skip("fix me on win please")
|
t.Skip("fix me on win please")
|
||||||
}
|
}
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
logger := log.New()
|
||||||
|
|
||||||
// Set up RandomNodes() to use expected keys instead of generating random ones.
|
// Set up RandomNodes() to use expected keys instead of generating random ones.
|
||||||
testNetPrivateKeys := lookupTestnet.privateKeys()
|
testNetPrivateKeys := lookupTestnet.privateKeys()
|
||||||
@ -86,7 +89,7 @@ func TestUDPv4_LookupIterator(t *testing.T) {
|
|||||||
ctx = contextWithReplyTimeout(ctx, time.Second)
|
ctx = contextWithReplyTimeout(ctx, time.Second)
|
||||||
ctx = contextWithPrivateKeyGenerator(ctx, privateKeyGenerator)
|
ctx = contextWithPrivateKeyGenerator(ctx, privateKeyGenerator)
|
||||||
|
|
||||||
test := newUDPTestContext(ctx, t)
|
test := newUDPTestContext(ctx, t, logger)
|
||||||
defer test.close()
|
defer test.close()
|
||||||
|
|
||||||
// Seed table with initial nodes.
|
// Seed table with initial nodes.
|
||||||
@ -121,7 +124,8 @@ func TestUDPv4_LookupIterator(t *testing.T) {
|
|||||||
// method is called.
|
// method is called.
|
||||||
func TestUDPv4_LookupIteratorClose(t *testing.T) {
|
func TestUDPv4_LookupIteratorClose(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
test := newUDPTest(t)
|
logger := log.New()
|
||||||
|
test := newUDPTest(t, logger)
|
||||||
defer test.close()
|
defer test.close()
|
||||||
|
|
||||||
// Seed table with initial nodes.
|
// Seed table with initial nodes.
|
||||||
|
@ -110,22 +110,22 @@ const (
|
|||||||
|
|
||||||
// Map adds a port mapping on m and keeps it alive until c is closed.
|
// Map adds a port mapping on m and keeps it alive until c is closed.
|
||||||
// This function is typically invoked in its own goroutine.
|
// This function is typically invoked in its own goroutine.
|
||||||
func Map(m Interface, c <-chan struct{}, protocol string, extport, intport int, name string) {
|
func Map(m Interface, c <-chan struct{}, protocol string, extport, intport int, name string, logger log.Logger) {
|
||||||
if !m.SupportsMapping() {
|
if !m.SupportsMapping() {
|
||||||
panic("Port mapping is not supported")
|
panic("Port mapping is not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
logger := log.New("proto", protocol, "extport", extport, "intport", intport, "interface", m)
|
logger1 := logger.New("proto", protocol, "extport", extport, "intport", intport, "interface", m)
|
||||||
refresh := time.NewTimer(mapTimeout)
|
refresh := time.NewTimer(mapTimeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
refresh.Stop()
|
refresh.Stop()
|
||||||
logger.Trace("Deleting port mapping")
|
logger1.Trace("Deleting port mapping")
|
||||||
m.DeleteMapping(protocol, extport, intport)
|
m.DeleteMapping(protocol, extport, intport)
|
||||||
}()
|
}()
|
||||||
if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil {
|
if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil {
|
||||||
logger.Debug("Couldn't add port mapping", "err", err)
|
logger1.Debug("Couldn't add port mapping", "err", err)
|
||||||
} else {
|
} else {
|
||||||
logger.Info("Mapped network port")
|
logger1.Info("Mapped network port")
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -134,9 +134,9 @@ func Map(m Interface, c <-chan struct{}, protocol string, extport, intport int,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case <-refresh.C:
|
case <-refresh.C:
|
||||||
logger.Trace("Refreshing port mapping")
|
logger1.Trace("Refreshing port mapping")
|
||||||
if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil {
|
if err := m.AddMapping(protocol, extport, intport, name, mapTimeout); err != nil {
|
||||||
logger.Debug("Couldn't add port mapping", "err", err)
|
logger1.Debug("Couldn't add port mapping", "err", err)
|
||||||
}
|
}
|
||||||
refresh.Reset(mapTimeout)
|
refresh.Reset(mapTimeout)
|
||||||
}
|
}
|
||||||
|
@ -609,7 +609,7 @@ func (srv *Server) setupDiscovery(ctx context.Context) error {
|
|||||||
go func() {
|
go func() {
|
||||||
defer debug.LogPanic()
|
defer debug.LogPanic()
|
||||||
defer srv.loopWG.Done()
|
defer srv.loopWG.Done()
|
||||||
nat.Map(srv.NAT, srv.quit, "udp", realaddr.Port, realaddr.Port, "ethereum discovery")
|
nat.Map(srv.NAT, srv.quit, "udp", realaddr.Port, realaddr.Port, "ethereum discovery", srv.logger)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -721,7 +721,7 @@ func (srv *Server) setupListening(ctx context.Context) error {
|
|||||||
go func() {
|
go func() {
|
||||||
defer debug.LogPanic()
|
defer debug.LogPanic()
|
||||||
defer srv.loopWG.Done()
|
defer srv.loopWG.Done()
|
||||||
nat.Map(srv.NAT, srv.quit, "tcp", tcp.Port, tcp.Port, "ethereum p2p")
|
nat.Map(srv.NAT, srv.quit, "tcp", tcp.Port, tcp.Port, "ethereum p2p", srv.logger)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user