1
0
mirror of https://github.com/fumiama/WireGold.git synced 2026-07-01 00:00:23 +08:00

模块化 me router

This commit is contained in:
fumiama
2021-12-28 12:44:28 +08:00
parent bba9662a5b
commit ff5d9a03c5
7 changed files with 87 additions and 62 deletions

View File

@@ -5,10 +5,10 @@ import (
"sync"
)
var (
routetable = make(map[string][]*Link)
type Router struct {
routetable map[string][]*Link
routetablemu sync.RWMutex
)
}
// Accept 判断是否应当接受 ip 发来的包
func (l *Link) Accept(ip net.IP) bool {
@@ -22,7 +22,7 @@ func (l *Link) Accept(ip net.IP) bool {
// IsToMe 判断是否是发给自己的包
func (l *Link) IsToMe(ip net.IP) bool {
return ip.Equal(me)
return ip.Equal(l.me.me)
}
// NextHop 得到前往 ip 的下一跳的 link