-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
423 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
use App\Models\TrafficLog; | ||
use App\Models\User; | ||
use App\Utils\Tools; | ||
use App\Services\V2rayGenerator; | ||
|
||
class NodeController extends BaseController | ||
{ | ||
|
@@ -109,4 +110,23 @@ public function postTraffic($request, $response, $args) | |
|
||
return $this->echoJson($response, $res); | ||
} | ||
|
||
public function v2rayUsers($request, $response, $args) | ||
{ | ||
$node = Node::find($args['id']); | ||
$users = User::all(); | ||
|
||
$v = new V2rayGenerator(); | ||
$v->setPort($node->v2ray_port); | ||
|
||
foreach ($users as $user) { | ||
if ($user->enable == 0) { | ||
continue; | ||
} | ||
$email = sprintf("%[email protected]", $user->v2ray_uuid); | ||
$v->addUser($user->v2ray_uuid, $user->v2ray_level, $user->v2ray_alter_id, $email); | ||
} | ||
|
||
return $this->echoJson($response, $v->getArr()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
|
||
namespace App\Services; | ||
|
||
|
||
use App\Utils\EmptyClass; | ||
|
||
class V2rayGenerator | ||
{ | ||
|
||
private $arr = [ | ||
"log" => [ | ||
"access" => "/var/log/access.log", | ||
"error" => "/var/log/error.log", | ||
"loglevel" => "warning" | ||
], | ||
"inbound" => [ | ||
"port" => 8300, | ||
"protocol" => "vmess", | ||
"settings" => [ | ||
"clients" => [ | ||
] | ||
] | ||
], | ||
"outbound" => [ | ||
"protocol" => "freedom", | ||
// "settings" => , | ||
], | ||
"inboundDetour" => [], | ||
"outboundDetour" => [ | ||
[ | ||
"protocol" => "blackhole", | ||
// "settings" => [], | ||
"tag" => "blocked" | ||
] | ||
], | ||
"routing" => [ | ||
"strategy" => "rules", | ||
"settings" => [ | ||
"rules" => [ | ||
[ | ||
"type" => "field", | ||
"ip" => [ | ||
"0.0.0.0/8", | ||
"10.0.0.0/8", | ||
"100.64.0.0/10", | ||
"127.0.0.0/8", | ||
"169.254.0.0/16", | ||
"172.16.0.0/12", | ||
"192.0.0.0/24", | ||
"192.0.2.0/24", | ||
"192.168.0.0/16", | ||
"198.18.0.0/15", | ||
"198.51.100.0/24", | ||
"203.0.113.0/24", | ||
"::1/128", | ||
"fc00::/7", | ||
"fe80::/10" | ||
], | ||
"outboundTag" => "blocked" | ||
] | ||
] | ||
] | ||
] | ||
]; | ||
|
||
|
||
public function addUser($uuid, $level, $alertId, $email) | ||
{ | ||
$user = [ | ||
"id" => $uuid, | ||
"level" => $level, | ||
"alterId" => $alertId, | ||
"email" => $email | ||
]; | ||
array_push($this->arr["inbound"]['settings']['clients'], $user); | ||
} | ||
|
||
public function setPort($port) | ||
{ | ||
$this->arr['inbound']['port'] = $port; | ||
} | ||
|
||
public function getArr() | ||
{ | ||
return $this->arr; | ||
} | ||
|
||
public function __construct() | ||
{ | ||
$this->arr["outbound"]["settings"] = new EmptyClass(); | ||
$this->arr["outboundDetour"][0]["settings"] = new EmptyClass(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
|
||
namespace App\Utils; | ||
|
||
|
||
class EmptyClass | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
/** | ||
* Migration auto-generated by Sequel Pro Laravel Export | ||
* @see https://github.com/cviebrock/sequel-pro-laravel-export | ||
*/ | ||
class UpdateSsNodeTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::table('ss_node', function (Blueprint $table) { | ||
$table->integer('ss_enable')->default(1); | ||
$table->integer('v2ray_enable')->default(0); | ||
$table->integer('https_enable')->default(0); | ||
$table->integer('v2ray_port')->default(8100); | ||
$table->string('v2ray_protocol')->default("tcp"); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.