Files
indra/pkg/indra/helper-sendexit.go
2023-01-28 11:17:42 +00:00

21 lines
532 B
Go

package indra
import (
"github.com/indra-labs/indra/pkg/onion"
"github.com/indra-labs/indra/pkg/traffic"
"github.com/indra-labs/indra/pkg/util/slice"
)
func (en *Engine) SendExit(port uint16, message slice.Bytes,
target *traffic.Session, hook func(b slice.Bytes)) {
hops := []byte{0, 1, 2, 3, 4, 5}
s := make(traffic.Sessions, len(hops))
s[2] = target
se := en.Select(hops, s)
var c traffic.Circuit
copy(c[:], se)
o := onion.SendExit(port, message, se[len(se)-1], c, en.KeySet)
en.SendOnion(c[0].AddrPort, o, hook)
}