在 javascript 中从 Tor 请求新标识 [英] Request new identify from tor in javascript

查看:19
本文介绍了在 javascript 中从 Tor 请求新标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 PHP 中你会做这样的事情:

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;
}

是否可以在 javascript 中实现相同的功能?

Is it possible to achieve the same thing in javascript?

推荐答案

您无法在 JavaScript 中打开套接字.您可以向服务器发送 AJAX 请求,服务器会为您完成并返回结果.

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.

这篇关于在 javascript 中从 Tor 请求新标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