Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Data model for details pane #14

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ba28ec9
WIP
peterbourgon May 8, 2015
9381e22
Special API node type for detail panel
peterbourgon May 8, 2015
bc97ebf
Realistic load avgs
peterbourgon May 8, 2015
97eccdf
styled details pane
davkal May 11, 2015
792b192
Tables may declare if they are numeric
peterbourgon May 11, 2015
3948030
consider numeric tables differently
davkal May 11, 2015
f642cf1
Code refactoring while debugging #18
peterbourgon May 11, 2015
0082efa
colored headings for node details
davkal May 11, 2015
34a174d
Remove scripts for publishing to gh-pages
errordeveloper Apr 28, 2015
cf04d61
Update documentation URLs
errordeveloper Apr 28, 2015
6beb08f
Publishing updates to the docs on latest release
errordeveloper May 6, 2015
72a0584
Point to released docs for WeaveDNS
errordeveloper May 8, 2015
9f79b74
animate node transitions
davkal May 8, 2015
25c5f50
straighten edges
davkal May 8, 2015
60feeba
' ' > '|' ? merge : close
peterbourgon May 8, 2015
22c248f
Use our fork of procspy, and have it read /hostproc when run in a con…
May 8, 2015
e9d0f6d
Manually checkout procspy whilst its private; this change shouldn't g…
May 8, 2015
482ca69
cosmetic
rade May 8, 2015
7e3e4b7
refactor
rade May 8, 2015
df4e341
cosmetic: fix typo
rade May 9, 2015
feb4c67
refactor: get rid of test-launch
rade May 9, 2015
db0b8e9
make Peer.String() return the common case
rade May 10, 2015
3f47286
keep linter happy
rade May 11, 2015
f4027af
cosmetic: resolve some linter complaints
rade May 11, 2015
99dfff1
cosmetic: resolve some linter complaints
rade May 11, 2015
7521d98
cosmetic: resolve some more linter complaints
rade May 11, 2015
88f746f
cosmetic: resolve yet more linter complaints
rade May 11, 2015
de322e2
fix edge render artifacts
davkal May 11, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ install:
- go install -tags netgo std
- pip install --user --upgrade gcloud gsutil
- bin/setup-ci-secrets $encrypted_5ba036e89377_key $encrypted_5ba036e89377_iv
- cd ..; git clone ssh://git@github.com/weaveworks/procspy.git; cd scope
- make travis

script:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ $(WEAVER_EXE) $(WEAVEDNS_EXE): common/*.go
$(WEAVER_EXE): router/*.go weaver/main.go
$(WEAVEDNS_EXE): nameserver/*.go weavedns/main.go
$(SIGPROXY_EXE): sigproxy/main.go
$(SCOPEAPP_EXE): scope/app/*.go
$(SCOPEPROBE_EXE): scope/probe/*.go
$(SCOPEAPP_EXE): scope/app/*.go scope/xfer/*.go scope/report/*.go
$(SCOPEPROBE_EXE): scope/probe/*.go scope/xfer/*.go scope/report/*.go

# Sigproxy etc needs separate rule as it fails the netgo check in the main
# build stanza due to not importing net package
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Note that we could instead have told the weave on `$HOST1` to connect to
weave automatically (re)connects to peers when they become
available. Also, we can tell weave to connect to multiple peers by
supplying multiple addresses, separated by spaces. And we can
[add peers dynamically](http://weaveworks.github.io/weave/features.html#dynamic-topologies).
[add peers dynamically](http://docs.weave.works/weave/latest_release/features.html#dynamic-topologies).

Now that we've got everything set up, let's see whether our containers
can talk to each other...
Expand Down Expand Up @@ -131,12 +131,12 @@ to each other.

## Find out more

* [Documentation homepage](http://weaveworks.github.io/weave/)
* [Features](http://weaveworks.github.io/weave/features.html)
* [Troubleshooting](http://weaveworks.github.io/weave/troubleshooting.html)
* [Building](http://weaveworks.github.io/weave/building.html)
* [How it works](http://weaveworks.github.io/weave/how-it-works.html)
* [Automatic Discovery with WeaveDNS](https://github.com/weaveworks/weave/tree/master/weavedns#readme)
* [Documentation homepage](http://docs.weave.works/weave/latest_release/)
* [Features](http://docs.weave.works/weave/latest_release/features.html)
* [Troubleshooting](http://docs.weave.works/weave/latest_release/troubleshooting.html)
* [Building](http://docs.weave.works/weave/latest_release/building.html)
* [How it works](http://docs.weave.works/weave/latest_release/how-it-works.html)
* [Automatic Discovery with WeaveDNS](https://github.com/weaveworks/weave/tree/latest_release/weavedns#readme)

## Contact Us

Expand Down
20 changes: 0 additions & 20 deletions bin/merge-into-gh-pages

This file was deleted.

11 changes: 10 additions & 1 deletion bin/multiweave
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ set -e
START=${FIRST_WEAVE:-1}
COUNT=${NUM_WEAVES:-28}
FINISH=$((START+COUNT-1))
PORT=6783

weavedir=$(dirname $0)/..

# Generate a random MAC value - copied from 'weave' script
random_mac() {
# In the first byte of the MAC, the 'multicast' bit should be
# clear and 'locally administered' bit should be set. All other
# bits should be random.
od -txC -An -N6 /dev/urandom | sed 's|^ ||;s| |:|;s|[0-3]:|2:|;s|[4-7]:|6:|;s|[89ab]:|a:|;s|[c-f]:|e:|;s| |:|g'
}

case "$1" in
launch)
shift 1
for i in $(seq $START $FINISH); do
WEAVE_CONTAINER_NAME=weave$i $weavedir/weave test-launch "$@"
WEAVE_CONTAINER_NAME=weave$i WEAVE_PORT=$((5000+i)) $weavedir/weave launch -iface '' -name $(random_mac) -nickname weave$i -port $PORT "$@"
done
if [ $START -ne 1 ] ; then
status=$(docker inspect --format='{{.State.Running}} {{.NetworkSettings.IPAddress}}' weave$((START-1)))
Expand Down
3 changes: 0 additions & 3 deletions bin/publish-gh-pages

This file was deleted.

22 changes: 11 additions & 11 deletions nameserver/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ func (r Record) Priority() int { return r.priority }
func (r Record) Weight() int { return r.weight }
func (r Record) TTL() int { return r.ttl }

func (i Record) String() string {
func (r Record) String() string {
var buf bytes.Buffer
if len(i.Name()) > 0 {
fmt.Fprintf(&buf, "%s", i.Name())
if len(r.Name()) > 0 {
fmt.Fprintf(&buf, "%s", r.Name())
}
if !i.IP().IsUnspecified() {
fmt.Fprintf(&buf, "[%s]", i.IP())
if !r.IP().IsUnspecified() {
fmt.Fprintf(&buf, "[%s]", r.IP())
}
if i.Priority() > 0 {
fmt.Fprintf(&buf, "/P:%d", i.Priority())
if r.Priority() > 0 {
fmt.Fprintf(&buf, "/P:%d", r.Priority())
}
if i.Weight() > 0 {
fmt.Fprintf(&buf, "/W:%d", i.Weight())
if r.Weight() > 0 {
fmt.Fprintf(&buf, "/W:%d", r.Weight())
}
if i.TTL() > 0 {
fmt.Fprintf(&buf, "/TTL:%d", i.TTL())
if r.TTL() > 0 {
fmt.Fprintf(&buf, "/TTL:%d", r.TTL())
}

return buf.String()
Expand Down
20 changes: 10 additions & 10 deletions nameserver/mdns_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ func (r Response) Equal(r2 *Response) bool {
return true
}

func (i Response) String() string {
func (r Response) String() string {
var buf bytes.Buffer
if i.err != nil {
fmt.Fprintf(&buf, "%s", i.err)
if r.err != nil {
fmt.Fprintf(&buf, "%s", r.err)
} else {
if len(i.Name()) > 0 {
fmt.Fprintf(&buf, "%s", i.Name())
if len(r.Name()) > 0 {
fmt.Fprintf(&buf, "%s", r.Name())
}
if !i.IP().IsUnspecified() {
fmt.Fprintf(&buf, "[%s]", i.IP())
if !r.IP().IsUnspecified() {
fmt.Fprintf(&buf, "[%s]", r.IP())
}
if i.ttl > 0 {
fmt.Fprintf(&buf, "(TTL:%d)", i.TTL())
if r.ttl > 0 {
fmt.Fprintf(&buf, "(TTL:%d)", r.TTL())
}
}
return buf.String()
Expand Down Expand Up @@ -214,7 +214,7 @@ func (c *MDNSClient) ResponseCallback(r *dns.Msg) {
}

if query, found := c.inflight[name]; found {
newResponseInfos := make([]*responseInfo, 0)
var newResponseInfos []*responseInfo
for _, resp := range query.responseInfos {
resp.ch <- res
// insistent queries are not removed on the first reply, but on the timeout
Expand Down
2 changes: 1 addition & 1 deletion nameserver/mdns_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func mdnsLookup(client *MDNSClient, name string, qtype uint16, insistent bool) ([]ZoneRecord, error) {
responses := make([]*Response, 0)
var responses []*Response
channel := make(chan *Response)
client.SendQuery(name, qtype, insistent, channel)

Expand Down
2 changes: 1 addition & 1 deletion nameserver/mdns_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestServerSimpleQuery(t *testing.T) {
wt.AssertNoErr(t, err)
defer mdnsServer.Stop()

receivedAddrs := make([]net.IP, 0)
var receivedAddrs []net.IP
receivedName := ""
recvChan := make(chan interface{})
receivedCount := 0
Expand Down
8 changes: 4 additions & 4 deletions nameserver/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func (mz *mockedZoneWithRecords) LookupName(name string) ([]ZoneRecord, error) {
mz.Lock()
defer mz.Unlock()

mz.NumLookupsName += 1
res := make([]ZoneRecord, 0)
mz.NumLookupsName++
var res []ZoneRecord
for _, r := range mz.records {
if r.Name() == name {
res = append(res, r)
Expand All @@ -49,8 +49,8 @@ func (mz *mockedZoneWithRecords) LookupInaddr(inaddr string) ([]ZoneRecord, erro
mz.Lock()
defer mz.Unlock()

mz.NumLookupsInaddr += 1
res := make([]ZoneRecord, 0)
mz.NumLookupsInaddr++
var res []ZoneRecord
for _, r := range mz.records {
revIP, err := raddrToIP(inaddr)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions nameserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ func (s *DNSServer) Stop() error {

func (s *DNSServer) queryHandler(proto dnsProtocol) dns.HandlerFunc {
zoneLookup := func(lookup ZoneLookup, q *dns.Question, r *dns.Msg) (*dns.Msg, []ZoneRecord, error) {
if ips, err := lookup.LookupName(q.Name); err != nil {
ips, err := lookup.LookupName(q.Name)
if err != nil {
return nil, nil, err
} else {
return makeAddressReply(r, q, ips), ips, nil
}
return makeAddressReply(r, q, ips), ips, nil
}

fallback := func(w dns.ResponseWriter, r *dns.Msg) {
Expand All @@ -231,11 +231,11 @@ func (s *DNSServer) queryHandler(proto dnsProtocol) dns.HandlerFunc {

func (s *DNSServer) rdnsHandler(proto dnsProtocol) dns.HandlerFunc {
zoneLookup := func(lookup ZoneLookup, q *dns.Question, r *dns.Msg) (*dns.Msg, []ZoneRecord, error) {
if names, err := lookup.LookupInaddr(q.Name); err != nil {
names, err := lookup.LookupInaddr(q.Name)
if err != nil {
return nil, nil, err
} else {
return makePTRReply(r, q, names), names, nil
}
return makePTRReply(r, q, names), names, nil
}

notUsHandler := s.notUsHandler(proto)
Expand Down
8 changes: 4 additions & 4 deletions router/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ func (conn *RemoteConnection) BreakTie(Connection) ConnectionTieBreak { return T
func (conn *RemoteConnection) Shutdown(error) {}

func (conn *RemoteConnection) Log(args ...interface{}) {
log.Println(append(append([]interface{}{}, fmt.Sprintf("->[%s|%s]:", conn.remoteTCPAddr, conn.remote.FullName())), args...)...)
log.Println(append(append([]interface{}{}, fmt.Sprintf("->[%s|%s]:", conn.remoteTCPAddr, conn.remote)), args...)...)
}

func (conn *RemoteConnection) String() string {
from := "<nil>"
if conn.local != nil {
from = conn.local.FullName()
from = conn.local.String()
}
to := "<nil>"
if conn.remote != nil {
to = conn.remote.FullName()
to = conn.remote.String()
}
return fmt.Sprint("Connection ", from, "->", to)
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func (conn *LocalConnection) ReceivedHeartbeat(remoteUDPAddr *net.UDPAddr, connU
if oldRemoteUDPAddr == nil {
return conn.sendFastHeartbeats()
} else if oldRemoteUDPAddr.String() != remoteUDPAddr.String() {
log.Println("Peer", conn.remote.FullName(), "moved from", old, "to", remoteUDPAddr)
log.Println("Peer", conn.remote, "moved from", old, "to", remoteUDPAddr)
}
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion router/handshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (conn *LocalConnection) handshake(enc *gob.Encoder, dec *gob.Decoder, accep
}
}
if existingConn, found := conn.local.ConnectionTo(name); found && existingConn.Established() {
return fmt.Errorf("Already have connection to %s at %s", existingConn.Remote().FullName(), existingConn.RemoteTCPAddr())
return fmt.Errorf("Already have connection to %s at %s", existingConn.Remote(), existingConn.RemoteTCPAddr())
}
uid, err := strconv.ParseUint(uidStr, 10, 64)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions router/local_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (peer *LocalPeer) Relay(srcPeer, dstPeer *Peer, df bool, frame []byte, dec
if !found {
// Not necessarily an error as there could be a race with the
// dst disappearing whilst the frame is in flight
log.Println("Received packet for unknown destination:", dstPeer.FullName())
log.Println("Received packet for unknown destination:", dstPeer)
return nil
}
conn, found := peer.ConnectionTo(relayPeerName)
Expand Down Expand Up @@ -162,7 +162,7 @@ func (peer *LocalPeer) handleAddConnection(conn Connection) error {
log.Fatal("Attempt made to add connection to peer with unknown remote peer")
}
toName := conn.Remote().Name
dupErr := fmt.Errorf("Multiple connections to %s added to %s", conn.Remote().FullName(), peer.FullName())
dupErr := fmt.Errorf("Multiple connections to %s added to %s", conn.Remote(), peer.String())
// deliberately non symmetrical
if dupConn, found := peer.connections[toName]; found {
if dupConn == conn {
Expand Down
2 changes: 1 addition & 1 deletion router/mac_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (cache *MacCache) String() string {
cache.RLock()
defer cache.RUnlock()
for key, entry := range cache.table {
fmt.Fprintf(&buf, "%v -> %s (%v)\n", intmac(key), entry.peer.FullName(), entry.lastSeen)
fmt.Fprintf(&buf, "%v -> %s (%v)\n", intmac(key), entry.peer, entry.lastSeen)
}
return buf.String()
}
Expand Down
10 changes: 5 additions & 5 deletions router/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ func NewPeer(name PeerName, nickName string, uid uint64, version uint64) *Peer {
}

func (peer *Peer) String() string {
peer.RLock()
defer peer.RUnlock()
return fmt.Sprint(peer.FullName(), " (v", peer.version, ") (UID ", peer.UID, ")")
return fmt.Sprint(peer.Name, "(", peer.NickName, ")")
}

func (peer *Peer) FullName() string {
return fmt.Sprint(peer.Name, "(", peer.NickName, ")")
func (peer *Peer) Info() string {
peer.RLock()
defer peer.RUnlock()
return fmt.Sprint(peer.String(), " (v", peer.version, ") (UID ", peer.UID, ")")
}

func (peer *Peer) Version() uint64 {
Expand Down
1 change: 1 addition & 0 deletions router/peer_name_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// Let peer names be sha256 hashes...of anything (as long as it's
// unique).

package router

import (
Expand Down
1 change: 1 addition & 0 deletions router/peer_name_mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// Note that we do not mandate *what* MAC should be used as the peer
// name. In particular it doesn't actually have to be the MAC of, say,
// the network interface the peer is sniffing on.

package router

import (
Expand Down
4 changes: 2 additions & 2 deletions router/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ func (peers *Peers) GarbageCollect() []*Peer {
func (peers *Peers) String() string {
var buf bytes.Buffer
peers.ForEach(func(peer *Peer) {
fmt.Fprint(&buf, peer, "\n")
fmt.Fprintln(&buf, peer.Info())
for conn := range peer.Connections() {
established := ""
if !conn.Established() {
established = " (unestablished)"
}
fmt.Fprintf(&buf, " -> %s [%v%s]\n", conn.Remote().FullName(), conn.RemoteTCPAddr(), established)
fmt.Fprintf(&buf, " -> %s [%v%s]\n", conn.Remote(), conn.RemoteTCPAddr(), established)
}
})
return buf.String()
Expand Down
10 changes: 5 additions & 5 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ type PacketSourceSink interface {
func NewRouter(config RouterConfig, name PeerName, nickName string) *Router {
router := &Router{RouterConfig: config, GossipChannels: make(map[uint32]*GossipChannel)}
onMacExpiry := func(mac net.HardwareAddr, peer *Peer) {
log.Println("Expired MAC", mac, "at", peer.FullName())
log.Println("Expired MAC", mac, "at", peer)
}
onPeerGC := func(peer *Peer) {
router.Macs.Delete(peer)
log.Println("Removed unreachable peer", peer.FullName())
log.Println("Removed unreachable peer", peer)
}
router.Ourself = NewLocalPeer(name, nickName, router)
router.Macs = NewMacCache(macMaxAge, onMacExpiry)
Expand Down Expand Up @@ -95,7 +95,7 @@ func (router *Router) Start() {
}

func (router *Router) Stop() error {
// TODO: perform greceful shutdown...
// TODO: perform graceful shutdown...
return nil
}

Expand All @@ -105,7 +105,7 @@ func (router *Router) UsingPassword() bool {

func (router *Router) Status() string {
var buf bytes.Buffer
fmt.Fprintln(&buf, "Our name is", router.Ourself.FullName())
fmt.Fprintln(&buf, "Our name is", router.Ourself)
fmt.Fprintln(&buf, "Sniffing traffic on", router.Iface)
fmt.Fprintf(&buf, "MACs:\n%s", router.Macs)
fmt.Fprintf(&buf, "Peers:\n%s", router.Peers)
Expand Down Expand Up @@ -328,7 +328,7 @@ func (router *Router) handleUDPPacketFunc(relayConn *LocalConnection, dec *Ether
dstMac := dec.eth.DstMAC

if router.Macs.Enter(srcMac, srcPeer) {
log.Println("Discovered remote MAC", srcMac, "at", srcPeer.FullName())
log.Println("Discovered remote MAC", srcMac, "at", srcPeer)
}
if po != nil {
router.LogFrame("Injecting", frame, &dec.eth)
Expand Down
Loading