Added extra crash dump settings, added way to disable parts of it or change the host

This commit is contained in:
Shoghi Cervantes 2014-07-28 14:42:51 +02:00
parent b10e63b951
commit 10c67a57a7
3 changed files with 36 additions and 16 deletions

View File

@ -103,20 +103,30 @@ class CrashDump{
private function extraData(){ private function extraData(){
global $arguments; global $arguments;
if($this->server->getProperty("auto-report.send-settings", true) !== false){
$this->data["parameters"] = (array) $arguments; $this->data["parameters"] = (array) $arguments;
$this->data["server.properties"] = @file_get_contents($this->server->getDataPath() . "server.properties"); $this->data["server.properties"] = @file_get_contents($this->server->getDataPath() . "server.properties");
$this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $this->data["server.properties"]); $this->data["server.properties"] = preg_replace("#^rcon\\.password=(.*)$#m", "rcon.password=******", $this->data["server.properties"]);
$this->data["pocketmine.yml"] = @file_get_contents($this->server->getDataPath() . "pocketmine.yml"); $this->data["pocketmine.yml"] = @file_get_contents($this->server->getDataPath() . "pocketmine.yml");
}else{
$this->data["pocketmine.yml"] = "";
$this->data["server.properties"] = "";
$this->data["parameters"] = [];
}
$extensions = []; $extensions = [];
foreach(get_loaded_extensions() as $ext){ foreach(get_loaded_extensions() as $ext){
$extensions[$ext] = phpversion($ext); $extensions[$ext] = phpversion($ext);
} }
$this->data["extensions"] = $extensions; $this->data["extensions"] = $extensions;
if($this->server->getProperty("auto-report.send-phpinfo", true) !== false){
ob_start(); ob_start();
phpinfo(); phpinfo();
$this->data["phpinfo"] = ob_get_contents(); $this->data["phpinfo"] = ob_get_contents();
ob_end_clean(); ob_end_clean();
} }
}
private function baseCrash(){ private function baseCrash(){
global $lastError; global $lastError;
@ -181,11 +191,15 @@ class CrashDump{
$this->addLine(); $this->addLine();
$this->addLine("Code:"); $this->addLine("Code:");
$this->data["code"] = []; $this->data["code"] = [];
if($this->server->getProperty("auto-report.send-code", true) !== false){
$file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES); $file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10; ++$l){ for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10; ++$l){
$this->addLine("[" . ($l + 1) . "] " . @$file[$l]); $this->addLine("[" . ($l + 1) . "] " . @$file[$l]);
$this->data["code"][$l + 1] = @$file[$l]; $this->data["code"][$l + 1] = @$file[$l];
} }
}
$this->addLine(); $this->addLine();
$this->addLine("Backtrace:"); $this->addLine("Backtrace:");
foreach(($this->data["trace"] = $error["trace"]) as $line){ foreach(($this->data["trace"] = $error["trace"]) as $line){

View File

@ -1792,8 +1792,8 @@ class Server{
$this->logger->emergency("An unrecoverable error has occurred and the server has crashed. Creating a crash dump"); $this->logger->emergency("An unrecoverable error has occurred and the server has crashed. Creating a crash dump");
$dump = new CrashDump($this); $dump = new CrashDump($this);
if($this->getProperty("settings.send-crash", true) !== false){ if($this->getProperty("auto-report.enabled", true) !== false){
$reply = Utils::postURL("http://crash.pocketmine.net/submit/api", [ $reply = Utils::postURL("http://".$this->getProperty("auto-report.host", "crash.pocketmine.net")."/submit/api", [
"report" => "yes", "report" => "yes",
"name" => "PocketMine-MP ".$this->getPocketMineVersion(), "name" => "PocketMine-MP ".$this->getPocketMineVersion(),
"email" => "crash@pocketmine.net", "email" => "crash@pocketmine.net",

View File

@ -10,7 +10,6 @@ settings:
advanced-cache: false advanced-cache: false
upnp-forwarding: false upnp-forwarding: false
send-usage: true send-usage: true
send-crash: true
async-workers: 4 async-workers: 4
debug: debug:
@ -44,6 +43,13 @@ spawn-limits:
water-animals: 5 water-animals: 5
ambient: 15 ambient: 15
auto-report: #Send crash reports for processing
enabled: true
send-code: true
send-settings: true
send-phpinfo: true
host: crash.pocketmine.net
auto-updater: auto-updater:
enabled: true enabled: true
on-update: on-update: