refactor: update path request handling to use transportIdentity and improve logging with packet length
This commit is contained in:
@@ -557,35 +557,33 @@ func (t *Transport) RequestPath(destinationHash []byte, onInterface string, tag
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pathRequestData []byte
|
var pathRequestData []byte
|
||||||
if t.identity != nil {
|
if t.transportIdentity != nil {
|
||||||
pathRequestData = append(destinationHash, t.identity.Hash()...)
|
pathRequestData = append(destinationHash, t.transportIdentity.Hash()...)
|
||||||
pathRequestData = append(pathRequestData, tag...)
|
pathRequestData = append(pathRequestData, tag...)
|
||||||
} else {
|
} else {
|
||||||
pathRequestData = append(destinationHash, tag...)
|
pathRequestData = append(destinationHash, tag...)
|
||||||
}
|
}
|
||||||
|
|
||||||
pathRequestDest := destination.NewDestination(
|
destHashFull := sha256.Sum256([]byte("rnstransport.path.request"))
|
||||||
nil,
|
pathRequestDestHash := destHashFull[:common.SIZE_16]
|
||||||
destination.OUT,
|
|
||||||
destination.PLAIN,
|
|
||||||
"rnstransport",
|
|
||||||
"path",
|
|
||||||
"request",
|
|
||||||
)
|
|
||||||
|
|
||||||
pkt := packet.NewPacket(
|
pkt := packet.NewPacket(
|
||||||
pathRequestDest,
|
packet.DestinationPlain,
|
||||||
pathRequestData,
|
pathRequestData,
|
||||||
common.DATA,
|
0x00,
|
||||||
|
0x00,
|
||||||
|
packet.PropagationBroadcast,
|
||||||
|
0x01,
|
||||||
|
pathRequestDestHash,
|
||||||
|
false,
|
||||||
|
0x00,
|
||||||
)
|
)
|
||||||
pkt.SetTransportType(common.BROADCAST)
|
|
||||||
pkt.SetHeaderType(common.HEADER_1)
|
|
||||||
|
|
||||||
if err := pkt.Pack(); err != nil {
|
if err := pkt.Pack(); err != nil {
|
||||||
return fmt.Errorf("failed to pack path request: %w", err)
|
return fmt.Errorf("failed to pack path request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Log(debug.DEBUG_INFO, "Sending path request", "dest_hash", fmt.Sprintf("%x", destinationHash), "data_len", len(pathRequestData))
|
debug.Log(debug.DEBUG_INFO, "Sending path request", "dest_hash", fmt.Sprintf("%x", destinationHash), "data_len", len(pathRequestData), "packet_len", len(pkt.Raw))
|
||||||
|
|
||||||
if onInterface != "" {
|
if onInterface != "" {
|
||||||
iface, ok := t.interfaces[onInterface]
|
iface, ok := t.interfaces[onInterface]
|
||||||
|
|||||||
Reference in New Issue
Block a user