浏览代码

Update RestrictedNames

Daniel Supernault 7 年之前
父节点
当前提交
b6dc212b4d
共有 2 个文件被更改,包括 40 次插入11 次删除
  1. 31 11
      app/Util/Lexer/RestrictedNames.php
  2. 9 0
      config/pixelfed.php

+ 31 - 11
app/Util/Lexer/RestrictedNames.php

@@ -4,10 +4,9 @@ namespace App\Util\Lexer;
 
 class RestrictedNames {
 
-  static $restricted = [
+  static $blacklist = [
      "about",
      "abuse",
-     "admin",
      "administrator",
      "app",
      "autoconfig",
@@ -38,16 +37,12 @@ class RestrictedNames {
      "faq",
      "faqs",
      "features",
-     "federation",
-     "fediverse",
      "ftp",
      "guest",
      "guests",
      "help",
-     "horizon",
      "hostmaster",
      "hostmaster",
-     "i",
      "image",
      "images",
      "imap",
@@ -58,7 +53,6 @@ class RestrictedNames {
      "isatap",
      "it",
      "js",
-     "liltay",
      "localdomain",
      "localhost",
      "login",
@@ -89,9 +83,6 @@ class RestrictedNames {
      "ns8",
      "ns9",
      "owner",
-     "pixelfed",
-     "pixelfed-support",
-     "pixelfed_support",
      "pop",
      "pop3",
      "postmaster",
@@ -125,9 +116,38 @@ class RestrictedNames {
      "www"
    ];
 
+  static $reserved = [
+     // Reserved for instance admin
+     "admin",
+
+     // Static Assets
+     "assets",
+
+     // Laravel Horizon
+     "horizon",
+
+     // Reserved route
+     "i",
+
+     // Official accounts
+     "pixelfed",
+     "pixelfed-support",
+     "pixelfed_support",
+  ];
+
   public static function get()
   {
-    return self::$restricted;
+     
+     $reserved = $blacklist = [];
+
+     if(true == config('pixelfed.restricted_names.use_blacklist')) {
+          $blacklist = self::$blacklist;
+     }
+
+     if(true == config('pixelfed.restricted_names.reserved_routes')) {
+          $reserved = self::$reserved;
+     }
+     return array_merge($blacklist, $reserved);
   }
 
 }

+ 9 - 0
config/pixelfed.php

@@ -1,9 +1,18 @@
 <?php
 
 return [
+
   'version' => '0.1.0',
+
   'nodeinfo' => [
     'url' => config('app.url') . '/' . 'api/nodeinfo/2.0.json'
   ],
+
   'memory_limit' => '1024M',
+
+  'restricted_names' => [
+    'reserved_routes' => true,
+    'use_blacklist' => false
+  ],
+  
 ];