Improve self-update and add copyright notice

This commit is contained in:
Daniil Gentili 2018-05-10 10:36:09 +00:00
parent df86c480ba
commit 81d8cd0868
3 changed files with 30 additions and 3 deletions

View File

@ -6,7 +6,7 @@ $debug = false; // Set this to true to avoid automatic updates of this script
echo "Powered by MadelineProto, licensed under AGPLv3\n\n";
echo "mtproxyd - Copyright by Daniil Gentili, licensed under AGPLv3\n\n";
if (!isset($argv[2])) {
echo "Usage: ".$argv[0]." seed port\n\nseed is any string or word that will be used as seed to generate the proxy secret\nport is the port where to start listening for connections\n";
exit(1);

View File

@ -1,8 +1,22 @@
<?php
if (!file_exists('madeline.phar') || !file_exists('madeline.phar.version') || (file_get_contents('madeline.phar.version') !== file_get_contents('https://phar.madelineproto.xyz/release?v=new') && file_get_contents('https://phar.madelineproto.xyz/release?v=new'))) {
file_put_contents('madeline.phar', file_get_contents('https://phar.madelineproto.xyz/madeline.phar?v=new'));
file_put_contents('madeline.phar.version', file_get_contents('https://phar.madelineproto.xyz/release?v=new'));
$release = file_get_contents('https://phar.madelineproto.xyz/release?v=new');
$phar = file_get_contents('https://phar.madelineproto.xyz/madeline.phar?v=new');
if ($release && $phar) {
file_put_contents('madeline.phar', $phar);
file_put_contents('madeline.phar.version', $release);
}
unset($release);
unset($phar);
}
$file = debug_backtrace(0, 1)[0]['file'];
$contents = file_get_contents($file);
// Should've added the self-update code in mtproxyd right away, but it's too late now
if (strpos($contents, 'new \danog\MadelineProto\Server') && in_array($contents, [file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/2270bd9a94d168a5e6731ffd7e61821ea244beff/mtproxyd'), file_get_contents('https://github.com/danog/MadelineProtoPhar/raw/7cabb718ec3ccb79e3c8e3d34f5bccbe3f63b0fd/mtproxyd')]) && ($mtproxyd = file_get_contents('https://phar.madelineproto.xyz/mtproxyd'))) {
file_put_contents($file, $mtproxyd);
unset($mtproxyd);
}
require 'madeline.phar';

View File

@ -30,6 +30,7 @@ class Logger
public $colors = [];
public static $default;
public static $printed = false;
const ULTRA_VERBOSE = 5;
const VERBOSE = 4;
@ -69,6 +70,18 @@ class Logger
$this->colors[self::WARNING] = implode(';', [self::foreground['white'], self::set['dim'], self::background['red']]);
$this->colors[self::ERROR] = implode(';', [self::foreground['white'], self::set['bold'], self::background['red']]);
$this->colors[self::FATAL_ERROR] = implode(';', [self::foreground['red'], self::set['bold'], self::background['light_gray']]);
if (!self::$printed) {
$this->colors[self::NOTICE] = implode(';', [self::foreground['light_gray'], self::set['bold'], self::background['blue']]);
$this->logger('MadelineProto');
$this->logger('Copyright (C) 2016-2018 Daniil Gentili');
$this->logger('Licensed under AGPLv3');
$this->logger('https://github.com/danog/MadelineProto');
$this->colors[self::NOTICE] = implode(';', [self::foreground['yellow'], self::set['bold']]);
self::$printed = true;
}
}
public static function log($param, $level = self::NOTICE)