mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-29 07:10:25 +08:00
完善路由表
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
package link
|
||||
|
||||
import "net"
|
||||
import (
|
||||
"net"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
routetable = make(map[string][]*Link)
|
||||
routetablemu sync.RWMutex
|
||||
)
|
||||
|
||||
// Accept 判断是否应当接受 ip 发来的包
|
||||
func (l *Link) Accept(ip net.IP) bool {
|
||||
@@ -19,5 +27,7 @@ func (l *Link) IsToMe(ip net.IP) bool {
|
||||
|
||||
// NextHop 得到前往 ip 的下一跳的 link
|
||||
func (l *Link) NextHop(ip net.IP) *Link {
|
||||
// TODO: 遍历 routetable,得到正确的下一跳
|
||||
// 注意使用 routetablemu 读写锁避免竞争
|
||||
return l
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user