mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
seed box record add asn
This commit is contained in:
@@ -101,8 +101,12 @@ class Test extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$result = \Nexus\Plugin\Plugin::listEnabled();
|
||||
dd($result);
|
||||
$file = resource_path("geoip/GeoLite2-ASN.mmdb");
|
||||
$file = resource_path("geoip/GeoLite2-City.mmdb");
|
||||
$reader = new Reader($file);
|
||||
$asn = $reader->asn("94.16.120.0");
|
||||
// $result = \Nexus\Plugin\Plugin::listEnabled();
|
||||
dd($asn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class SeedBoxRecordResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('operator')->label(__('label.seed_box_record.operator')),
|
||||
Forms\Components\TextInput::make('bandwidth')->label(__('label.seed_box_record.bandwidth'))->integer(),
|
||||
Forms\Components\TextInput::make('asn')->label(__('label.seed_box_record.asn'))->integer(),
|
||||
Forms\Components\TextInput::make('ip_begin')->label(__('label.seed_box_record.ip_begin')),
|
||||
Forms\Components\TextInput::make('ip_end')->label(__('label.seed_box_record.ip_end')),
|
||||
Forms\Components\TextInput::make('ip')->label(__('label.seed_box_record.ip'))->helperText(__('label.seed_box_record.ip_help')),
|
||||
@@ -72,6 +73,7 @@ class SeedBoxRecordResource extends Resource
|
||||
,
|
||||
Tables\Columns\TextColumn::make('operator')->label(__('label.seed_box_record.operator'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('bandwidth')->label(__('label.seed_box_record.bandwidth')),
|
||||
Tables\Columns\TextColumn::make('asn')->label(__('label.seed_box_record.asn')),
|
||||
Tables\Columns\TextColumn::make('ip')
|
||||
->label(__('label.seed_box_record.ip'))
|
||||
->searchable(true, function (Builder $query, $search) {
|
||||
|
||||
@@ -42,16 +42,6 @@ class CalculateUserSeedBonus implements ShouldQueue
|
||||
$this->requestId = $requestId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the time at which the job should timeout.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function retryUntil()
|
||||
{
|
||||
return now()->addSeconds(Setting::get('main.autoclean_interval_one'));
|
||||
}
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
public $timeout = 3600;
|
||||
|
||||
@@ -36,16 +36,6 @@ class GenerateTemporaryInvite implements ShouldQueue
|
||||
$this->count = $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the time at which the job should timeout.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function retryUntil()
|
||||
{
|
||||
return now()->addHours(1);
|
||||
}
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
public $timeout = 1800;
|
||||
|
||||
@@ -42,16 +42,6 @@ class UpdateTorrentSeedersEtc implements ShouldQueue
|
||||
$this->requestId = $requestId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the time at which the job should timeout.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function retryUntil()
|
||||
{
|
||||
return now()->addSeconds(Setting::get('main.autoclean_interval_three'));
|
||||
}
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
public $timeout = 1800;
|
||||
|
||||
@@ -42,16 +42,6 @@ class UpdateUserSeedingLeechingTime implements ShouldQueue
|
||||
$this->requestId = $requestId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the time at which the job should timeout.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function retryUntil()
|
||||
{
|
||||
return now()->addSeconds(Setting::get('main.autoclean_interval_four'));
|
||||
}
|
||||
|
||||
public $tries = 1;
|
||||
|
||||
public $timeout = 3600;
|
||||
@@ -102,8 +92,8 @@ class UpdateUserSeedingLeechingTime implements ShouldQueue
|
||||
$count = 0;
|
||||
foreach ($res as $row) {
|
||||
$count++;
|
||||
$seedtimeUpdates = sprintf("when %d then %d", $row->userid, $row->seedtime_sum ?? 0);
|
||||
$leechTimeUpdates = sprintf("when %d then %d", $row->userid, $row->leechtime_sum ?? 0);
|
||||
$seedtimeUpdates[] = sprintf("when %d then %d", $row->userid, $row->seedtime_sum ?? 0);
|
||||
$leechTimeUpdates[] = sprintf("when %d then %d", $row->userid, $row->leechtime_sum ?? 0);
|
||||
}
|
||||
$sql = sprintf(
|
||||
"update users set seedtime = case id %s end, leechtime = case id %s end, seed_time_updated_at = '%s' where id in (%s)",
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
class SeedBoxRecord extends NexusModel
|
||||
{
|
||||
protected $fillable = ['type', 'uid', 'status', 'operator', 'bandwidth', 'ip', 'ip_begin', 'ip_end', 'ip_begin_numeric', 'ip_end_numeric',
|
||||
'comment', 'version', 'is_allowed',
|
||||
'comment', 'version', 'is_allowed', 'asn'
|
||||
];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -40,7 +40,13 @@ class SeedBoxRepository extends BaseRepository
|
||||
|
||||
private function formatParams(array $params): array
|
||||
{
|
||||
if (!empty($params['ip']) && empty($params['ip_begin']) && empty($params['ip_end'])) {
|
||||
$params = array_filter($params);
|
||||
if (
|
||||
!empty($params['ip'])
|
||||
&& empty($params['ip_begin'])
|
||||
&& empty($params['ip_end'])
|
||||
&& empty($params['asn'])
|
||||
) {
|
||||
try {
|
||||
$ipBlock = IPBlock::create($params['ip']);
|
||||
$params['ip_begin_numeric'] = $ipBlock->getFirstIp()->numeric();
|
||||
@@ -62,8 +68,12 @@ class SeedBoxRepository extends BaseRepository
|
||||
if (empty($params['version'])) {
|
||||
throw new \InvalidArgumentException("Invalid IPBlock or IP: " . $params['ip']);
|
||||
}
|
||||
|
||||
} elseif (empty($params['ip']) && !empty($params['ip_begin']) && !empty($params['ip_end'])) {
|
||||
} elseif (
|
||||
empty($params['ip'])
|
||||
&& empty($params['asn'])
|
||||
&& !empty($params['ip_begin'])
|
||||
&& !empty($params['ip_end'])
|
||||
) {
|
||||
$ipBegin = IP::create($params['ip_begin']);
|
||||
$params['ip_begin_numeric'] = $ipBegin->numeric();
|
||||
|
||||
@@ -73,6 +83,13 @@ class SeedBoxRepository extends BaseRepository
|
||||
throw new \InvalidArgumentException("ip_begin/ip_end must be the same version");
|
||||
}
|
||||
$params['version'] = $ipEnd->getVersion();
|
||||
} elseif (
|
||||
!empty($params['asn'])
|
||||
&& empty($params['ip'])
|
||||
&& empty($params['ip_begin'])
|
||||
&& empty($params['ip_end'])
|
||||
) {
|
||||
do_log("only asn: " . $params['asn']);
|
||||
} else {
|
||||
throw new \InvalidArgumentException(nexus_trans('label.seed_box_record.ip_help'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user