增加 IP Port 支持
This commit is contained in:
parent
f60cc898c1
commit
fb56b30d16
@ -54,6 +54,7 @@ public function store(Request $request): RedirectResponse
|
||||
$module->name = $request->input('name');
|
||||
$module->api_token = $api_token;
|
||||
$module->url = $request->input('url');
|
||||
$module->ip_port = $request->input('ip_port');
|
||||
$module->status = $request->input('status');
|
||||
$module->wecom_key = $request->input('wecom_key');
|
||||
|
||||
@ -68,6 +69,7 @@ private function rules(): array
|
||||
'id' => 'required|string|max:255',
|
||||
'name' => 'required|string|max:255',
|
||||
'url' => 'required|url',
|
||||
'ip_port' => 'nullable|string|max:255',
|
||||
'status' => 'required|string|in:up,down,maintenance',
|
||||
'balance' => 'nullable|numeric',
|
||||
'wecom_key' => 'nullable|string|max:255',
|
||||
@ -116,6 +118,7 @@ public function update(Request $request, Module $module): RedirectResponse
|
||||
$module->id = $request->input('id');
|
||||
$module->name = $request->input('name');
|
||||
$module->url = $request->input('url');
|
||||
$module->ip_port = $request->input('ip_port');
|
||||
$module->status = $request->input('status');
|
||||
$module->wecom_key = $request->input('wecom_key');
|
||||
|
||||
|
@ -83,7 +83,19 @@ public function remote($func, $requests): array
|
||||
|
||||
public function http(): PendingRequest
|
||||
{
|
||||
return Http::module($this->api_token, $this->url.'/remote')->acceptJson()->timeout(5);
|
||||
$http = Http::module($this->api_token, $this->url.'/remote')->acceptJson()->timeout(5);
|
||||
|
||||
if ($this->ip_port) {
|
||||
// 如果设置了 ip_port 则使用 ip_port
|
||||
$http->baseUrl($this->ip_port . '/remote');
|
||||
|
||||
// 添加 Host 头
|
||||
$http->withHeaders([
|
||||
'Host' => parse_url($this->url, PHP_URL_HOST),
|
||||
]);
|
||||
}
|
||||
|
||||
return $http;
|
||||
}
|
||||
|
||||
private function getResponse(Response $response): array
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->string('ip_port')->nullable()->after('url');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('modules', function (Blueprint $table) {
|
||||
$table->dropColumn('ip_port');
|
||||
});
|
||||
}
|
||||
};
|
@ -22,6 +22,10 @@
|
||||
<label for="url">对端地址</label>
|
||||
<input type="text" class="form-control" id="url" name="url">
|
||||
</div>
|
||||
<div class="form-group mt-1">
|
||||
<label for="ip_port">源站 IP:Port</label>
|
||||
<input type="text" class="form-control" id="ip_port" name="ip_port">
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-1">
|
||||
<label for="wecom_key">企业微信 群机器人 WebHook Key</label>
|
||||
|
@ -25,6 +25,10 @@
|
||||
<label for="url">对端地址</label>
|
||||
<input type="text" class="form-control" id="url" name="url" value="{{ $module->url }}">
|
||||
</div>
|
||||
<div class="form-group mt-1">
|
||||
<label for="ip_port">源站 IP:Port</label>
|
||||
<input type="text" class="form-control" id="ip_port" name="ip_port" value="{{ $module->ip_port }}">
|
||||
</div>
|
||||
|
||||
<div class="form-group mt-1">
|
||||
<label for="api_token">通信密钥(即 Api Token, 非常重要,请勿泄露。)</label>
|
||||
|
Loading…
Reference in New Issue
Block a user