Request new identify from tor in javascript

落花浮王杯 提交于 2019-12-25 05:22:44

问题


In PHP you would do something like this:

function tor_new_identity($tor_ip='127.0.0.1', $control_port='9051', $auth_code='')
{
    $fp = @fsockopen($tor_ip, $control_port, $errno, $errstr, 30);
    if(!$fp)
    {
        return false; //can't connect to the control port
    }

    fputs($fp, "AUTHENTICATE $auth_code\r\n");
    $response = fread($fp, 1024);
    list($code, $text) = explode(' ', $response, 2);
    if ($code != '250') return false; //authentication failed

    //send the request to for new identity
    fputs($fp, "signal NEWNYM\r\n");
    $response = fread($fp, 1024);
    list($code, $text) = explode(' ', $response, 2);
    if ($code != '250') return false; //signal failed

    fclose($fp);
    return true;
}

Is it possible to achieve the same thing in javascript?


回答1:


You can't open a socket in JavaScript. You could send an AJAX request to the server, and the server would do it for you and return the results.



来源:https://stackoverflow.com/questions/11585681/request-new-identify-from-tor-in-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!