mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-25 04:27:28 +08:00
Merge branch 'cedar2025:master' into master
This commit is contained in:
@@ -26,6 +26,8 @@ class CacheKey
|
||||
'SERVER_*_LAST_PUSH_AT', // 节点最后推送时间
|
||||
'SERVER_*_LOAD_STATUS', // 节点负载状态
|
||||
'SERVER_*_LAST_LOAD_AT', // 节点最后负载提交时间
|
||||
'SERVER_*_METRICS', // 节点指标数据
|
||||
'USER_ONLINE_CONN_*_*', // 用户在线连接数 (特定节点类型_ID)
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -57,7 +59,7 @@ class CacheKey
|
||||
private static function matchesPattern(string $key): bool
|
||||
{
|
||||
foreach (self::ALLOWED_PATTERNS as $pattern) {
|
||||
$regex = '/^' . str_replace('*', '[A-Z_]+', $pattern) . '$/';
|
||||
$regex = '/^' . str_replace('*', '[A-Za-z0-9_]+', $pattern) . '$/';
|
||||
if (preg_match($regex, $key)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+20
-3
@@ -143,8 +143,13 @@ class Helper
|
||||
}
|
||||
|
||||
public static function randomPort($range): int {
|
||||
$portRange = explode('-', $range);
|
||||
return random_int((int)$portRange[0], (int)$portRange[1]);
|
||||
$portRange = explode('-', (string) $range, 2);
|
||||
$min = (int) ($portRange[0] ?? 0);
|
||||
$max = (int) ($portRange[1] ?? $portRange[0] ?? 0);
|
||||
if ($min > $max) {
|
||||
[$min, $max] = [$max, $min];
|
||||
}
|
||||
return random_int($min, $max);
|
||||
}
|
||||
|
||||
public static function base64EncodeUrlSafe($data)
|
||||
@@ -184,8 +189,20 @@ class Helper
|
||||
public static function getIpByDomainName($domain) {
|
||||
return gethostbynamel($domain) ?: [];
|
||||
}
|
||||
|
||||
public static function getTlsFingerprint($utls = null)
|
||||
{
|
||||
|
||||
if (is_array($utls) || is_object($utls)) {
|
||||
if (!data_get($utls, 'enabled')) {
|
||||
return null;
|
||||
}
|
||||
$fingerprint = data_get($utls, 'fingerprint', 'chrome');
|
||||
if ($fingerprint !== 'random') {
|
||||
return $fingerprint;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getRandFingerprint() {
|
||||
$fingerprints = ['chrome', 'firefox', 'safari', 'ios', 'edge', 'qq'];
|
||||
return Arr::random($fingerprints);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user