Skip to content

Commit

Permalink
fix: relay stream to correct target peer
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <[email protected]>
  • Loading branch information
paralin committed May 28, 2024
1 parent ebe156d commit ab43a2b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ github.com/aperturerobotics/protobuf-go-lite v0.6.5 h1:AuPPcZ7ZaJe9ZYYC4gF7/5/Xb
github.com/aperturerobotics/protobuf-go-lite v0.6.5/go.mod h1:YTbfnUj3feSULhs8VgepAHFnF3wUc0CPj4jd2axy21I=
github.com/aperturerobotics/quic-go v0.43.1-0.20240504081906-25e38f065e10 h1:xtQ4K5XBgTSO47KbLYYEy9Y3HWLGeVNlbJXw1RfAXt4=
github.com/aperturerobotics/quic-go v0.43.1-0.20240504081906-25e38f065e10/go.mod h1:IWwvw/rjosC5aPDuEgzbRPNlZSHC4b4ABztoalIe59g=
github.com/aperturerobotics/starpc v0.32.10 h1:Z9Y0XVMSUSg8oMywjAba2eM2N2KaFWrg2tp88kSt8Pg=
github.com/aperturerobotics/starpc v0.32.10/go.mod h1:nc3qveJAMZJlRpHZyHm0yvESvCbU0xx38mc/nMvpb0o=
github.com/aperturerobotics/starpc v0.32.11 h1:u7YdybGmhJI8yBUvEHxyBOh19j6KgxAkSLltTkvIFI4=
github.com/aperturerobotics/starpc v0.32.11/go.mod h1:CVH9wMjd4jjsD5xo/SCQu2vFv8u1etYG7+7FVDavH6w=
github.com/aperturerobotics/util v1.23.4 h1:IXkVoN3Cc+5U5Rhd5hC00VGgL1PainhpaTyz5IPkc8I=
Expand Down
2 changes: 1 addition & 1 deletion stream/relay/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (c *Config) GetConfigID() string {

// EqualsConfig checks if the config is equal to another.
func (c *Config) EqualsConfig(c2 config.Config) bool {
return config.EqualsConfig[*Config](c, c2)
return config.EqualsConfig(c, c2)
}

var _ config.Config = ((*Config)(nil))
17 changes: 3 additions & 14 deletions stream/relay/stream_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (m *MountedStreamHandler) HandleMountedStream(
if err != nil {
return err
}

go func() {
s := strm.GetStream()
defer func() {
Expand All @@ -57,24 +58,12 @@ func (m *MountedStreamHandler) HandleMountedStream(

// Emit directive to relay stream to target peer
m.le.Debug("relaying stream to target peer")
outMstrm, _, ref, err := bus.ExecWaitValue[link.MountedStream](
ctx,
m.bus,
link.NewOpenStreamWithPeer(
m.targetProtocolID,
localPeerID, remotePeerID,
0,
strm.GetOpenOpts(),
),
nil,
nil,
nil,
)
outMstrm, rel, err := link.OpenStreamWithPeerEx(ctx, m.bus, m.targetProtocolID, localPeerID, m.targetPeerID, 0, strm.GetOpenOpts())
if err != nil {
m.le.WithError(err).Warn("unable to relay stream to target peer")
return
}
ref.Release()
rel()

outStrm := outMstrm.GetStream()
defer outStrm.Close()
Expand Down

0 comments on commit ab43a2b

Please sign in to comment.