File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 1313use Illuminate \Queue \InteractsWithQueue ;
1414use Illuminate \Queue \SerializesModels ;
1515use Illuminate \Support \Arr ;
16+ use Illuminate \Support \Facades \URL ;
1617use JJG \Ping ;
1718use Symfony \Component \Process \Exception \ProcessFailedException ;
1819use Symfony \Component \Process \Process ;
@@ -88,13 +89,34 @@ public function handle(): void
8889
8990 protected function checkForInternetConnection (): bool
9091 {
92+ $ url = config ('speedtest.ping_url ' );
93+
9194 // Skip checking for internet connection if ping url isn't set (disabled)
92- if (blank (config ( ' speedtest.ping_url ' ) )) {
95+ if (blank ($ url )) {
9396 return true ;
9497 }
9598
99+ if (! URL ::isValidUrl ($ url )) {
100+ $ this ->result ->update ([
101+ 'server_id ' => $ this ->serverId ,
102+ 'data ' => [
103+ 'type ' => 'log ' ,
104+ 'level ' => 'error ' ,
105+ 'message ' => 'Invalid ping URL. ' ,
106+ ],
107+ 'status ' => ResultStatus::Failed,
108+ ]);
109+
110+ SpeedtestFailed::dispatch ($ this ->result );
111+
112+ return false ;
113+ }
114+
115+ // Remove http:// or https:// from the URL if present
116+ $ url = preg_replace ('/^https?:\/\// ' , '' , $ url );
117+
96118 $ ping = new Ping (
97- host: config ( ' speedtest.ping_url ' ) ,
119+ host: $ url ,
98120 timeout: 3 ,
99121 );
100122
You can’t perform that action at this time.
0 commit comments