update tls path

This commit is contained in:
Tokumeikoi 2020-07-02 21:41:14 +08:00
parent a905a5ad27
commit 971637ffd6
4 changed files with 16 additions and 5 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin\Server;
use App\Http\Requests\Admin\ServerTrojanSave; use App\Http\Requests\Admin\ServerTrojanSave;
use App\Http\Requests\Admin\ServerTrojanSort; use App\Http\Requests\Admin\ServerTrojanSort;
use App\Http\Requests\Admin\ServerTrojanUpdate; use App\Http\Requests\Admin\ServerTrojanUpdate;
use App\Services\ServerService;
use App\Utils\CacheKey; use App\Utils\CacheKey;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
@ -131,4 +132,13 @@ class TrojanController extends Controller
'data' => true 'data' => true
]); ]);
} }
public function viewConfig(Request $request)
{
$serverService = new ServerService();
$config = $serverService->getTrojanConfig($request->input('node_id'), 23333);
return response([
'data' => $config
]);
}
} }

View File

@ -35,6 +35,7 @@ class AdminRoute
$router->post('update', 'Admin\\Server\\TrojanController@update'); $router->post('update', 'Admin\\Server\\TrojanController@update');
$router->post('copy', 'Admin\\Server\\TrojanController@copy'); $router->post('copy', 'Admin\\Server\\TrojanController@copy');
$router->post('sort', 'Admin\\Server\\TrojanController@sort'); $router->post('sort', 'Admin\\Server\\TrojanController@sort');
$router->post('viewConfig', 'Admin\\Server\\TrojanController@viewConfig');
}); });
$router->group([ $router->group([
'prefix' => 'server/v2ray' 'prefix' => 'server/v2ray'

View File

@ -120,8 +120,8 @@ class ServerService
$json = json_decode(self::TROJAN_CONFIG); $json = json_decode(self::TROJAN_CONFIG);
$json->local_port = $server->server_port; $json->local_port = $server->server_port;
$json->ssl->sni = $server->server_name ? $server->server_name : $server->host; $json->ssl->sni = $server->server_name ? $server->server_name : $server->host;
$json->ssl->cert = "/root/.cert/{$server->host}.crt"; $json->ssl->cert = "/root/.cert/server.crt";
$json->ssl->key = "/root/.cert/{$server->host}.key"; $json->ssl->key = "/root/.cert/server.key";
$json->api->api_port = $localPort; $json->api->api_port = $localPort;
return $json; return $json;
} }
@ -196,8 +196,8 @@ class ServerService
$tlsSettings = json_decode($server->tlsSettings); $tlsSettings = json_decode($server->tlsSettings);
$json->inbound->streamSettings->security = 'tls'; $json->inbound->streamSettings->security = 'tls';
$tls = (object)[ $tls = (object)[
'certificateFile' => '/home/v2ray.crt', 'certificateFile' => '/root/.cert/server.crt',
'keyFile' => '/home/v2ray.key' 'keyFile' => '/root/.cert/server.key'
]; ];
$json->inbound->streamSettings->tlsSettings = new \StdClass(); $json->inbound->streamSettings->tlsSettings = new \StdClass();
if (isset($tlsSettings->serverName)) { if (isset($tlsSettings->serverName)) {

File diff suppressed because one or more lines are too long