Skip to content

Commit

Permalink
Changes to handlers.go and icmp.go relating to updated type definitio…
Browse files Browse the repository at this point in the history
…ns in latest gvisor
  • Loading branch information
dismantl committed Jun 4, 2023
1 parent 1383d56 commit 3b02928
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions pkg/proxy/netstack/handlers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package netstack

import (
"github.com/hashicorp/yamux"
"io"

"github.com/dismantl/gvisor/pkg/tcpip/adapters/gonet"
"github.com/dismantl/gvisor/pkg/tcpip/header"
"github.com/dismantl/gvisor/pkg/tcpip/stack"
Expand All @@ -11,8 +12,8 @@ import (
"github.com/dismantl/gvisor/pkg/waiter"
"github.com/dismantl/ligolo-ng/pkg/protocol"
"github.com/dismantl/ligolo-ng/pkg/relay"
"github.com/hashicorp/yamux"
"github.com/sirupsen/logrus"
"io"
)

// handleICMP process incoming ICMP packets and, depending on the target host status, respond a ICMP ECHO Reply
Expand Down Expand Up @@ -84,7 +85,7 @@ func HandlePacket(nstack *stack.Stack, localConn TunConn, yamuxConn *yamux.Sessi
return
}

if endpointID.LocalAddress.To4() != "" {
if endpointID.LocalAddress.To4().String() != "" {
protonet = protocol.Networkv4
} else {
protonet = protocol.Networkv6
Expand Down
5 changes: 3 additions & 2 deletions pkg/proxy/netstack/icmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package netstack
import (
"bytes"
"errors"

"github.com/dismantl/gvisor/pkg/bufferv2"
"github.com/dismantl/gvisor/pkg/tcpip"
"github.com/dismantl/gvisor/pkg/tcpip/checksum"
Expand Down Expand Up @@ -127,7 +128,7 @@ func ProcessICMP(nstack *stack.Stack, pkt stack.PacketBufferPtr) {
localAddressBroadcast := pkt.NetworkPacketInfo.LocalAddressBroadcast

// It's possible that a raw socket expects to receive this.
pkt = stack.PacketBufferPtr{}
pkt = nil
_ = pkt // Suppress unused variable warning.

// Take the base of the incoming request IP header but replace the options.
Expand All @@ -143,7 +144,7 @@ func ProcessICMP(nstack *stack.Stack, pkt stack.PacketBufferPtr) {
// or multicast address).
localAddr := ipHdr.DestinationAddress()
if localAddressBroadcast || header.IsV4MulticastAddress(localAddr) {
localAddr = ""
localAddr = tcpip.Address{}
}

r, err := nstack.FindRoute(1, localAddr, ipHdr.SourceAddress(), ipv4.ProtocolNumber, false /* multicastLoop */)
Expand Down

0 comments on commit 3b02928

Please sign in to comment.