mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-20 02:16:17 +08:00
add link rep
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/fumiama/WireGold/gold/head"
|
"github.com/fumiama/WireGold/gold/head"
|
||||||
|
"github.com/fumiama/WireGold/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Link 是本机到 peer 的连接抽象
|
// Link 是本机到 peer 的连接抽象
|
||||||
@@ -100,3 +101,11 @@ func (l *Link) Write(p *head.Packet, istransfer bool) (n int, err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *Link) String() (n string) {
|
||||||
|
n = "default"
|
||||||
|
if l.pubk != nil {
|
||||||
|
n = helper.BytesToString(l.pubk[:24])
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/fumiama/WireGold/helper"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -85,11 +84,7 @@ func (r *Router) SetItem(ip *net.IPNet, l *Link) {
|
|||||||
copy(r.list[i+1:], r.list[i:len(r.list)-1])
|
copy(r.list[i+1:], r.list[i:len(r.list)-1])
|
||||||
r.list[i] = ip
|
r.list[i] = ip
|
||||||
r.table[ip.String()] = l
|
r.table[ip.String()] = l
|
||||||
lnkname := "default"
|
logrus.Infoln("[router] add route in link", l, "to", ip, "-->", l.peerip)
|
||||||
if l.pubk != nil {
|
|
||||||
lnkname = helper.BytesToString(l.pubk[:24])
|
|
||||||
}
|
|
||||||
logrus.Infoln("[router] add route in link", lnkname, "to", ip, "-->", l.peerip)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user