Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
reusee committed Jun 13, 2023
1 parent 86c53c8 commit 998dea0
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions bridge_icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ func (n *Network) StartICMP(
if !node.HasBridge(BridgeICMP) {
continue
}

if node == localNode {
continue
}

ip := getReachableIP(node)
if len(ip) == 0 {
continue
Expand All @@ -81,7 +79,6 @@ func (n *Network) StartICMP(
},
}
remotes = append(remotes, remote)

}

inbounds := make(chan ICMPInbound, 1024)
Expand All @@ -91,24 +88,18 @@ func (n *Network) StartICMP(
localConnOK := make(chan struct{})
spawn(func() {
node := localNode
ip := node.wanIP
if len(ip) == 0 && len(node.PrivateIP) > 0 {
for _, addr := range sysAddrs {
if ipnet, ok := addr.(*net.IPNet); ok && ipnet.Contains(node.PrivateIP) {
ip = node.PrivateIP
break
}
}
}
ip := getReachableIP(node)
if len(ip) == 0 {
return
}

var err error
localConn, err = net.ListenIP("ip4:icmp", &net.IPAddr{
IP: net.ParseIP("0.0.0.0"),
})
ce(err)
close(localConnOK)

buf := make([]byte, mtu*2)
for {
n, addr, err := localConn.ReadFrom(buf)
Expand Down Expand Up @@ -177,8 +168,10 @@ func (n *Network) StartICMP(
}

queue := newSendQueue(
func(ip *net.IP, addr *net.HardwareAddr, data []byte) {
func(ip *net.IP, _ *net.HardwareAddr, data []byte) {
sent := false

// pick a icmp remote
var r *ICMPRemote
for _, remote := range remotes {
skip := false
Expand Down

0 comments on commit 998dea0

Please sign in to comment.