Browse Source

opt 1.2.3

Tokumeikoi 5 years ago
parent
commit
6a6de2dc22
1 changed files with 11 additions and 8 deletions
  1. 11 8
      app/Utils/Helper.php

+ 11 - 8
app/Utils/Helper.php

@@ -2,6 +2,9 @@
 
 namespace App\Utils;
 
+use App\Models\Server;
+use App\Models\User;
+
 class Helper
 {
     public static function guid($format = false)
@@ -53,23 +56,23 @@ class Helper
         return $str;
     }
 
-    public static function buildVmessLink($item, $user)
+    public static function buildVmessLink(Server $server, User $user)
     {
         $config = [
             "v" => "2",
-            "ps" => $item->name,
-            "add" => $item->host,
-            "port" => $item->port,
+            "ps" => $server->name,
+            "add" => $server->host,
+            "port" => $server->port,
             "id" => $user->v2ray_uuid,
             "aid" => "2",
-            "net" => $item->network,
+            "net" => $server->network,
             "type" => "none",
             "host" => "",
             "path" => "",
-            "tls" => $item->tls ? "tls" : ""
+            "tls" => $server->tls ? "tls" : ""
         ];
-        if ($item->network == 'ws') {
-            $wsSettings = json_decode($item->settings);
+        if ((string)$server->network === 'ws') {
+            $wsSettings = json_decode($server->networkSettings);
             if (isset($wsSettings->path)) $config['path'] = $wsSettings->path;
             if (isset($wsSettings->headers->Host)) $config['host'] = $wsSettings->headers->Host;
         }