golden hour
/home/godaofbq/cellsonic-usa.com/wp-content/plugins/litespeed-cache/src
⬆️ Go Up
Upload
File/Folder
Size
Actions
activation.cls.php
17.62 KB
Del
OK
admin-display.cls.php
48.76 KB
Del
OK
admin-settings.cls.php
12.77 KB
Del
OK
admin.cls.php
6.13 KB
Del
OK
api.cls.php
10.44 KB
Del
OK
avatar.cls.php
9.25 KB
Del
OK
base.cls.php
37.66 KB
Del
OK
cdn
-
Del
OK
cdn.cls.php
17.76 KB
Del
OK
cloud-auth-callback.trait.php
10.43 KB
Del
OK
cloud-auth-ip.trait.php
4.33 KB
Del
OK
cloud-auth.trait.php
9.38 KB
Del
OK
cloud-misc.trait.php
10.32 KB
Del
OK
cloud-node.trait.php
5.95 KB
Del
OK
cloud-queue-svc.cls.php
9.33 KB
Del
OK
cloud-request.trait.php
19.68 KB
Del
OK
cloud.cls.php
7.32 KB
Del
OK
conf.cls.php
19.53 KB
Del
OK
control.cls.php
24.35 KB
Del
OK
core.cls.php
21.53 KB
Del
OK
crawler-map.cls.php
22.3 KB
Del
OK
crawler.cls.php
44 KB
Del
OK
css.cls.php
7.26 KB
Del
OK
data.cls.php
22.2 KB
Del
OK
data.upgrade.func.php
6.41 KB
Del
OK
data_structure
-
Del
OK
db-optm.cls.php
15.35 KB
Del
OK
debug2.cls.php
18.4 KB
Del
OK
doc.cls.php
5.45 KB
Del
OK
error.cls.php
7.35 KB
Del
OK
esi.cls.php
31.37 KB
Del
OK
file.cls.php
13.75 KB
Del
OK
guest.cls.php
2.75 KB
Del
OK
gui.cls.php
35.09 KB
Del
OK
health.cls.php
4.66 KB
Del
OK
htaccess.cls.php
29.81 KB
Del
OK
img-optm-manage.trait.php
31.25 KB
Del
OK
img-optm-pull.trait.php
22.1 KB
Del
OK
img-optm-send.trait.php
20.77 KB
Del
OK
img-optm.cls.php
5.25 KB
Del
OK
import.cls.php
4.29 KB
Del
OK
import.preset.cls.php
5.5 KB
Del
OK
lang.cls.php
17.02 KB
Del
OK
localization.cls.php
4.03 KB
Del
OK
media.cls.php
44.06 KB
Del
OK
metabox.cls.php
5.29 KB
Del
OK
object-cache-wp.cls.php
18.82 KB
Del
OK
object-cache.cls.php
21.82 KB
Del
OK
object.lib.php
13.85 KB
Del
OK
optimax.cls.php
8.94 KB
Del
OK
optimize.cls.php
38.74 KB
Del
OK
optimizer.cls.php
12.71 KB
Del
OK
placeholder.cls.php
17.64 KB
Del
OK
purge.cls.php
35.48 KB
Del
OK
report.cls.php
7.53 KB
Del
OK
rest.cls.php
7.95 KB
Del
OK
root.cls.php
14.29 KB
Del
OK
router.cls.php
20.86 KB
Del
OK
str.cls.php
3.08 KB
Del
OK
tag.cls.php
9.26 KB
Del
OK
task.cls.php
8.98 KB
Del
OK
tool.cls.php
4.58 KB
Del
OK
ucss.cls.php
7.34 KB
Del
OK
utility.cls.php
27.11 KB
Del
OK
vary.cls.php
21.33 KB
Del
OK
vpi.cls.php
4.25 KB
Del
OK
Edit: cloud-node.trait.php
<?php /** * Cloud node detection trait * * @package LiteSpeed * @since 7.8 */ namespace LiteSpeed; defined( 'WPINC' ) || exit(); /** * Trait Cloud_Node * * Handles cloud node detection and management. */ trait Cloud_Node { /** * Clear all existing cloud nodes for future reconnect * * @since 3.0 * @access public */ public function clear_cloud() { foreach ( self::$services as $service ) { if ( isset( $this->_summary[ 'server.' . $service ] ) ) { unset( $this->_summary[ 'server.' . $service ] ); } if ( isset( $this->_summary[ 'server_date.' . $service ] ) ) { unset( $this->_summary[ 'server_date.' . $service ] ); } } self::save_summary(); self::debug( 'Cleared all local service node caches' ); } /** * Ping clouds to find the fastest node * * @since 3.0 * @access public * * @param string $service Service. * @param bool $force Force redetect. * @return string|false */ public function detect_cloud( $service, $force = false ) { if ( in_array( $service, self::$center_svc_set, true ) ) { return $this->_cloud_server; } if ( in_array( $service, self::$wp_svc_set, true ) ) { return $this->_cloud_server_wp; } // Check if the stored server needs to be refreshed if ( ! $force ) { if ( ! empty( $this->_summary[ 'server.' . $service ] ) && ! empty( $this->_summary[ 'server_date.' . $service ] ) && (int) $this->_summary[ 'server_date.' . $service ] > time() - 86400 * self::TTL_NODE ) { $server = $this->_summary[ 'server.' . $service ]; if ( false === strpos( $this->_cloud_server, 'preview.' ) && false === strpos( $server, 'preview.' ) ) { return $server; } if ( false !== strpos( $this->_cloud_server, 'preview.' ) && false !== strpos( $server, 'preview.' ) ) { return $server; } } } if ( ! $service || ! in_array( $service, self::$services, true ) ) { $msg = __( 'Cloud Error', 'litespeed-cache' ) . ': ' . $service; Admin_Display::error( $msg ); return false; } // Send request to Quic Online Service $json = $this->_post( self::SVC_D_NODES, [ 'svc' => $this->_maybe_queue( $service ) ] ); // Check if get list correctly if ( empty( $json['list'] ) || ! is_array( $json['list'] ) ) { self::debug( 'request cloud list failed: ', $json ); if ( $json ) { $msg = __( 'Cloud Error', 'litespeed-cache' ) . ": [Service] $service [Info] " . wp_json_encode( $json ); Admin_Display::error( $msg ); } return false; } // Ping closest cloud $valid_clouds = false; if ( ! empty( $json['list_preferred'] ) ) { $valid_clouds = $this->_get_closest_nodes( $json['list_preferred'], $service ); } if ( ! $valid_clouds ) { $valid_clouds = $this->_get_closest_nodes( $json['list'], $service ); } if ( ! $valid_clouds ) { return false; } // Check server load if ( in_array( $service, self::$services_load_check, true ) ) { // TODO $valid_cloud_loads = []; foreach ( $valid_clouds as $v ) { $response = wp_safe_remote_get( $v, [ 'timeout' => 5 ] ); if ( is_wp_error( $response ) ) { $error_message = $response->get_error_message(); self::debug( 'failed to do load checker: ' . $error_message ); continue; } $curr_load = \json_decode( $response['body'], true ); if ( ! empty( $curr_load['_res'] ) && 'ok' === $curr_load['_res'] && isset( $curr_load['load'] ) ) { $valid_cloud_loads[ $v ] = $curr_load['load']; } } if ( ! $valid_cloud_loads ) { $msg = __( 'Cloud Error', 'litespeed-cache' ) . ": [Service] $service [Info] " . __( 'No available Cloud Node after checked server load.', 'litespeed-cache' ); Admin_Display::error( $msg ); return false; } self::debug( 'Closest nodes list after load check', $valid_cloud_loads ); $qualified_list = array_keys( $valid_cloud_loads, min( $valid_cloud_loads ), true ); } else { $qualified_list = $valid_clouds; } $closest = $qualified_list[ array_rand( $qualified_list ) ]; self::debug( 'Chose node: ' . $closest ); // store data into option locally $this->_summary[ 'server.' . $service ] = $closest; $this->_summary[ 'server_date.' . $service ] = time(); self::save_summary(); return $this->_summary[ 'server.' . $service ]; } /** * Ping to choose the closest nodes * * @since 7.0 * * @param array $nodes_list Node list. * @param string $service Service. * @return array|false */ private function _get_closest_nodes( $nodes_list, $service ) { $speed_list = []; foreach ( $nodes_list as $v ) { // Exclude possible failed 503 nodes if ( ! empty( $this->_summary['disabled_node'] ) && ! empty( $this->_summary['disabled_node'][ $v ] ) && time() - (int) $this->_summary['disabled_node'][ $v ] < 86400 ) { continue; } $speed_list[ $v ] = Utility::ping( $v ); } if ( ! $speed_list ) { self::debug( 'nodes are in 503 failed nodes' ); return false; } $min = min( $speed_list ); if ( 99999 === (int) $min ) { self::debug( 'failed to ping all clouds' ); return false; } // Random pick same time range ip (230ms 250ms) $range_len = strlen( $min ); $range_num = substr( $min, 0, 1 ); $valid_clouds = []; foreach ( $speed_list as $node => $speed ) { if ( strlen( $speed ) === $range_len && substr( $speed, 0, 1 ) === $range_num ) { $valid_clouds[] = $node; } elseif ( $speed < $min * 4 ) { // Append the lower speed ones $valid_clouds[] = $node; } } if ( ! $valid_clouds ) { $msg = __( 'Cloud Error', 'litespeed-cache' ) . ": [Service] $service [Info] " . __( 'No available Cloud Node.', 'litespeed-cache' ); Admin_Display::error( $msg ); return false; } self::debug( 'Closest nodes list', $valid_clouds ); return $valid_clouds; } /** * May need to convert to queue service * * @param string $service Service. * @return string */ private function _maybe_queue( $service ) { if ( in_array( $service, self::$_queue_svc_set, true ) ) { return self::SVC_QUEUE; } return $service; } }
Save