Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117900601
D5754.1775380111.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D5754.1775380111.diff
View Options
diff --git a/src/app/Policy/Greylist.php b/src/app/Policy/Greylist.php
--- a/src/app/Policy/Greylist.php
+++ b/src/app/Policy/Greylist.php
@@ -25,6 +25,10 @@
protected $whitelist;
protected $request = [];
+ public const CONNECTION_MIN_AGE_MINUTES = 5;
+ public const CONNECTION_MAX_AGE_DAYS = 7;
+ public const CONNECTION_WHITELIST_THRESHOLD = 5;
+
/**
* Class constructor
*
@@ -122,7 +126,7 @@
$connect = $this->findConnectsCollection()->first();
// Purge all old information if we have no recent entry
- if ($connect && $connect->updated_at < $this->timestamp->copy()->subDays(7)) {
+ if ($connect && $connect->updated_at < $this->timestamp->copy()->subDays(self::CONNECTION_MAX_AGE_DAYS)) {
$this->findConnectsCollection()->delete();
$connect = null;
}
@@ -143,7 +147,7 @@
->where('net_type', $this->netType)
->first();
- $cutoffDate = $this->timestamp->copy()->subDays(7)->startOfDay();
+ $cutoffDate = $this->timestamp->copy()->subDays(self::CONNECTION_MAX_AGE_DAYS)->startOfDay();
DB::beginTransaction();
@@ -172,7 +176,7 @@
->update(['greylisting' => false, 'updated_at' => $this->timestamp]);
$enabled = false;
- } elseif ($all->count() >= 4) {
+ } elseif ($all->count() >= (self::CONNECTION_WHITELIST_THRESHOLD - 1)) {
// Automatically create a whitelist if we have at least 5 (4 existing plus this) messages from the sender
$this->whitelist = Whitelist::create([
'sender_domain' => $this->senderDomain,
@@ -202,7 +206,7 @@
$connect->connect_count++;
// TODO: The period of time for which the greylisting persists is configurable.
- if ($connect->created_at < $this->timestamp->copy()->subMinutes(5)) {
+ if ($connect->created_at < $this->timestamp->copy()->subMinutes(self::CONNECTION_MIN_AGE_MINUTES)) {
$defer = false;
$connect->greylisting = false;
diff --git a/src/tests/Feature/Policy/GreylistTest.php b/src/tests/Feature/Policy/GreylistTest.php
--- a/src/tests/Feature/Policy/GreylistTest.php
+++ b/src/tests/Feature/Policy/GreylistTest.php
@@ -86,7 +86,7 @@
$this->assertNull($whitelist);
- for ($i = 0; $i < 5; $i++) {
+ for ($i = 0; $i < Greylist::CONNECTION_WHITELIST_THRESHOLD; $i++) {
$request = new Greylist([
'sender' => "someone{$i}@sender.domain",
'recipient' => $this->domainOwner->email,
@@ -162,7 +162,7 @@
'net_type' => IP4Net::class,
]);
- $connect->created_at = Carbon::now()->subMinutes(6);
+ $connect->created_at = Carbon::now()->subMinutes(Greylist::CONNECTION_MIN_AGE_MINUTES + 1);
$connect->save();
$request = new Greylist([
@@ -254,7 +254,7 @@
$this->assertTrue($request->shouldDefer());
- $connect->created_at = Carbon::now()->subMinutes(6);
+ $connect->created_at = Carbon::now()->subMinutes(Greylist::CONNECTION_MIN_AGE_MINUTES + 1);
$connect->save();
$this->assertFalse($request->shouldDefer());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 9:08 AM (1 h, 19 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18832938
Default Alt Text
D5754.1775380111.diff (3 KB)
Attached To
Mode
D5754: Document the greylisting variables
Attached
Detach File
Event Timeline