Skip to content

Commit b8f3f0f

Browse files
committed
blank useragent bug
1 parent aa47171 commit b8f3f0f

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

App/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<!-- accept relays (required for the webclient) -->
2222
<add key="acceptRelays" value="true"/>
2323

24-
<!-- set to false to shutdown when the last relay is finished or canceled -->
24+
<!-- set to false to shutdown when the last relay is finished or canceled (only applicable to the tray app) -->
2525
<add key="stayOpen" value="true"/>
2626

2727
<!-- max concurrent connections for listener -->

Server/RelayServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private async Task ProcessRequestAsync(HttpContextBase context)
131131
{
132132
if (validCode)
133133
{
134-
if (activeRelays.TryGetValue(code, out IRelay relay) && !botAgents.IsMatch(context.Request.UserAgent))
134+
if (activeRelays.TryGetValue(code, out IRelay relay) && !botAgents.IsMatch(context.Request.UserAgent ?? ""))
135135
await relay.HandleDownloadRequest(context);
136136
else
137137
context.Response.StatusCode = 410;

Tests/TestTransfers.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ private void LocalDownload(int size, bool pipe = false)
5555
var code = server.AddRelay(new LocalRelay(stream));
5656

5757
using (var client = new WebClient())
58-
CollectionAssert.AreEqual(data, client.DownloadData(downloadUrl + code));
58+
{
59+
var downloaded = client.DownloadData(downloadUrl + code);
60+
if (listen.IsFaulted) throw listen.Exception.InnerException;
61+
CollectionAssert.AreEqual(data, downloaded);
62+
}
5963
}
6064

6165
private void SocketDownload(int size, bool pipe = false)
@@ -66,7 +70,11 @@ private void SocketDownload(int size, bool pipe = false)
6670
var code = socket.AddRelay(websocketUrl, stream).Result;
6771

6872
using (var client = new WebClient())
69-
CollectionAssert.AreEqual(data, client.DownloadData(downloadUrl + code));
73+
{
74+
var downloaded = client.DownloadData(downloadUrl + code);
75+
if (listen.IsFaulted) throw listen.Exception.InnerException;
76+
CollectionAssert.AreEqual(data, downloaded);
77+
}
7078
}
7179

7280
[TestMethod] public void Local_Empty() => LocalDownload(0);

0 commit comments

Comments
 (0)