Adventure Crypto Discovery Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

SMF - Just Installed!

Author Topic: Свой Приватный мессенджер за 10 минут  (Read 130 times)

bomj

  • Newbie
  • *
  • Karma: +1/-0
  • Offline Offline
  • Posts: 25

Собственный Приватный мессенджер.
Пример бесплатного мессенджера для определенного круга участников.

Это пример общедоступного мессенджера:
http://wall.0xbt.net/ball2.html

Работает в тестовой сети Rinkeby

Для создания своего мессенджера.
1. Перейдите в MyEtherWallet
- Раздел 'Contracts'
- Нажмите 'Deploy Contract'
- Втавьте Byte Code приведенный ниже:

Code: [Select]
0x60806040526040805190810160405280601f81526020017f57656c636f6d6520746f207468652050726f6a65637420307862742e6e6574008152506000908051906020019061004f929190610062565b5034801561005c57600080fd5b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b6102d7806101166000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638c6838ba14610051578063c38caab5146100e1575b600080fd5b34801561005d57600080fd5b5061006661014a565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100a657808201518184015260208101905061008b565b50505050905090810190601f1680156100d35780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156100ed57600080fd5b50610148600480360381019080803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506101ec565b005b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101e25780601f106101b7576101008083540402835291602001916101e2565b820191906000526020600020905b8154815290600101906020018083116101c557829003601f168201915b5050505050905090565b8060009080519060200190610202929190610206565b5050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061024757805160ff1916838001178555610275565b82800160010185558215610275579182015b82811115610274578251825591602001919060010190610259565b5b5090506102829190610286565b5090565b6102a891905b808211156102a457600081600090555060010161028c565b5090565b905600a165627a7a7230582088266c3e343870866e9dc688e0b18de7babf9b7c16a7e14318ed514ac232ac780029
Gas Limit по своему усмотрению, задавал 3000000
- Подключитесь к MetaMask
- Нажать 'Sign Transaction'
- Нажмите 'Deploy Contract'
- При вызове MetaMask можете смело снижать Газ до 10 gwei

Вы создали контракт своего мессенджера.

2 В данном коде измените контракт 0xae4243e2c0f910223323dd2f2fdd16820b69f1d6
на свой в строках 31 и 70

Code: [Select]
<html>
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="https://wall.0xbt.net/assets/images/m1-120x120.png" type="image/x-icon">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<meta name="description" content="">
<title>BigBalls :)</title>
<script type="text/javascript" src="https://rinkeby.etherscan.io/assets/plugins/jquery/jquery.min.js"></script>
<script type="text/javascript" src="https://rinkeby.etherscan.io/jss/web3.min.js?v=0.20.6"></script>
<!-- <script type="text/javascript" src="https://wall.0xbt.net/contr2.js"></script>-->
<style>
    a {
    text-decoration: none; /* Отменяем подчеркивание у ссылки */
    }
button.knopka {
color: #fff;
background: #828282;
padding: 5px;
border-radius: 5px;
border: 2px solid #teal;
}
button.knopka:hover {
background: #000;
}
</style>
</head>
<body style="background-color:#2E2E2E">
<table border = "15" width ="100%" cellpadding = "5" cellspacing ="15" bordercolor="#2E2E2E" bgcolor=""><tr><td>
<center>
<h4>Rinkeby TestNet</h4><br>
<button class="knopka" id='btn_5'><a href="https://rinkeby.etherscan.io/writecontract/index.html?a=0xae4243e2c0f910223323dd2f2fdd16820b69f1d6&n=rinkeby" title="section - '4. setPost'" target="_blank"><b><span style="color:white;">Send <i class="fa fa-btc"></i> News</span></b></a></button>
<button type='button' id='btn_5' class="knopka" onclick="ethcall2('getPost', 'input_5','myanswer_5','string', '|string', 'btn_5');">Get <i class="fa fa-btc"></i> News</button>
<div align="left"><b><span id='myanswer_5' style="color:teal"></span></b></div>

</center>
</body></td></tr></table>

