public function handle($request, Closure $next) { $accountable = true; if ($request->header('X-TOR', false) || is_hidden_service()) { // Consider a user unaccountable if there's a custom X-TOR header, // or if the hostname is our hidden service name. $accountable = false; } elseif (!env('APP_DEBUG', false) && env('APP_URL_HS', false) && (new Geolocation())->getCountryCode() == "tor") { throw new TorClearnet(); } $this->auth->user()->setAccountable($accountable); return $next($request); }
/** * Generate an absolute or relative URL depending on our CDN domain. * * @since 0.6.0 * @param string $path * @param bool $absolute Defaults true for fully-qualified URL. * @return Illuminate\Contracts\Routing\UrlGenerator|string */ function media_url($path, $absolute = true) { $url = '/' . trim($path, '/'); if ($absolute) { $gen = app(Request::class); $request = app(UrlGenerator::class); $scheme = $gen->getScheme(); $media = env('APP_URL_MEDIA', false); if (is_hidden_service()) { return $gen->to($url); } if ($media) { return $scheme . $media . $url; } return asset($path); } return $url; }