• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java TorControlConnection类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中net.freehaven.tor.control.TorControlConnection的典型用法代码示例。如果您正苦于以下问题:Java TorControlConnection类的具体用法?Java TorControlConnection怎么用?Java TorControlConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

TorControlConnection类属于net.freehaven.tor.control包,在下文中一共展示了TorControlConnection类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUpControlConnection

点赞 2

import net.freehaven.tor.control.TorControlConnection; //导入依赖的package包/类
private void setUpControlConnection(int controlPort) throws IOException {
  controlSocket = new Socket(Constants.localhost, controlPort);
  controlConn = new TorControlConnection(controlSocket);

  if (config == null) {
    controlConn.authenticate(new byte[0]);
  } else {
    controlConn.authenticate(config.getAuthenticationBytes());
  }
}
 

开发者ID:kit-tm,
项目名称:PTP,
代码行数:11,
代码来源:TorManager.java

示例2: shutdown

点赞 2

import net.freehaven.tor.control.TorControlConnection; //导入依赖的package包/类
public static void shutdown(int controlPort) throws UnknownHostException, IOException {
    Socket s = new Socket(Constants.localhost, controlPort);
    TorControlConnection conn = new TorControlConnection(s);
    conn.authenticate(new byte[0]);
    conn.shutdownTor(Constants.shutdownsignal);
}
 

开发者ID:weichweich,
项目名称:AluShare,
代码行数:7,
代码来源:TorManager.java

示例3: startDaemon

点赞 2

import net.freehaven.tor.control.TorControlConnection; //导入依赖的package包/类
private void startDaemon(boolean awaitFirstCircuit) throws Utils.ApplicationError, IOException, InterruptedException {
    try {
        mDataDirectory.mkdirs();
        mCircuitEstablishedLatch = new CountDownLatch(1);
        mControlAuthCookieFile.delete();
        Utils.FileInitializedObserver controlInitializedObserver =
                new Utils.FileInitializedObserver(
                        mDataDirectory,
                        mPidFile.getName(),
                        mControlPortFile.getName(),
                        mControlAuthCookieFile.getName());
        controlInitializedObserver.startWatching();

        ProcessBuilder processBuilder =
                new ProcessBuilder(
                        mExecutableFile.getAbsolutePath(),
                        "--hush",
                        "-f", mConfigFile.getAbsolutePath());
        processBuilder.environment().put("HOME", mRootDirectory.getAbsolutePath());
        processBuilder.directory(mRootDirectory);
        mProcess = processBuilder.start();

        Scanner stdout = new Scanner(mProcess.getInputStream());
        while(stdout.hasNextLine()) {
            Log.addEntry(logTag(), stdout.nextLine());
        }
        stdout.close();

        // TODO: i18n errors (string resources); combine logging with throwing Utils.ApplicationError
        int exit = mProcess.waitFor();
        if (exit != 0) {
            throw new Utils.ApplicationError(logTag(), String.format("Tor exited with error %d", exit));
        }

        if (!controlInitializedObserver.await(CONTROL_INITIALIZED_TIMEOUT_MILLISECONDS)) {
            throw new Utils.ApplicationError(logTag(), "timeout waiting for Tor control initialization");
        }

        mPid = Utils.readFileToInt(mPidFile);
        mControlPort = getPortValue(Utils.readFileToString(mControlPortFile).trim());
        mControlSocket = new Socket("127.0.0.1", mControlPort);
        mControlConnection = new TorControlConnection(mControlSocket);
        mControlConnection.authenticate(Utils.readFileToBytes(mControlAuthCookieFile));
        mControlConnection.setEventHandler(this);
        mControlConnection.setEvents(Arrays.asList("STATUS_CLIENT", "WARN", "ERR"));

        if (awaitFirstCircuit) {
            mCircuitEstablishedLatch.await(CIRCUIT_ESTABLISHED_TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS);
        }
    } finally {
        if (mProcess != null) {
            try {
                mProcess.getOutputStream().close();
                mProcess.getInputStream().close();
                mProcess.getErrorStream().close();
            } catch (IOException e) {
            }
        }
    }
}
 

开发者ID:Psiphon-Labs,
项目名称:ploggy,
代码行数:61,
代码来源:TorWrapper.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)