<script>
    $('#overlay', window.parent.document).hide();
    jQuery(window).load(function () {
        $('#overlay').fadeOut("slow");
       
        var obj = window.parent.document.getElementById('readcontractiframe');
        parent.resizeIframe(obj, 0);
    });
    function getcontractabi(contractaddress) {
       
            $.post("https://Rinkeby.etherscan.io/api",
       
                {
                    module: "contract",
                    action: "getabit",
                    address: contractaddress
                },
                function (data, status) {
                    console.log("contractAbi = " + data)
                });
    }

    var Web3 = require('web3');
   
    var web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io"));
   
    var version = web3.version.api;
    console.log(version);
    var MyContract;
    var myContractInstance;
    try {
        MyContract = web3.eth.contract([{"constant":true,"inputs":[],"name":"getPost","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newPost","type":"string"}],"name":"setPost","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]);
        myContractInstance = MyContract.at("0xae4243e2c0f910223323dd2f2fdd16820b69f1d6");
    }
    catch (err) {
        console.log(err.message);
    }   
    function ethcall2(strMethodName, strInputElementName, strOutputElementName, strOutputtype, strOutputFieldNames, strBtnName) {       
   
        var functionNametoCall = "myContractInstance." + strMethodName;
        var result;
        try {
            var strparas;
            var elms = document.querySelectorAll("[id=" + strInputElementName + "]");
            //console.log("elms.length = " + elms.length);           
            for (var i = 0; i < elms.length; i++) {
                if (i == 0) {
                    strparas = "'" + add0xforAddress(Escape(elms[i].value)) + "'"
                } else {
                    strparas = strparas + ",'" + Escape(elms[i].value) + "'"
                }
                if (elms[i].value == '') {
                    document.getElementById(strInputElementName).focus();                   
                    alert('Input value cannot be empty');
                    return false;
                }
            }
            showLoading(true, strBtnName);

            new Function(functionNametoCall + "(" + strparas + ", function(err, res){ if (err) {result = err;} else { result = res; } showMessage('" + strMethodName +"',result,'" + strOutputElementName+"','" + strOutputFieldNames +"','"+ strBtnName +"');   });")();

           // result = eval(functionNametoCall + "(" + strparas + ");");
           
           // $('#overlay').show();
        }
        catch (err) {
            //$('#overlay').show();
            result = "" + err + "";
            showLoading(false, strBtnName);
        }
        //setTimeout(function () {
        //    $('#overlay').show();
        //}, 2500);
       
        //document.getElementById(strOutputElementName).innerHTML = "<br><br> [&nbsp;<b>" + strMethodName + "</b> method Response ]<br>" + formatmultipleoutputs(result, strOutputFieldNames) + "<br>";
             
    }

    function showMessage(strMethodName, result, strOutputElementName, strOutputFieldNames, strBtnName) {
       
        document.getElementById(strOutputElementName).innerHTML = "<br><br> [&nbsp;<b>" + strMethodName + "</b> method Response ]<br>" + formatmultipleoutputs(result, strOutputFieldNames) + "<br>";
        showLoading(false, strBtnName); 
    }

    function showLoading(isShow, strBtnName) {
       
        if (isShow) {
            $(" <img id='waiting_" + strBtnName + "' class='waitingImg' src='https://etherscan.io/images/ajax-loader2.gif' style='margin-left:5px;' alt='Loading' />").insertAfter($('#' + strBtnName));
            $('#' + strBtnName).prop('disabled', true);
        } else {
            $('#' + strBtnName).prop('disabled', false);
            $('#waiting_' + strBtnName).remove();
        }
    }

    function Escape(val) {
        return val.replace(/'/g, "\\u0027");
    }

    function formatmultipleoutputs(strVal, strOutputFieldNames) {
        var strAnswer = '';
        //console.log("strVal = " + strVal);
        //console.log("strOutputFieldNames = " + strOutputFieldNames);
        //console.log("strVal.length = " + strVal.length);
        if (strOutputFieldNames.includes(';') == true) {
            var res_2 = strOutputFieldNames.split(';');
            for (i = 0; i < strVal.length; i++) {
                var tmparray = res_2[i].toString().split('|');
                strAnswer = strAnswer + "&nbsp;<font color='green'><i class='fa  fa-angle-double-right'></i></font> ";
                if (res_2[i] != null && res_2[i].toString() != '') {
                    strAnswer = strAnswer + " <b>" + tmparray[0] + "</b> &nbsp; <font color='silver'><i>" + tmparray[1] + "</i></font> <b>:</b> &nbsp;"
                }
                strAnswer = strAnswer + formatresult(strVal[i].toString(), tmparray[1]) + "<br>";
            }
        } else {
            strAnswer = strAnswer + "&nbsp;<font color='green'><i class='fa  fa-angle-double-right'></i></font> ";
            if (strOutputFieldNames != '') {
                var tmparray = strOutputFieldNames.toString().split('|');
                strAnswer = strAnswer + " <b>" + tmparray[0] + "</b> &nbsp; <font color='silver'><i>" + tmparray[1] + "</i></font> <b>:</b> &nbsp;";
                strVal = formatresult(strVal.toString(), tmparray[1])
            }
            strAnswer = strAnswer + replaceAll(strVal, ",", "<br>&nbsp;<font color='green'><i class='fa  fa-angle-double-right'></i></font> ") + "<br>";
        }
        return strAnswer;
    }

    function htmlEncode(value) {
        return $('<div/>').text(value).html();
    }
    function replaceAll(str, find, replace) {
        return str.replace(new RegExp(find, 'g'), replace);
    }
    function formatresult(strResult, resulttype) {
        if (resulttype.startsWith('uint')) {
            return toFixed(strResult);
        } else if (resulttype == 'string') {
            return htmlEncode(strResult);
            //return hex_to_ascii(strResult);
        } else if (resulttype == 'address') {
            if (strResult != '0x0000000000000000000000000000000000000000') {
                return "<a href='/address/" + strResult + "' target='_blank'>" + strResult + "</a>";
            } else {
                return htmlEncode(strResult);
            }
            //} else if (resulttype == 'bool') {
            //    return Boolean(remove0x(strResult));
        } else {
            return htmlEncode(strResult);
        }
    }
    function hex_to_ascii(str1) {
        var hex = str1.toString();
        var str = '';
        for (var n = 0; n < hex.length; n += 2) {
            str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
        }
        return str;
    }
    function extractaddress(str1) {
        if (str1.length > 40) {
            str1.substr(str1.length - 40)
        }
        return str1;
    }
    function remove0x(str1) {
        if (str1.startsWith("0x") == true) {
            str1 = str1.substr(str1.length - str1.length + 2);
        }
        return str1;
    }
    function add0xforAddress(straddress) {
        straddress = straddress.trim();
        if (straddress.startsWith("0x") == false && straddress.length == 40) {
            straddress = "0x" + straddress;
        }
        return straddress;
    }
    function toFixed(x) {
        if (x.indexOf("e+") !== -1) {
            var value = web3.toBigNumber(x);
            x = value.toString(10);
        }
        return x;
    }     
    setTimeout(function () {
       
    }, 0);

</script>

</html>


Скопируйте код и преобразуйте в Base64 https://base64.0xbt.net/
Перед кодом вставьте "data:text/html;base64,"
Вставьте полученный код в строку браузера Google Chrome

Все, у вас есть собственный мессенджер.
Вам только осталось поделиться полученным кодом со своими родственниками
или с друзьями. Смотря для каких целей вы его создали.
Если вы хотите шифровать свои сообщения, можете воспользоваться
сервисом https://webcrypt.0xbt.net/
Пользуясь данным мессенджером в сети Rinkeby вы можете использовать
его бесплатно. Для этого вам нужен тестовый Эфир.

Удачи!
« Last Edit: November 17, 2018, 12:09:35 AM by bomj »
Logged

bomj

  • Newbie
  • *
  • Karma: +1/-0
  • Offline Offline
  • Posts: 25
Re: Свой Приватный мессенджер за 10 минут
« Reply #1 on: November 16, 2018, 11:00:31 PM »

Здесь результат:

Code: [Select]
data:text/html;base64,PGh0bWw+CjxoZWFkPgo8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+CjxsaW5rIHJlbD0ic2hvcnRjdXQgaWNvbiIgaHJlZj0iaHR0cHM6Ly93YWxsLjB4YnQubmV0L2Fzc2V0cy9pbWFnZXMvbTEtMTIweDEyMC5wbmciIHR5cGU9ImltYWdlL3gtaWNvbiI+CjxsaW5rIHJlbD0ic3R5bGVzaGVldCIgaHJlZj0iaHR0cHM6Ly9tYXhjZG4uYm9vdHN0cmFwY2RuLmNvbS9mb250LWF3ZXNvbWUvNC40LjAvY3NzL2ZvbnQtYXdlc29tZS5taW4uY3NzIj4KPG1ldGEgbmFtZT0iZGVzY3JpcHRpb24iIGNvbnRlbnQ9IiI+Cjx0aXRsZT5CaWdCYWxscyA6KTwvdGl0bGU+CjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0IiBzcmM9Imh0dHBzOi8vcmlua2VieS5ldGhlcnNjYW4uaW8vYXNzZXRzL3BsdWdpbnMvanF1ZXJ5L2pxdWVyeS5taW4uanMiPjwvc2NyaXB0Pgo8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCIgc3JjPSJodHRwczovL3JpbmtlYnkuZXRoZXJzY2FuLmlvL2pzcy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2NhcGUoZWxtc1tpXS52YWx1ZSkgKyAiJyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChlbG1zW2ldLnZhbHVlID09ICcnKSB7CiAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoc3RySW5wdXRFbGVtZW50TmFtZSkuZm9jdXMoKTsgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgYWxlcnQoJ0lucHV0IHZhbHVlIGNhbm5vdCBiZSBlbXB0eScpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBzaG93TG9hZGluZyh0cnVlLCBzdHJCdG5OYW1lKTsKCiAgICAgICAgICAgIG5ldyBGdW5jdGlvbihmdW5jdGlvbk5hbWV0b0NhbGwgKyAiKCIgKyBzdHJwYXJhcyArICIsIGZ1bmN0aW9uKGVyciwgcmVzKXsgaWYgKGVycikge3Jlc3VsdCA9IGVycjt9IGVsc2UgeyByZXN1bHQgPSByZXM7IH0gc2hvd01lc3NhZ2UoJyIgKyBzdHJNZXRob2ROYW1lICsiJyxyZXN1bHQsJyIgKyBzdHJPdXRwdXRFbGVtZW50TmFtZSsiJywnIiArIHN0ck91dHB1dEZpZWxkTmFtZXMgKyInLCciKyBzdHJCdG5OYW1lICsiJyk7ICAgfSk7IikoKTsKCiAgICAgICAgICAgLy8gcmVzdWx0ID0gZXZhbChmdW5jdGlvbk5hbWV0b0NhbGwgKyAiKCIgKyBzdHJwYXJhcyArICIpOyIpOwogICAgICAgICAgIAogICAgICAgICAgIC8vICQoJyNvdmVybGF5Jykuc2hvdygpOwogICAgICAgIH0KICAgICAgICBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIC8vJCgnI292ZXJsYXknKS5zaG93KCk7CiAgICAgICAgICAgIHJlc3VsdCA9ICIiICsgZXJyICsgIiI7CiAgICAgICAgICAgIHNob3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zdWx0KTsKICAgICAgICAgICAgLy9yZXR1cm4gaGV4X3RvX2FzY2lpKHN0clJlc3VsdCk7CiAgICAgICAgfSBlbHNlIGlmIChyZXN1bHR0eXBlID09ICdhZGRyZXNzJykgewogICAgICAgICAgICBpZiAoc3RyUmVzdWx0ICE9ICcweDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAnKSB7CiAgICAgICAgICAgICAgICByZXR1cm4gIjxhIGhyZWY9Jy9hZGRyZXNzLyIgKyBzdHJSZXN1bHQgKyAiJyB0YXJnZXQ9J19ibGFuayc+IiArIHN0clJlc3VsdCArICI8L2E+IjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHVybiBodG1sRW5jb2RlKHN0clJlc3VsdCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy99IGVsc2UgaWYgKHJlc3VsdHR5cGUgPT0gJ2Jvb2wnKSB7CiAgICAgICAgICAgIC8vICAgIHJldHVybiBCb29sZWFuKHJlbW92ZTB4KHN0clJlc3VsdCkpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiBodG1sRW5jb2RlKHN0clJlc3VsdCk7CiAgICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gaGV4X3RvX2FzY2lpKHN0cjEpIHsKICAgICAgICB2YXIgaGV4ID0gc3RyMS50b1N0cmluZygpOwogICAgICAgIHZhciBzdHIgPSAnJzsKICAgICAgICBmb3IgKHZhciBuID0gMDsgbiA8IGhleC5sZW5ndGg7IG4gKz0gMikgewogICAgICAgICAgICBzdHIgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShwYXJzZUludChoZXguc3Vic3RyKG4sIDIpLCAxNikpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc3RyOwogICAgfQogICAgZnVuY3Rpb24gZXh0cmFjdGFkZHJlc3Moc3RyMSkgewogICAgICAgIGlmIChzdHIxLmxlbmd0aCA+IDQwKSB7CiAgICAgICAgICAgIHN0cjEuc3Vic3RyKHN0cjEubGVuZ3RoIC0gNDApCiAgICAgICAgfQogICAgICAgIHJldHVybiBzdHIxOwogICAgfQogICAgZnVuY3Rpb24gcmVtb3ZlMHgoc3RyMSkgewogICAgICAgIGlmIChzdHIxLnN0YXJ0c1dpdGgoIjB4IikgPT0gdHJ1ZSkgewogICAgICAgICAgICBzdHIxID0gc3RyMS5zdWJzdHIoc3RyMS5sZW5ndGggLSBzdHIxLmxlbmd0aCArIDIpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc3RyMTsKICAgIH0KICAgIGZ1bmN0aW9uIGFkZDB4Zm9yQWRkcmVzcyhzdHJhZGRyZXNzKSB7CiAgICAgICAgc3RyYWRkcmVzcyA9IHN0cmFkZHJlc3MudHJpbSgpOwogICAgICAgIGlmIChzdHJhZGRyZXNzLnN0YXJ0c1dpdGgoIjB4IikgPT0gZmFsc2UgJiYgc3RyYWRkcmVzcy5sZW5ndGggPT0gNDApIHsKICAgICAgICAgICAgc3RyYWRkcmVzcyA9ICIweCIgKyBzdHJhZGRyZXNzOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc3RyYWRkcmVzczsKICAgIH0KICAgIGZ1bmN0aW9uIHRvRml4ZWQoeCkgewogICAgICAgIGlmICh4LmluZGV4T2YoImUrIikgIT09IC0xKSB7CiAgICAgICAgICAgIHZhciB2YWx1ZSA9IHdlYjMudG9CaWdOdW1iZXIoeCk7CiAgICAgICAgICAgIHggPSB2YWx1ZS50b1N0cmluZygxMCk7CiAgICAgICAgfQogICAgICAgIHJldHVybiB4OwogICAgfSAgICAgCiAgICBzZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsKICAgICAgIAogICAgfSwgMCk7Cgo8L3NjcmlwdD4KCjwvaHRtbD4=
Можете тестировать!
 :o
« Last Edit: November 16, 2018, 11:33:35 PM by bomj »
Logged

bomj

  • Newbie
  • *
  • Karma: +1/-0
  • Offline Offline
  • Posts: 25
Re: Свой Приватный мессенджер за 10 минут
« Reply #2 on: November 21, 2018, 09:53:37 AM »

Video Manual
Contract: 0xc0559f4b79A5eaEb210d216b4C81c3Ea800ce6B5

Messenger Code:

Code: [Select]
data:text/html;base64,PGh0bWw+CjxoZWFkPgo8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+CjxsaW5rIHJlbD0ic2hvcnRjdXQgaWNvbiIgaHJlZj0iaHR0cHM6Ly93YWxsLjB4YnQubmV0L2Fzc2V0cy9pbWFnZXMvbTEtMTIweDEyMC5wbmciIHR5cGU9ImltYWdlL3gtaWNvbiI+CjxsaW5rIHJlbD0ic3R5bGVzaGVldCIgaHJlZj0iaHR0cHM6Ly9tYXhjZG4uYm9vdHN0cmFwY2RuLmNvbS9mb250LWF3ZXNvbWUvNC40LjAvY3NzL2ZvbnQtYXdlc29tZS5taW4uY3NzIj4KPG1ldGEgbmFtZT0iZGVzY3JpcHRpb24iIGNvbnRlbnQ9IiI+Cjx0aXRsZT5CaWdCYWxscyA6KTwvdGl0bGU+CjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0IiBzcmM9Imh0dHBzOi8vcmlua2VieS5ldGhlcnNjYW4uaW8vYXNzZXRzL3BsdWdpbnMvanF1ZXJ5L2pxdWVyeS5taW4uanMiPjwvc2NyaXB0Pgo8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCIgc3JjPSJodHRwczovL3JpbmtlYnkuZXRoZXJzY2FuLmlvL2pzcy93ZWIzLm1pbi5qcz92PTAuMjAuNiI+PC9zY3JpcHQ+CjwhLS0gPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiIHNyYz0iaHR0cHM6Ly93YWxsLjB4YnQubmV0L2NvbnRyMi5qcyI+PC9zY3JpcHQ+LS0+CjxzdHlsZT4KICAgIGEgeyAKICAgIHRleHQtZGVjb3JhdGlvbjogbm9uZTsgLyog0J7RgtC80LXQvdGP0LXQvCDQv9C+0LTRh9C10YDQutC40LLQsNC90LjQtSDRgyD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ycsICd8c3RyaW5nJywgJ2J0bl81Jyk7Ij5HZXQgPGkgY2xhc3M9ImZhIGZhLWJ0YyI+PC9pPiBOZXdzPC9idXR0b24+CjxkaXYgYWxpZ249ImxlZnQiPjxiPjxzcGFuIGlkPSdteWFuc3dlcl81JyBzdHlsZT0iY29sb3I6dGVhbCI+PC9zcGFuPjwvYj48L2Rpdj4KCjwvY2VudGVyPgo8L2JvZHk+PC90ZD48L3RyPjwvdGFibGU+Cgo8c2NyaXB0PgogICAgJCgnI292ZXJsYXknLCB3aW5kb3cucGFyZW50LmRvY3VtZW50KS5oaWRlKCk7CiAgICBqUXVlcnkod2luZG93KS5sb2FkKGZ1bmN0aW9uICgpIHsKICAgICAgICAkKCcjb3ZlcmxheScpLmZhZGVPdXQoInNsb3ciKTsKICAgICAgICAKICAgICAgICB2YXIgb2JqID0gd2luZG93LnBhcmVudC5kb2N1bWVudC5nZXRFbGVtZW50QnlJZCgncmVhZGNvbnRyYWN0aWZyYW1lJyk7CiAgICAgICAgcGFyZW50LnJlc2l6ZUlmcmFtZShvYmosIDApOyAKICAgIH0pOwogICAgZnVuY3Rpb24gZ2V0Y29udHJhY3RhYmkoY29udHJhY3RhZGRyZXNzKSB7CiAgICAgICAgCiAgICAgICAgICAgICQucG9zdCgiaHR0cHM6Ly9SaW5rZWJ5LmV0aGVyc2Nhbi5pby9hcGkiLAogICAgICAgIAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIG1vZHVsZTogImNvbnRyYWN0IiwKICAgICAgICAgICAgICAgICAgICBhY3Rpb246ICJnZXRhYml0IiwKICAgICAgICAgICAgICAgICAgICBhZGRyZXNzOiBjb250cmFjdGFkZHJlc3MKICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICBmdW5jdGlvbiAoZGF0YSwgc3RhdHVzKSB7CiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coImNvbnRyYWN0QWJpID0gIiArIGRhdGEpCiAgICAgICAgICAgICAgICB9K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ZW50TmFtZSwgc3RyT3V0cHV0RWxlbWVudE5hbWUsIHN0ck91dHB1dHR5cGUsIHN0ck91dHB1dEZpZWxkTmFtZXMsIHN0ckJ0bk5hbWUpIHsgICAgICAgIAogICAKICAgICAgICB2YXIgZnVuY3Rpb25OYW1ldG9DYWxsID0gIm15Q29udHJhY3RJbnN0YW5jZS4iICsgc3RyTWV0aG9kTmFtZTsKICAgICAgICB2YXIgcmVzdWx0OwogICAgICAgIHRyeSB7CiAgICAgICAgICAgIHZhciBzdHJwYXJhczsKICAgICAgICAgICAgdmFyIGVsbXMgPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKCJbaWQ9IiArIHN0cklucHV0RWxlbWVudE5hbWUgKyAiXSIpOwogICAgICAgICAgICAvL2NvbnNvbGUubG9nKCJlbG1zLmxlbmd0aCA9ICIgKyBlbG1zLmxlbmd0aCk7ICAgICAgICAgICAgCiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgZWxtcy5sZW5ndGg7IGkrKykgewogICAgICAgICAgICAgICAgaWYgKGkgPT0gMCkgewogICAgICAgICAgICAgICAgICAgIHN0cnBhcmFzID0gIiciICsgYWRkMHhmb3JBZGRyZXNzKEVzY2FwZShlbG1zW2ldLnZhbHVlKSkgKyAiJyIKICAgICAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICAgICAgc3RycGFyYXMgPSBzdHJwYXJhcyArICIsJyIgKyBFc2NhcGUoZWxtc1tpXS52YWx1ZSkgKyAiJyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmIChlbG1zW2ldLnZhbHVlID09ICcnKSB7CiAgICAgICAgICAgICAgICAgICAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoc3RySW5wdXRFbGVtZW50TmFtZSkuZm9jdXMoKTsgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgYWxlcnQoJ0lucHV0IHZhbHVlIGNhbm5vdCBiZSBlbXB0eScpOwogICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgICAgICBzaG93TG9hZGluZyh0cnVlLCBzdHJCdG5OYW1lKTsKCiAgICAgICAgICAgIG5ldyBGdW5jdGlvbihmdW5jdGlvbk5hbWV0b0NhbGwgKyAiKCIgKyBzdHJwYXJhcyArICIsIGZ1bmN0aW9uKGVyciwgcmVzKXsgaWYgKGVycikge3Jlc3VsdCA9IGVycjt9IGVsc2UgeyByZXN1bHQgPSByZXM7IH0gc2hvd01lc3NhZ2UoJyIgKyBzdHJNZXRob2ROYW1lICsiJyxyZXN1bHQsJyIgKyBzdHJPdXRwdXRFbGVtZW50TmFtZSsiJywnIiArIHN0ck91dHB1dEZpZWxkTmFtZXMgKyInLCciKyBzdHJCdG5OYW1lICsiJyk7ICAgfSk7IikoKTsKCiAgICAgICAgICAgLy8gcmVzdWx0ID0gZXZhbChmdW5jdGlvbk5hbWV0b0NhbGwgKyAiKCIgKyBzdHJwYXJhcyArICIpOyIpOwogICAgICAgICAgIAogICAgICAgICAgIC8vICQoJyNvdmVybGF5Jykuc2hvdygpOwogICAgICAgIH0KICAgICAgICBjYXRjaCAoZXJyKSB7CiAgICAgICAgICAgIC8vJCgnI292ZXJsYXknKS5zaG93KCk7CiAgICAgICAgICAgIHJlc3VsdCA9ICIiICsgZXJyICsgIiI7CiAgICAgICAgICAgIHNob3dMb2FkaW5nKGZhbHNlLCBzdHJCdG5OYW1lKTsKICAgICAgICB9CiAgICAgICAgLy9zZXRUaW1lb3V0KGZ1bmN0aW9uICgpIHsKICAgICAgICAvLyAgICAkKCcjb3ZlcmxheScpLnNob3coKTsKICAgICAgICAvL30sIDI1MDApOwogICAgICAgCiAgICAgICAgLy9kb2N1bWVudC5nZXRFbGVtZW50QnlJZChzdHJPdXRwdXRFbGVtZW50TmFtZSkuaW5uZXJIVE1MID0gIjxicj48YnI+IFsmbmJzcDs8Yj4iICs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+ICI7CiAgICAgICAgICAgICAgICBpZiAocmVzXzJbaV0gIT0gbnVsbCAmJiByZXNfMltpXS50b1N0cmluZygpICE9ICcnKSB7CiAgICAgICAgICAgICAgICAgICAgc3RyQW5zd2VyID0gc3RyQW5zd2VyICsgIiA8Yj4iICsgdG1wYXJyYXlbMF0gKyAiPC9iPiAmbmJzcDsgPGZvbnQgY29sb3I9J3NpbHZlcic+PGk+IiArIHRtcGFycmF5WzFdICsgIjwvaT48L2ZvbnQ+IDxiPjo8L2I+ICZuYnNwOyIKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHN0ckFuc3dlciA9IHN0ckFuc3dlciArIGZvcm1hdHJlc3VsdChzdHJWYWxbaV0udG9TdHJpbmcoKSwgdG1wYXJyYXlbMV0pICsgIjxicj4iOwogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgc3RyQW5zd2VyID0gc3RyQW5zd2VyICsgIiZuYnNwOzxmb250IGNvbG9yPSdncmVlbic+PGkgY2xhc3M9J2ZhICBmYS1hbmdsZS1kb3VibGUtcmlnaHQnPjwvaT48L2ZvbnQ+ICI7CiAgICAgICAgICAgIGlmIChzdHJPdXRwdXRGaWVsZE5hbWVzICE9ICcnKSB7CiAgICAgICAgICAgICAgICB2YXIgdG1wYXJyYXkgPSBzdHJPdXRwdXRGaWVsZE5hbWVzLnRvU3RyaW5nKCkuc3BsaXQoJ3wnKTsKICAgICAgICAgICAgICAgIHN0ckFuc3dlciA9IHN0ckFuc3dlciArICIgPGI+IiArIHRtcGFycmF5WzBdICsgIjwvYj4gJm5ic3A7IDxmb250IGNvbG9yPSdzaWx2ZXInPjxpPiIgKyB0bXBhcnJheVsxXSArICI8L2k+PC9mb250PiA8Yj46PC9iPiAmbmJzcDsiOwogICAgICAgICAgICAgICAgc3RyVmFsID0gZm9ybWF0cmVzdWx0KHN0clZhbC50b1N0cmluZygpLCB0bXBhcnJheVsxXSkKICAgICAgICAgICAgfQogICAgICA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JSZXN1bHQgKyAiJyB0YXJnZXQ9J19ibGFuayc+IiArIHN0clJlc3VsdCArICI8L2E+IjsKICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgICAgIHJldHVybiBodG1sRW5jb2RlKHN0clJlc3VsdCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy99IGVsc2UgaWYgKHJlc3VsdHR5cGUgPT0gJ2Jvb2wnKSB7CiAgICAgICAgICAgIC8vICAgIHJldHVybiBCb29sZWFuKHJlbW92ZTB4KHN0clJlc3VsdCkpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIHJldHVybiBodG1sRW5jb2RlKHN0clJlc3VsdCk7CiAgICAgICAgfQogICAgfQogICAgZnVuY3Rpb24gaGV4X3RvX2FzY2lpKHN0cjEpIHsKICAgICAgICB2YXIgaGV4ID0gc3RyMS50b1N0cmluZygpOwogICAgICAgIHZhciBzdHIgPSAnJzsKICAgICAgICBmb3IgKHZhciBuID0gMDsgbiA8IGhleC5sZW5ndGg7IG4gKz0gMikgewogICAgICAgICAgICBzdHIgKz0gU3RyaW5nLmZyb21DaGFyQ29kZShwYXJzZUludChoZXguc3Vic3RyKG4sIDIpLCAxNikpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gc3RyOwogICAgfQogICAgZnVuY3Rpb24gZXh0cmFjdGFkZHJlc3Moc3RyMSkgewogICAgICAgIGlmIChzdHIxLmxlbmd0aCA+IDQwKSB7CiAgICAgICAgICAgIHN0cjEuc3Vic3RyKHN0cjEubGVuZ3RoIC0gNDApCiAgICAgICAgfQogICAgICAgIHJldHVybiBzdHIxOwogICAgfQogICAgZnVuY3Rpb24gcmVtb3ZlMHgoc3RyMSkgewogICAgICAgIGlmIChzdHIxLnN0YXJ0c1dpdGgoIjB4IikgPT0gdHJ1ZSkgewogICAgICAgICAgICBzdHIxID0gc3RyMS5zdWJzdHIoc3RyMS5sZW5ndGggLSBzdHIxLmxlbmd0aCArIDIpOwogICAgICAgIH0KICAgICA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