Skip to content

Commit

Permalink
~ Fix IPv6 issue #2
Browse files Browse the repository at this point in the history
  • Loading branch information
modernben committed Aug 2, 2023
1 parent f7da627 commit 07aacb6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/Providers/NativeAppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Native\Laravel\Menu\Menu;
use App\Events\ClickedCopyV4Link;
use App\Events\ClickedCopyV6Link;
use Illuminate\Support\Facades\DB;
use Native\Laravel\Facades\MenuBar;

class NativeAppServiceProvider
Expand Down
17 changes: 11 additions & 6 deletions app/Services/IP.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,30 @@

namespace App\Services;

use Exception;
use Illuminate\Support\Facades\Http;

class IP
{
public static function getV4(): string|bool
{
return Http::get('https://ipv4.seeip.org')->throw(function($error){
report($error);
try {
return Http::get('https://ipv4.seeip.org')->body();
} catch (Exception $e) {
report($e);

return false;
})->body();
}
}

public static function getV6(): string|bool
{
return Http::get('https://ipv6.seeip.org')->throw(function($error){
report($error);
try {
return Http::get('https://ipv6.seeip.org')->body();
} catch (Exception $e) {
report($e);

return false;
})->body();
}
}
}

0 comments on commit 07aacb6

Please sign in to comment.