mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 06:15:33 +00:00
info->notice, debug->info
This commit is contained in:
@@ -126,7 +126,7 @@ func (a *AddrBook) init() {
|
||||
|
||||
func (a *AddrBook) Start() {
|
||||
if atomic.CompareAndSwapUint32(&a.started, 0, 1) {
|
||||
log.Info("Starting AddrBook")
|
||||
log.Notice("Starting AddrBook")
|
||||
a.loadFromFile(a.filePath)
|
||||
a.wg.Add(1)
|
||||
go a.saveRoutine()
|
||||
@@ -135,7 +135,7 @@ func (a *AddrBook) Start() {
|
||||
|
||||
func (a *AddrBook) Stop() {
|
||||
if atomic.CompareAndSwapUint32(&a.stopped, 0, 1) {
|
||||
log.Info("Stopping AddrBook")
|
||||
log.Notice("Stopping AddrBook")
|
||||
close(a.quit)
|
||||
a.wg.Wait()
|
||||
}
|
||||
@@ -144,7 +144,7 @@ func (a *AddrBook) Stop() {
|
||||
func (a *AddrBook) AddOurAddress(addr *NetAddress) {
|
||||
a.mtx.Lock()
|
||||
defer a.mtx.Unlock()
|
||||
log.Debug("Add our address to book", "addr", addr)
|
||||
log.Info("Add our address to book", "addr", addr)
|
||||
a.ourAddrs[addr.String()] = addr
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ func (a *AddrBook) OurAddresses() []*NetAddress {
|
||||
func (a *AddrBook) AddAddress(addr *NetAddress, src *NetAddress) {
|
||||
a.mtx.Lock()
|
||||
defer a.mtx.Unlock()
|
||||
log.Debug("Add address to book", "addr", addr, "src", src)
|
||||
log.Info("Add address to book", "addr", addr, "src", src)
|
||||
a.addAddress(addr, src)
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ out:
|
||||
for {
|
||||
select {
|
||||
case <-dumpAddressTicker.C:
|
||||
log.Debug("Saving AddrBook to file", "size", a.Size())
|
||||
log.Info("Saving AddrBook to file", "size", a.Size())
|
||||
a.saveToFile(a.filePath)
|
||||
case <-a.quit:
|
||||
break out
|
||||
@@ -388,7 +388,7 @@ out:
|
||||
dumpAddressTicker.Stop()
|
||||
a.saveToFile(a.filePath)
|
||||
a.wg.Done()
|
||||
log.Info("Address handler done")
|
||||
log.Notice("Address handler done")
|
||||
}
|
||||
|
||||
func (a *AddrBook) getBucket(bucketType byte, bucketIdx int) map[string]*knownAddress {
|
||||
@@ -421,7 +421,7 @@ func (a *AddrBook) addToNewBucket(ka *knownAddress, bucketIdx int) bool {
|
||||
|
||||
// Enforce max addresses.
|
||||
if len(bucket) > newBucketSize {
|
||||
log.Info("new bucket is full, expiring old ")
|
||||
log.Notice("new bucket is full, expiring old ")
|
||||
a.expireNew(bucketIdx)
|
||||
}
|
||||
|
||||
@@ -549,7 +549,7 @@ func (a *AddrBook) addAddress(addr, src *NetAddress) {
|
||||
bucket := a.calcNewBucket(addr, src)
|
||||
a.addToNewBucket(ka, bucket)
|
||||
|
||||
log.Info("Added new address", "address", addr, "total", a.size())
|
||||
log.Notice("Added new address", "address", addr, "total", a.size())
|
||||
}
|
||||
|
||||
// Make space in the new buckets by expiring the really bad entries.
|
||||
@@ -558,7 +558,7 @@ func (a *AddrBook) expireNew(bucketIdx int) {
|
||||
for addrStr, ka := range a.addrNew[bucketIdx] {
|
||||
// If an entry is bad, throw it away
|
||||
if ka.isBad() {
|
||||
log.Info(Fmt("expiring bad address %v", addrStr))
|
||||
log.Notice(Fmt("expiring bad address %v", addrStr))
|
||||
a.removeFromBucket(ka, bucketTypeNew, bucketIdx)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ func NewMConnection(conn net.Conn, chDescs []*ChannelDescriptor, onReceive recei
|
||||
// .Start() begins multiplexing packets to and from "channels".
|
||||
func (c *MConnection) Start() {
|
||||
if atomic.CompareAndSwapUint32(&c.started, 0, 1) {
|
||||
log.Debug("Starting MConnection", "connection", c)
|
||||
log.Info("Starting MConnection", "connection", c)
|
||||
go c.sendRoutine()
|
||||
go c.recvRoutine()
|
||||
}
|
||||
@@ -132,7 +132,7 @@ func (c *MConnection) Start() {
|
||||
|
||||
func (c *MConnection) Stop() {
|
||||
if atomic.CompareAndSwapUint32(&c.stopped, 0, 1) {
|
||||
log.Debug("Stopping MConnection", "connection", c)
|
||||
log.Info("Stopping MConnection", "connection", c)
|
||||
close(c.quit)
|
||||
c.conn.Close()
|
||||
c.flushTimer.Stop()
|
||||
@@ -151,7 +151,7 @@ func (c *MConnection) String() string {
|
||||
}
|
||||
|
||||
func (c *MConnection) flush() {
|
||||
log.Debug("Flush", "conn", c)
|
||||
log.Info("Flush", "conn", c)
|
||||
err := c.bufWriter.Flush()
|
||||
if err != nil {
|
||||
log.Warn("MConnection flush failed", "error", err)
|
||||
@@ -182,7 +182,7 @@ func (c *MConnection) Send(chId byte, msg interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
log.Debug("Send", "channel", chId, "connection", c, "msg", msg) //, "bytes", binary.BinaryBytes(msg))
|
||||
log.Info("Send", "channel", chId, "connection", c, "msg", msg) //, "bytes", binary.BinaryBytes(msg))
|
||||
|
||||
// Send message to channel.
|
||||
channel, ok := c.channelsIdx[chId]
|
||||
@@ -211,7 +211,7 @@ func (c *MConnection) TrySend(chId byte, msg interface{}) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
log.Debug("TrySend", "channel", chId, "connection", c, "msg", msg)
|
||||
log.Info("TrySend", "channel", chId, "connection", c, "msg", msg)
|
||||
|
||||
// Send message to channel.
|
||||
channel, ok := c.channelsIdx[chId]
|
||||
@@ -263,12 +263,12 @@ FOR_LOOP:
|
||||
channel.updateStats()
|
||||
}
|
||||
case <-c.pingTimer.Ch:
|
||||
log.Debug("Send Ping")
|
||||
log.Info("Send Ping")
|
||||
binary.WriteByte(packetTypePing, c.bufWriter, &n, &err)
|
||||
c.sendMonitor.Update(int(n))
|
||||
c.flush()
|
||||
case <-c.pong:
|
||||
log.Debug("Send Pong")
|
||||
log.Info("Send Pong")
|
||||
binary.WriteByte(packetTypePong, c.bufWriter, &n, &err)
|
||||
c.sendMonitor.Update(int(n))
|
||||
c.flush()
|
||||
@@ -339,7 +339,7 @@ func (c *MConnection) sendMsgPacket() bool {
|
||||
if leastChannel == nil {
|
||||
return true
|
||||
} else {
|
||||
// log.Debug("Found a msgPacket to send")
|
||||
// log.Info("Found a msgPacket to send")
|
||||
}
|
||||
|
||||
// Make & send a msgPacket from this channel
|
||||
@@ -368,7 +368,7 @@ FOR_LOOP:
|
||||
/*
|
||||
// Peek into bufReader for debugging
|
||||
if numBytes := c.bufReader.Buffered(); numBytes > 0 {
|
||||
log.Debug("Peek connection buffer", "numBytes", numBytes, "bytes", log15.Lazy{func() []byte {
|
||||
log.Info("Peek connection buffer", "numBytes", numBytes, "bytes", log15.Lazy{func() []byte {
|
||||
bytes, err := c.bufReader.Peek(MinInt(numBytes, 100))
|
||||
if err == nil {
|
||||
return bytes
|
||||
@@ -397,11 +397,11 @@ FOR_LOOP:
|
||||
switch pktType {
|
||||
case packetTypePing:
|
||||
// TODO: prevent abuse, as they cause flush()'s.
|
||||
log.Debug("Receive Ping")
|
||||
log.Info("Receive Ping")
|
||||
c.pong <- struct{}{}
|
||||
case packetTypePong:
|
||||
// do nothing
|
||||
log.Debug("Receive Pong")
|
||||
log.Info("Receive Pong")
|
||||
case packetTypeMsg:
|
||||
pkt, n, err := msgPacket{}, int64(0), error(nil)
|
||||
binary.ReadBinaryPtr(&pkt, c.bufReader, &n, &err)
|
||||
@@ -426,7 +426,7 @@ FOR_LOOP:
|
||||
break FOR_LOOP
|
||||
}
|
||||
if msgBytes != nil {
|
||||
log.Debug("Received bytes", "chId", pkt.ChannelId, "msgBytes", msgBytes)
|
||||
log.Info("Received bytes", "chId", pkt.ChannelId, "msgBytes", msgBytes)
|
||||
c.onReceive(pkt.ChannelId, msgBytes)
|
||||
}
|
||||
default:
|
||||
@@ -565,7 +565,7 @@ func (ch *Channel) nextMsgPacket() msgPacket {
|
||||
// Not goroutine-safe
|
||||
func (ch *Channel) writeMsgPacketTo(w io.Writer) (n int64, err error) {
|
||||
packet := ch.nextMsgPacket()
|
||||
log.Debug("Write Msg Packet", "conn", ch.conn, "packet", packet)
|
||||
log.Info("Write Msg Packet", "conn", ch.conn, "packet", packet)
|
||||
binary.WriteByte(packetTypeMsg, w, &n, &err)
|
||||
binary.WriteBinary(packet, w, &n, &err)
|
||||
if err != nil {
|
||||
@@ -577,7 +577,7 @@ func (ch *Channel) writeMsgPacketTo(w io.Writer) (n int64, err error) {
|
||||
// Handles incoming msgPackets. Returns a msg bytes if msg is complete.
|
||||
// Not goroutine-safe
|
||||
func (ch *Channel) recvMsgPacket(packet msgPacket) ([]byte, error) {
|
||||
log.Debug("Read Msg Packet", "conn", ch.conn, "packet", packet)
|
||||
log.Info("Read Msg Packet", "conn", ch.conn, "packet", packet)
|
||||
if binary.MaxBinaryReadSize < len(ch.recving)+len(packet.Bytes) {
|
||||
return nil, binary.ErrBinaryReadSizeOverflow
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func NewDefaultListener(protocol string, lAddr string, requireUPNPHairpin bool)
|
||||
}
|
||||
// Actual listener local IP & port
|
||||
listenerIP, listenerPort := splitHostPort(listener.Addr().String())
|
||||
log.Debug("Local listener", "ip", listenerIP, "port", listenerPort)
|
||||
log.Info("Local listener", "ip", listenerIP, "port", listenerPort)
|
||||
|
||||
// Determine internal address...
|
||||
var intAddr *NetAddress = NewNetAddressString(lAddr)
|
||||
@@ -157,16 +157,16 @@ func (l *DefaultListener) String() string {
|
||||
|
||||
// UPNP external address discovery & port mapping
|
||||
func getUPNPExternalAddress(externalPort, internalPort int) *NetAddress {
|
||||
log.Debug("Getting UPNP external address")
|
||||
log.Info("Getting UPNP external address")
|
||||
nat, err := upnp.Discover()
|
||||
if err != nil {
|
||||
log.Debug("Could not perform UPNP discover", "error", err)
|
||||
log.Info("Could not perform UPNP discover", "error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
ext, err := nat.GetExternalAddress()
|
||||
if err != nil {
|
||||
log.Debug("Could not get UPNP external address", "error", err)
|
||||
log.Info("Could not get UPNP external address", "error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -177,11 +177,11 @@ func getUPNPExternalAddress(externalPort, internalPort int) *NetAddress {
|
||||
|
||||
externalPort, err = nat.AddPortMapping("tcp", externalPort, internalPort, "tendermint", 0)
|
||||
if err != nil {
|
||||
log.Debug("Could not add UPNP port mapping", "error", err)
|
||||
log.Info("Could not add UPNP port mapping", "error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debug("Got UPNP external address", "address", ext)
|
||||
log.Info("Got UPNP external address", "address", ext)
|
||||
return NewNetAddressIPPort(ext, uint16(externalPort))
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ func peerHandshake(conn net.Conn, ourNodeInfo *types.NodeInfo) (*types.NodeInfo,
|
||||
func() {
|
||||
var n int64
|
||||
binary.ReadBinary(peerNodeInfo, conn, &n, &err2)
|
||||
log.Info("Peer handshake", "peerNodeInfo", peerNodeInfo)
|
||||
log.Notice("Peer handshake", "peerNodeInfo", peerNodeInfo)
|
||||
})
|
||||
if err1 != nil {
|
||||
return nil, err1
|
||||
@@ -74,14 +74,14 @@ func newPeer(conn net.Conn, peerNodeInfo *types.NodeInfo, outbound bool, reactor
|
||||
|
||||
func (p *Peer) start() {
|
||||
if atomic.CompareAndSwapUint32(&p.running, 0, 1) {
|
||||
log.Debug("Starting Peer", "peer", p)
|
||||
log.Info("Starting Peer", "peer", p)
|
||||
p.mconn.Start()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Peer) stop() {
|
||||
if atomic.CompareAndSwapUint32(&p.running, 1, 0) {
|
||||
log.Debug("Stopping Peer", "peer", p)
|
||||
log.Info("Stopping Peer", "peer", p)
|
||||
p.mconn.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func NewPEXReactor(book *AddrBook) *PEXReactor {
|
||||
// Implements Reactor
|
||||
func (pexR *PEXReactor) Start(sw *Switch) {
|
||||
if atomic.CompareAndSwapUint32(&pexR.started, 0, 1) {
|
||||
log.Info("Starting PEXReactor")
|
||||
log.Notice("Starting PEXReactor")
|
||||
pexR.sw = sw
|
||||
go pexR.ensurePeersRoutine()
|
||||
}
|
||||
@@ -57,7 +57,7 @@ func (pexR *PEXReactor) Start(sw *Switch) {
|
||||
// Implements Reactor
|
||||
func (pexR *PEXReactor) Stop() {
|
||||
if atomic.CompareAndSwapUint32(&pexR.stopped, 0, 1) {
|
||||
log.Info("Stopping PEXReactor")
|
||||
log.Notice("Stopping PEXReactor")
|
||||
close(pexR.quit)
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func (pexR *PEXReactor) Receive(chId byte, src *Peer, msgBytes []byte) {
|
||||
log.Warn("Error decoding message", "error", err)
|
||||
return
|
||||
}
|
||||
log.Info("Received message", "msg", msg)
|
||||
log.Notice("Received message", "msg", msg)
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *pexRequestMessage:
|
||||
@@ -160,7 +160,7 @@ FOR_LOOP:
|
||||
func (pexR *PEXReactor) ensurePeers() {
|
||||
numOutPeers, _, numDialing := pexR.sw.NumPeers()
|
||||
numToDial := minNumOutboundPeers - (numOutPeers + numDialing)
|
||||
log.Debug("Ensure peers", "numOutPeers", numOutPeers, "numDialing", numDialing, "numToDial", numToDial)
|
||||
log.Info("Ensure peers", "numOutPeers", numOutPeers, "numDialing", numDialing, "numToDial", numToDial)
|
||||
if numToDial <= 0 {
|
||||
return
|
||||
}
|
||||
@@ -183,14 +183,14 @@ func (pexR *PEXReactor) ensurePeers() {
|
||||
alreadyConnected := pexR.sw.Peers().Has(try.IP.String())
|
||||
if alreadySelected || alreadyDialing || alreadyConnected {
|
||||
/*
|
||||
log.Debug("Cannot dial address", "addr", try,
|
||||
log.Info("Cannot dial address", "addr", try,
|
||||
"alreadySelected", alreadySelected,
|
||||
"alreadyDialing", alreadyDialing,
|
||||
"alreadyConnected", alreadyConnected)
|
||||
*/
|
||||
continue
|
||||
} else {
|
||||
log.Debug("Will dial address", "addr", try)
|
||||
log.Info("Will dial address", "addr", try)
|
||||
picked = try
|
||||
break
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func (pexR *PEXReactor) ensurePeers() {
|
||||
if peers := pexR.sw.Peers().List(); len(peers) > 0 {
|
||||
i := rand.Int() % len(peers)
|
||||
peer := peers[i]
|
||||
log.Debug("No addresses to dial. Sending pexRequest to random peer", "peer", peer)
|
||||
log.Info("No addresses to dial. Sending pexRequest to random peer", "peer", peer)
|
||||
pexR.RequestPEX(peer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, er
|
||||
// Add the peer to .peers
|
||||
// ignore if duplicate or if we already have too many for that IP range
|
||||
if err := sw.peers.Add(peer); err != nil {
|
||||
log.Info("Ignoring peer", "error", err, "peer", peer)
|
||||
log.Notice("Ignoring peer", "error", err, "peer", peer)
|
||||
peer.mconn.Stop()
|
||||
return nil, err
|
||||
}
|
||||
@@ -234,7 +234,7 @@ func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, er
|
||||
sw.startInitPeer(peer)
|
||||
}
|
||||
|
||||
log.Info("Added peer", "peer", peer)
|
||||
log.Notice("Added peer", "peer", peer)
|
||||
return peer, nil
|
||||
}
|
||||
|
||||
@@ -244,20 +244,20 @@ func (sw *Switch) startInitPeer(peer *Peer) {
|
||||
}
|
||||
|
||||
func (sw *Switch) DialPeerWithAddress(addr *NetAddress) (*Peer, error) {
|
||||
log.Debug("Dialing address", "address", addr)
|
||||
log.Info("Dialing address", "address", addr)
|
||||
sw.dialing.Set(addr.IP.String(), addr)
|
||||
conn, err := addr.DialTimeout(peerDialTimeoutSeconds * time.Second)
|
||||
sw.dialing.Delete(addr.IP.String())
|
||||
if err != nil {
|
||||
log.Debug("Failed dialing address", "address", addr, "error", err)
|
||||
log.Info("Failed dialing address", "address", addr, "error", err)
|
||||
return nil, err
|
||||
}
|
||||
peer, err := sw.AddPeerWithConnection(conn, true)
|
||||
if err != nil {
|
||||
log.Debug("Failed adding peer", "address", addr, "conn", conn, "error", err)
|
||||
log.Info("Failed adding peer", "address", addr, "conn", conn, "error", err)
|
||||
return nil, err
|
||||
}
|
||||
log.Info("Dialed and added peer", "address", addr, "peer", peer)
|
||||
log.Notice("Dialed and added peer", "address", addr, "peer", peer)
|
||||
return peer, nil
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ func (sw *Switch) IsDialing(addr *NetAddress) bool {
|
||||
// which receives success values for each attempted send (false if times out)
|
||||
func (sw *Switch) Broadcast(chId byte, msg interface{}) chan bool {
|
||||
successChan := make(chan bool, len(sw.peers.List()))
|
||||
log.Debug("Broadcast", "channel", chId, "msg", msg)
|
||||
log.Info("Broadcast", "channel", chId, "msg", msg)
|
||||
for _, peer := range sw.peers.List() {
|
||||
go func(peer *Peer) {
|
||||
success := peer.Send(chId, msg)
|
||||
@@ -302,7 +302,7 @@ func (sw *Switch) Peers() IPeerSet {
|
||||
// Disconnect from a peer due to external error.
|
||||
// TODO: make record depending on reason.
|
||||
func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) {
|
||||
log.Info("Stopping peer for error", "peer", peer, "error", reason)
|
||||
log.Notice("Stopping peer for error", "peer", peer, "error", reason)
|
||||
sw.peers.Remove(peer)
|
||||
peer.stop()
|
||||
sw.removePeerFromReactors(peer, reason)
|
||||
@@ -311,7 +311,7 @@ func (sw *Switch) StopPeerForError(peer *Peer, reason interface{}) {
|
||||
// Disconnect from a peer gracefully.
|
||||
// TODO: handle graceful disconnects.
|
||||
func (sw *Switch) StopPeerGracefully(peer *Peer) {
|
||||
log.Info("Stopping peer gracefully")
|
||||
log.Notice("Stopping peer gracefully")
|
||||
sw.peers.Remove(peer)
|
||||
peer.stop()
|
||||
sw.removePeerFromReactors(peer, nil)
|
||||
@@ -338,20 +338,20 @@ func (sw *Switch) listenerRoutine(l Listener) {
|
||||
|
||||
// ignore connection if we already have enough
|
||||
if maxNumPeers <= sw.peers.Size() {
|
||||
log.Debug("Ignoring inbound connection: already have enough peers", "address", inConn.RemoteAddr().String(), "numPeers", sw.peers.Size(), "max", maxNumPeers)
|
||||
log.Info("Ignoring inbound connection: already have enough peers", "address", inConn.RemoteAddr().String(), "numPeers", sw.peers.Size(), "max", maxNumPeers)
|
||||
continue
|
||||
}
|
||||
|
||||
// Ignore connections from IP ranges for which we have too many
|
||||
if sw.peers.HasMaxForIPRange(inConn) {
|
||||
log.Debug("Ignoring inbound connection: already have enough peers for that IP range", "address", inConn.RemoteAddr().String())
|
||||
log.Info("Ignoring inbound connection: already have enough peers for that IP range", "address", inConn.RemoteAddr().String())
|
||||
continue
|
||||
}
|
||||
|
||||
// New inbound connection!
|
||||
_, err := sw.AddPeerWithConnection(inConn, false)
|
||||
if err != nil {
|
||||
log.Info("Ignoring inbound connection: error on AddPeerWithConnection", "address", inConn.RemoteAddr().String(), "error", err)
|
||||
log.Notice("Ignoring inbound connection: error on AddPeerWithConnection", "address", inConn.RemoteAddr().String(), "error", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -19,19 +19,19 @@ func makeUPNPListener(intPort int, extPort int) (NAT, net.Listener, net.IP, erro
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.New(fmt.Sprintf("NAT upnp could not be discovered: %v", err))
|
||||
}
|
||||
log.Debug(Fmt("ourIP: %v", nat.(*upnpNAT).ourIP))
|
||||
log.Info(Fmt("ourIP: %v", nat.(*upnpNAT).ourIP))
|
||||
|
||||
ext, err := nat.GetExternalAddress()
|
||||
if err != nil {
|
||||
return nat, nil, nil, errors.New(fmt.Sprintf("External address error: %v", err))
|
||||
}
|
||||
log.Debug(Fmt("External address: %v", ext))
|
||||
log.Info(Fmt("External address: %v", ext))
|
||||
|
||||
port, err := nat.AddPortMapping("tcp", extPort, intPort, "Tendermint UPnP Probe", 0)
|
||||
if err != nil {
|
||||
return nat, nil, ext, errors.New(fmt.Sprintf("Port mapping error: %v", err))
|
||||
}
|
||||
log.Debug(Fmt("Port mapping mapped: %v", port))
|
||||
log.Info(Fmt("Port mapping mapped: %v", port))
|
||||
|
||||
// also run the listener, open for all remote addresses.
|
||||
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", intPort))
|
||||
@@ -46,17 +46,17 @@ func testHairpin(listener net.Listener, extAddr string) (supportsHairpin bool) {
|
||||
go func() {
|
||||
inConn, err := listener.Accept()
|
||||
if err != nil {
|
||||
log.Info(Fmt("Listener.Accept() error: %v", err))
|
||||
log.Notice(Fmt("Listener.Accept() error: %v", err))
|
||||
return
|
||||
}
|
||||
log.Debug(Fmt("Accepted incoming connection: %v -> %v", inConn.LocalAddr(), inConn.RemoteAddr()))
|
||||
log.Info(Fmt("Accepted incoming connection: %v -> %v", inConn.LocalAddr(), inConn.RemoteAddr()))
|
||||
buf := make([]byte, 1024)
|
||||
n, err := inConn.Read(buf)
|
||||
if err != nil {
|
||||
log.Info(Fmt("Incoming connection read error: %v", err))
|
||||
log.Notice(Fmt("Incoming connection read error: %v", err))
|
||||
return
|
||||
}
|
||||
log.Debug(Fmt("Incoming connection read %v bytes: %X", n, buf))
|
||||
log.Info(Fmt("Incoming connection read %v bytes: %X", n, buf))
|
||||
if string(buf) == "test data" {
|
||||
supportsHairpin = true
|
||||
return
|
||||
@@ -66,16 +66,16 @@ func testHairpin(listener net.Listener, extAddr string) (supportsHairpin bool) {
|
||||
// Establish outgoing
|
||||
outConn, err := net.Dial("tcp", extAddr)
|
||||
if err != nil {
|
||||
log.Info(Fmt("Outgoing connection dial error: %v", err))
|
||||
log.Notice(Fmt("Outgoing connection dial error: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
n, err := outConn.Write([]byte("test data"))
|
||||
if err != nil {
|
||||
log.Info(Fmt("Outgoing connection write error: %v", err))
|
||||
log.Notice(Fmt("Outgoing connection write error: %v", err))
|
||||
return
|
||||
}
|
||||
log.Debug(Fmt("Outgoing connection wrote %v bytes", n))
|
||||
log.Info(Fmt("Outgoing connection wrote %v bytes", n))
|
||||
|
||||
// Wait for data receipt
|
||||
time.Sleep(1 * time.Second)
|
||||
@@ -83,7 +83,7 @@ func testHairpin(listener net.Listener, extAddr string) (supportsHairpin bool) {
|
||||
}
|
||||
|
||||
func Probe() (caps UPNPCapabilities, err error) {
|
||||
log.Debug("Probing for UPnP!")
|
||||
log.Info("Probing for UPnP!")
|
||||
|
||||
intPort, extPort := 8001, 8001
|
||||
|
||||
|
||||
Reference in New Issue
Block a user