diff --git a/src/Moesocks.Client.Services/Network/ConnectionRouter.cs b/src/Moesocks.Client.Services/Network/ConnectionRouter.cs
index cbbdedd..5c662de 100644
--- a/src/Moesocks.Client.Services/Network/ConnectionRouter.cs
+++ b/src/Moesocks.Client.Services/Network/ConnectionRouter.cs
@@ -66,6 +66,11 @@ public Task SendAsync(uint sessionKey, uint identifier, object message)
_logger.LogDebug($"client: {sessionKey} Sending message {message} to server.");
await _serializer.Serialize(sessionKey, identifier, message, _secureTransport);
}
+ catch(Exception ex)
+ {
+ _logger.LogError(default(EventId), ex.Message, ex);
+ throw;
+ }
finally
{
_semSlim.Release();
@@ -110,9 +115,9 @@ private async Task BeginReceiveMessages(CancellationToken cancellationToken)
_logger.LogWarning($"Proxy stopped.");
break;
}
- catch (Exception)
+ catch (Exception ex)
{
- _receivers.Clear();
+ _logger.LogError(default(EventId), ex.Message, ex);
}
}
}
diff --git a/src/Moesocks.Client.Services/Network/HttpProxyProvider.cs b/src/Moesocks.Client.Services/Network/HttpProxyProvider.cs
index 5a86dcb..4d27b97 100644
--- a/src/Moesocks.Client.Services/Network/HttpProxyProvider.cs
+++ b/src/Moesocks.Client.Services/Network/HttpProxyProvider.cs
@@ -80,6 +80,10 @@ private async void DispatchIncoming(TcpClient tcpClient)
await session.Run();
}
}
+ }
+ catch(InvalidDataException)
+ {
+
}
catch (Exception ex)
{
diff --git a/src/Moesocks.Client.Services/Network/TunnelProxySession.cs b/src/Moesocks.Client.Services/Network/TunnelProxySession.cs
index 32b7432..49b9f27 100644
--- a/src/Moesocks.Client.Services/Network/TunnelProxySession.cs
+++ b/src/Moesocks.Client.Services/Network/TunnelProxySession.cs
@@ -42,9 +42,16 @@ public TunnelProxySession(string targetHost, Stream remoteStream, byte[] takenBy
public async Task Run()
{
- await SendOkResponse();
- var tasks = new[] { RunMessageReceive(), RunClientRead() };
- await Task.WhenAll(tasks);
+ try
+ {
+ await SendOkResponse();
+ var tasks = new[] { RunMessageReceive(), RunClientRead() };
+ await Task.WhenAll(tasks);
+ }
+ finally
+ {
+ _messageBus.EndReceive(_sessionKey);
+ }
}
private const string _okResponse = "HTTP/1.1 200 OK\r\n\r\n";
@@ -53,11 +60,11 @@ public async Task Run()
private async Task SendOkResponse()
{
var eor = FindEndOfRequest(_takenBytes, _takenBytes.Length);
- if(eor == -1)
+ if (eor == -1)
{
var buffer = new byte[512];
int read = 0;
- while(eor == -1)
+ while (eor == -1)
{
read = await _remoteStream.ReadAsync(buffer, 0, buffer.Length);
if (read == 0)
@@ -83,7 +90,7 @@ static int FindEndOfRequest(byte[] content, int length)
bool next = false;
for (int i = 0; i < _eor.Length; i++)
{
- if(content[first + i] != _eor[i])
+ if (content[first + i] != _eor[i])
{
next = true;
break;
@@ -122,7 +129,7 @@ private async Task RunMessageReceive()
private async Task RunClientRead()
{
- if(_takenBytes.Length != 0)
+ if (_takenBytes.Length != 0)
{
await _messageBus.SendAsync(_sessionKey, _identifier++, new TcpContentMessage
{
diff --git a/src/Moesocks.Client/Views/ShellView.xaml b/src/Moesocks.Client/Views/ShellView.xaml
index dfd45f0..3e83e13 100644
--- a/src/Moesocks.Client/Views/ShellView.xaml
+++ b/src/Moesocks.Client/Views/ShellView.xaml
@@ -9,6 +9,18 @@
SaveWindowPosition="True"
EnableDWMDropShadow="True" ShowIconOnTitleBar="True"
Height="338" Width="601" Title="Moesocks">
+
+
+
+
+
+
+