Self-update mtproxyd
This commit is contained in:
parent
b4e6d022ed
commit
7b9190b5e5
@ -27,7 +27,9 @@ $p->setStub('<?php
|
|||||||
$backtrace = debug_backtrace();
|
$backtrace = debug_backtrace();
|
||||||
if (in_array(basename($backtrace[0]["file"]), ["madeline.php", "phar.php"])) {
|
if (in_array(basename($backtrace[0]["file"]), ["madeline.php", "phar.php"])) {
|
||||||
chdir(dirname($backtrace[1]["file"]));
|
chdir(dirname($backtrace[1]["file"]));
|
||||||
if (!isset($phar_debug)) file_put_contents($backtrace[0]["file"], file_get_contents("https://phar.madelineproto.xyz/phar.php?v=new"));
|
if (!isset($phar_debug) && ($contents = file_get_contents("https://phar.madelineproto.xyz/phar.php?v=new"))) {
|
||||||
|
file_put_contents($backtrace[0]["file"], $contents);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Phar::interceptFileFuncs();
|
Phar::interceptFileFuncs();
|
||||||
|
31
mtproxyd
Executable file
31
mtproxyd
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
$debug = false; // Set this to true to avoid automatic updates of this script
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "Powered by MadelineProto, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file_exists('madeline.php')) {
|
||||||
|
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$debug) {
|
||||||
|
copy('https://phar.madelineproto.xyz/mtproxyd', $argv[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once 'madeline.php';
|
||||||
|
|
||||||
|
$secret = md5($argv[1]);
|
||||||
|
echo "Secret is $secret\n";
|
||||||
|
|
||||||
|
$MadelineProto = new \danog\MadelineProto\API('proxy.madeline');
|
||||||
|
$MadelineProto->parse_dc_options($MadelineProto->help->getConfig()['dc_options']);
|
||||||
|
$handler = new \danog\MadelineProto\Server(['type' => AF_INET, 'protocol' => 0, 'address' => '0.0.0.0', 'port' => $argv[2], 'handler' => '\danog\MadelineProto\Server\Proxy', 'extra' => ['madeline' => $MadelineProto->API->datacenter->sockets, 'secret' => hex2bin($secret), 'timeout' => 10]]);
|
||||||
|
$handler->start();
|
@ -44,7 +44,7 @@ ssh-add madeline_rsa
|
|||||||
git clone git@github.com:danog/MadelineProtoPhar
|
git clone git@github.com:danog/MadelineProtoPhar
|
||||||
cd MadelineProtoPhar
|
cd MadelineProtoPhar
|
||||||
cp "../madeline$branch.phar" .
|
cp "../madeline$branch.phar" .
|
||||||
cp ../phar.php .
|
cp ../phar.php ../mtproxyd .
|
||||||
[ "$TRAVIS_BRANCH" == "master" ] && echo -n $TRAVIS_COMMIT > release
|
[ "$TRAVIS_BRANCH" == "master" ] && echo -n $TRAVIS_COMMIT > release
|
||||||
git add -A
|
git add -A
|
||||||
git commit -am "Release $TRAVIS_BRANCH $TRAVIS_COMMIT"
|
git commit -am "Release $TRAVIS_BRANCH $TRAVIS_COMMIT"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user