Skip to content

Commit f50b461

Browse files
committed
Added a Online-Log-Viewer
1 parent e787c94 commit f50b461

21 files changed

+93208
-15
lines changed

.env.example

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ MAIL_ENCRYPTION=null
3131
GAMESERVER_ADDRESS=NULL
3232
GAMESERVER_PORT=NULL
3333
GAMESERVER_AUTH=NULL
34-
35-
LOGSERVER_ADDRESS=http://log.example.com
34+
GAMESERVER_LOGKEY=NULL
3635

3736
IPS_CLIENT_ID=null
3837
IPS_CLIENT_SECRET=null
3938
IPS_REDIRECT_URL=null
4039

4140
FORUM_URL=https://forums.aurorastation.org/
4241
FORUM_API_KEY=null
43-
FORUM_BYOND_ATTRIBUTE=15
42+
FORUM_BYOND_ATTRIBUTE=15
43+
44+
TELESCOPE_ENABLED=false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Server;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
use App\Models\ServerLog;
8+
use Illuminate\Support\Facades\Log;
9+
use Validator;
10+
use Storage;
11+
use DataTables;
12+
13+
class LogController extends Controller
14+
{
15+
16+
public function index(Request $request){
17+
if ($request->user()->cannot('server_logs_show'))
18+
abort('403', 'You do not have the required permission.');
19+
20+
$logs = ServerLog::all();
21+
return view('server.log.index',["logs"=>$logs]);
22+
}
23+
24+
public function getLogData()
25+
{
26+
$logs = ServerLog::select(['id', 'logdate', 'gameid']);
27+
28+
return Datatables::of($logs)
29+
->removeColumn('id')
30+
->addColumn('action', '<p><a href="{{route(\'server.log.show.get\',[\'log_id\'=>$id])}}" class="btn btn-success" role="button">Download</a></p>')
31+
->rawColumns([0])
32+
->make();
33+
}
34+
35+
public function getShow(Request $request, $log_id){
36+
if ($request->user()->cannot('server_logs_show'))
37+
abort('403', 'You do not have the required permission.');
38+
39+
$logfile = ServerLog::findOrFail($log_id);
40+
41+
Log::notice('server.log.download - Log Downloaded', ['user_id' => $request->user()->user_id, 'log_id' => $logfile->id]);
42+
43+
return Storage::download($logfile->filename);
44+
}
45+
46+
public function upload(Request $request){
47+
$validator = Validator::make($request->all(),[
48+
'logfile' => ['required','file'],
49+
'date' => ['required','date'],
50+
'gameid' => ['required','string','size:8'],
51+
'key' => [
52+
'required',
53+
function ($attribute, $value, $fail) {
54+
if ($value !== config('aurora.gameserver_logkey')) {
55+
$fail($attribute.' is invalid.');
56+
}
57+
},]
58+
]);
59+
60+
if($validator->fails()){
61+
return response([$validator->messages()],400);
62+
}
63+
64+
$path = $request->logfile->store('server_logs');
65+
66+
$logdata = new ServerLog();
67+
$logdata->filename = $path;
68+
$logdata->gameid = $request->input('gameid');
69+
$logdata->logdate = $request->input('date');
70+
$logdata->save();
71+
72+
Log::notice("server.logfile.upload - New Log Uploaded",["logdata"=>$logdata]);
73+
74+
return response(null,200);
75+
}
76+
}

app/Models/ServerLog.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class ServerLog extends Model
8+
{
9+
protected $table = 'server_logfiles';
10+
protected $connection = 'wi';
11+
protected $fillable = ['filename','logdate','gameid'];
12+
}

app/Providers/AppServiceProvider.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Blade;
66
use IPBProvider;
77
use Illuminate\Support\ServiceProvider;
8+
use Laravel\Telescope\TelescopeServiceProvider;
89

910
class AppServiceProvider extends ServiceProvider
1011
{
@@ -31,7 +32,9 @@ public function boot()
3132
*/
3233
public function register()
3334
{
34-
//
35+
if ($this->app->isLocal()) {
36+
$this->app->register(TelescopeServiceProvider::class);
37+
}
3538
}
3639

3740
private function bootIPBSocialite(){
+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace App\Providers;
4+
5+
use Laravel\Telescope\Telescope;
6+
use Illuminate\Support\Facades\Gate;
7+
use Laravel\Telescope\IncomingEntry;
8+
use Laravel\Telescope\TelescopeApplicationServiceProvider;
9+
10+
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
11+
{
12+
/**
13+
* Register any application services.
14+
*
15+
* @return void
16+
*/
17+
public function register()
18+
{
19+
// Telescope::night();
20+
21+
$this->hideSensitiveRequestDetails();
22+
23+
Telescope::filter(function (IncomingEntry $entry) {
24+
if ($this->app->isLocal()) {
25+
return true;
26+
}
27+
28+
return $entry->isReportableException() ||
29+
$entry->isFailedJob() ||
30+
$entry->isScheduledTask() ||
31+
$entry->hasMonitoredTag();
32+
});
33+
}
34+
35+
/**
36+
* Prevent sensitive request details from being logged by Telescope.
37+
*
38+
* @return void
39+
*/
40+
protected function hideSensitiveRequestDetails()
41+
{
42+
if ($this->app->isLocal()) {
43+
return;
44+
}
45+
46+
Telescope::hideRequestParameters(['_token']);
47+
48+
Telescope::hideRequestHeaders([
49+
'cookie',
50+
'x-csrf-token',
51+
'x-xsrf-token',
52+
]);
53+
}
54+
55+
/**
56+
* Register the Telescope gate.
57+
*
58+
* This gate determines who can access Telescope in non-local environments.
59+
*
60+
* @return void
61+
*/
62+
protected function gate()
63+
{
64+
Gate::define('viewTelescope', function ($user) {
65+
return in_array($user->email, [
66+
//
67+
]);
68+
});
69+
}
70+
}

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
"yajra/laravel-datatables-oracle": "~8.0"
2323
},
2424
"require-dev": {
25+
"barryvdh/laravel-ide-helper": "^2.1",
2526
"filp/whoops": "~2.0",
2627
"fzaninotto/faker": "~1.4",
28+
"laravel/telescope": "^1.0",
2729
"mockery/mockery": "~1.0",
28-
"phpunit/phpunit": "~7.0",
2930
"nunomaduro/collision": "^2.0",
30-
"barryvdh/laravel-ide-helper": "^2.1"
31+
"phpunit/phpunit": "~7.0"
3132
},
3233
"autoload": {
3334
"classmap": [

composer.lock

+114-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/aurora.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@
8484

8585
/*
8686
|--------------------------------------------------------------------------
87-
| Log Server Address
87+
| Game Server Log Key
8888
|--------------------------------------------------------------------------
8989
|
90-
| Auth Key for the Game Server
90+
| Auth Key used by the GameServer to upload Logs
9191
|
9292
*/
93-
"logserver_address" => env('LOGSERVER_ADDRESS', NULL),
93+
"gameserver_logkey" => env('GAMESERVER_LOGKEY', NULL),
9494

9595
/*
9696
|--------------------------------------------------------------------------

0 commit comments

Comments
 (0)