Skip to content

Commit

Permalink
Fix data rewrite in tunnel mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jlucansky committed Dec 26, 2020
1 parent bf60cec commit ac2e302
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Source/Swiddler/Channels/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public void Observe(Channel other)
Observers.Add(other);
}

public void ObserveAfter<T>(Channel other) where T: Channel
{
int index = Observers.FindIndex(x => x is T) + 1;
if (index < 0) index = 0;
Observers.Insert(index, other);
}

/// <summary>
/// Marks all sending packets (Reads) from this channel with specified flow.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/Swiddler/Common/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ private void StartClient()
{
ServerChannel.DefaultFlow = TrafficFlow.Outbound;

ServerChannel.Observers.Insert(0, ClientChannel);
ServerChannel.ObserveAfter<RewriteChannel>(ClientChannel);
ClientChannel.Observe(ServerChannel);

SessionChannel.Observers.Insert(0, ClientChannel); // user input data send to client channel
SessionChannel.ObserveAfter<RewriteChannel>(ClientChannel); // user input data send to client channel
ClientChannel.Observe(SessionChannel);

IPEndPoint src = null, dst = targetEP;
Expand Down

0 comments on commit ac2e302

Please sign in to comment.