ping: Add destination rewriter

This commit is contained in:
世界 2025-09-11 18:51:00 +08:00
parent 960457abba
commit 0381a06643
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
3 changed files with 88 additions and 9 deletions

View file

@ -27,7 +27,7 @@ type GVisorDestination struct {
logger logger.ContextLogger
endpoint tcpip.Endpoint
conn *gonet.TCPConn
rewriter *Rewriter
rewriter *SourceRewriter
timeout time.Duration
}
@ -76,7 +76,7 @@ func ConnectGVisor(
return nil, gonet.TranslateNetstackError(gErr)
}
endpoint.SocketOptions().SetHeaderIncluded(true)
rewriter := NewRewriter(ctx, logger, bindAddress4, bindAddress6)
rewriter := NewSourceRewriter(ctx, logger, bindAddress4, bindAddress6)
rewriter.CreateSession(tun.DirectRouteSession{Source: sourceAddress, Destination: destinationAddress}, routeContext)
destination := &GVisorDestination{
ctx: ctx,