Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gophergala2016/meshbird
Browse files Browse the repository at this point in the history
  • Loading branch information
gen1us2k committed Jan 24, 2016
2 parents c63eedc + 1061736 commit 2cfd197
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions common/net_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ func (nt *NetTable) SendPacket(dstIP net.IP, payload []byte) {
}
}

func (nt *NetTable) PeerAddresses() map[string]string {
nt.lock.Lock()
defer nt.lock.Unlock()
peers := make(map[string]string)
for l, peer := range nt.peers {
peers[l] = peer.publicAddress
}
return peers
}

func (nt *NetTable) knownHosts() []string {
nt.lock.Lock()
defer nt.lock.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion network/protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func Decode(r io.Reader) (*Packet, error) {

remainLength := int(pack.Head.Length) - 1 // minus type

if TypeHandshake != pack.Data.Type && TypeOk != pack.Data.Type && TypePeerInfo != pack.Data.Type && TypeHeartbeat != pack.Data.Type {
// Only `TypeTransfer` has vector
if TypeTransfer == pack.Data.Type {
vector := make([]byte, bodyVectorLen)
if n, err := r.Read(vector); err != nil || n != bodyVectorLen {
if n != bodyVectorLen {
Expand Down

0 comments on commit 2cfd197

Please sign in to comment.