Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Include selected overlay type in connection status
Browse files Browse the repository at this point in the history
  • Loading branch information
awh committed Oct 12, 2015
1 parent 316823b commit a553691
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions router/fastdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ func (fwd *fastDatapathForwarder) ControlMessage(tag byte, msg []byte) {
}
}

func (fwd *fastDatapathForwarder) OverlayType() string {
return "fastdp"
}

func (fwd *fastDatapathForwarder) handleHeartbeatAck() {
log.Debug(fwd.logPrefix(), "handleHeartbeatAck")

Expand Down
7 changes: 7 additions & 0 deletions router/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ type OverlayForwarder interface {
// compatibility, and should always be
// ProtocolOverlayControlMessage for non-sleeve overlays.
ControlMessage(tag byte, msg []byte)

// Type of overlay this forwarder belongs to
OverlayType() string

This comment has been minimized.

Copy link
@dpw

dpw Oct 12, 2015

Contributor

I think there's room for confusion between this overlay type identifier and the one used in the Overlay Add method (

func (osw *OverlaySwitch) Add(name string, overlay Overlay) {
). I was thinking about suggesting unifying them, but decided that the distinction is useful: The names used in the Overlays features string don't necessary match the names we want to show to users.

So I'd suggest renaming this method to make it clearer it yields a name for display to the user. E.g. DisplayName.

}

type NullOverlay struct{}
Expand Down Expand Up @@ -129,3 +132,7 @@ func (NullOverlay) Stop() {

func (NullOverlay) ControlMessage(byte, []byte) {
}

func (NullOverlay) OverlayType() string {
return "null"
}
12 changes: 12 additions & 0 deletions router/overlay_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,15 @@ func (fwd *overlaySwitchForwarder) ControlMessage(tag byte, msg []byte) {
subFwd.ControlMessage(msg[1], msg[2:])
}
}

func (fwd *overlaySwitchForwarder) OverlayType() string {
fwd.lock.Lock()
best := fwd.best
fwd.lock.Unlock()

if best == nil {
return "none"
}

return best.OverlayType()
}
4 changes: 4 additions & 0 deletions router/sleeve.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ func (fwd *sleeveForwarder) ControlMessage(tag byte, msg []byte) {
}
}

func (fwd *sleeveForwarder) OverlayType() string {
return "sleeve"
}

func (fwd *sleeveForwarder) Stop() {
fwd.sleeve.removeForwarder(fwd.remotePeer.Name, fwd)

Expand Down
5 changes: 4 additions & 1 deletion router/status.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package router

import (
"fmt"
"time"
)

Expand Down Expand Up @@ -170,7 +171,9 @@ func NewLocalConnectionStatusSlice(cm *ConnectionMaker) []LocalConnectionStatus
if conn.Established() {
state = "established"
}
slice = append(slice, LocalConnectionStatus{conn.RemoteTCPAddr(), conn.Outbound(), state, conn.Remote().String()})
lc, _ := conn.(*LocalConnection)
info := fmt.Sprintf("%-6v %v", lc.forwarder.OverlayType(), conn.Remote())
slice = append(slice, LocalConnectionStatus{conn.RemoteTCPAddr(), conn.Outbound(), state, info})
}
for address, target := range cm.targets {
add := func(state, info string) {
Expand Down

0 comments on commit a553691

Please sign in to comment.