2828use Pterodactyl \Models ;
2929use Illuminate \Http \Request ;
3030use Pterodactyl \Http \Controllers \Controller ;
31- use Pterodactyl \Services \NotificationService ;
3231
3332class RemoteController extends Controller
3433{
@@ -42,7 +41,7 @@ public function __construct()
4241
4342 public function postDownload (Request $ request )
4443 {
45- $ download = Models \Download::where ('token ' , $ request ->input ('token ' , ' 00 ' ))->first ();
44+ $ download = Models \Download::where ('token ' , $ request ->input ('token ' ))->first ();
4645 if (! $ download ) {
4746 return response ()->json ([
4847 'error ' => 'An invalid request token was recieved with this request. ' ,
@@ -59,18 +58,17 @@ public function postDownload(Request $request)
5958
6059 public function postInstall (Request $ request )
6160 {
62- $ server = Models \Server::where ('uuid ' , $ request ->input ('server ' ))->first ();
61+ $ server = Models \Server::where ('uuid ' , $ request ->input ('server ' ))->with ( ' node ' )-> first ();
6362 if (! $ server ) {
6463 return response ()->json ([
6564 'error ' => 'No server by that ID was found on the system. ' ,
6665 ], 422 );
6766 }
6867
69- $ node = Models \Node::findOrFail ($ server ->node_id );
7068 $ hmac = $ request ->input ('signed ' );
7169 $ status = $ request ->input ('installed ' );
7270
73- if (base64_decode ($ hmac ) !== hash_hmac ('sha256 ' , $ server ->uuid , $ node ->daemonSecret , true )) {
71+ if (base64_decode ($ hmac ) !== hash_hmac ('sha256 ' , $ server ->uuid , $ server -> node ->daemonSecret , true )) {
7472 return response ()->json ([
7573 'error ' => 'Signed HMAC was invalid. ' ,
7674 ], 403 );
@@ -86,17 +84,15 @@ public function postInstall(Request $request)
8684
8785 public function event (Request $ request )
8886 {
89- $ server = Models \Server::where ('uuid ' , $ request ->input ('server ' ))->first ();
87+ $ server = Models \Server::where ('uuid ' , $ request ->input ('server ' ))->with ( ' node ' )-> first ();
9088 if (! $ server ) {
9189 return response ()->json ([
9290 'error ' => 'No server by that ID was found on the system. ' ,
9391 ], 422 );
9492 }
9593
96- $ node = Models \Node::findOrFail ($ server ->node_id );
97-
9894 $ hmac = $ request ->input ('signed ' );
99- if (base64_decode ($ hmac ) !== hash_hmac ('sha256 ' , $ server ->uuid , $ node ->daemonSecret , true )) {
95+ if (base64_decode ($ hmac ) !== hash_hmac ('sha256 ' , $ server ->uuid , $ server -> node ->daemonSecret , true )) {
10096 return response ()->json ([
10197 'error ' => 'Signed HMAC was invalid. ' ,
10298 ], 403 );
@@ -130,7 +126,6 @@ public function getConfiguration(Request $request, $tokenString)
130126 $ token ->delete ();
131127
132128 // Manually as getConfigurationAsJson() returns it in correct format already
133- return response ($ node ->getConfigurationAsJson (), 200 )
134- ->header ('Content-Type ' , 'application/json ' );
129+ return response ()->json ($ node ->getConfigurationAsJson (), 200 );
135130 }
136131}
0 commit comments