Skip to content

Commit d11a28b

Browse files
committed
moved whitelist to settings
1 parent 46ddd00 commit d11a28b

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/Tetrifact.Core/ISettings.cs

+5
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,10 @@ public interface ISettings
237237
/// </summary>
238238
/// <returns></returns>
239239
bool Validate();
240+
241+
/// <summary>
242+
/// IPs treated as "from own website"
243+
/// </summary>
244+
IEnumerable<string> WhiteListedLocalAddresses { get; set; }
240245
}
241246
}

src/Tetrifact.Core/Settings.cs

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ public class Settings : ISettings
102102

103103
public IEnumerable<TagColor> TagColors { get; set; }
104104

105+
public IEnumerable<string> WhiteListedLocalAddresses { get; set; }
106+
105107
#endregion
106108

107109
#region CTORS
@@ -150,6 +152,7 @@ public Settings()
150152
this.Theme = "dark";
151153
this.WipeTempOnStart = true;
152154
this.WorkerThreadCount = 8;
155+
this.WhiteListedLocalAddresses = new string[] { };
153156
}
154157

155158
#endregion

src/Tetrifact.Web/Controllers/ArchivesController.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ public ActionResult GetArchive(string packageId, [FromQuery(Name = "ticket")] st
9494
if (!_indexReader.PackageExists(packageId))
9595
throw new PackageNotFoundException(packageId);
9696

97-
string[] localhosts = new string[] {
98-
"localhost",
99-
"127.0.0.1",
100-
"0.0.0.0"
101-
};
102-
10397
// enforce ticket if queue enabled
10498
RequestHeaders headers = Request.GetTypedHeaders();
10599
string range = string.Empty;
@@ -113,7 +107,7 @@ public ActionResult GetArchive(string packageId, [FromQuery(Name = "ticket")] st
113107
if (Request.HttpContext.Connection.RemoteIpAddress != null)
114108
host = Request.HttpContext.Connection.RemoteIpAddress.ToString();
115109

116-
bool isLocal = localhosts.Contains(headers.Host.Host.ToLower());
110+
bool isLocal = _settings.WhiteListedLocalAddresses.Contains(headers.Host.Host.ToLower());
117111
string ticketLog = string.Empty;
118112

119113
// local (this website) downloads always allowed.

0 commit comments

Comments
 (0)