• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Router类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sendIntroduce

import com.subgraph.orchid.Router; //导入依赖的package包/类
boolean sendIntroduce(TorPublicKey permanentKey, byte[] publicKeyBytes, byte[] rendezvousCookie, Router rendezvousRouter) {
	final RelayCell introduceCell = introductionCircuit.createRelayCell(RelayCell.RELAY_COMMAND_INTRODUCE1, 0, introductionCircuit.getFinalCircuitNode());

	final byte[] payload = createIntroductionPayload(rendezvousRouter, publicKeyBytes, rendezvousCookie, permanentKey);
	final TorPublicKey serviceKey = introductionPoint.getServiceKey();
	introduceCell.putByteArray(serviceKey.getFingerprint().getRawBytes());
	introduceCell.putByteArray(payload);
	introductionCircuit.sendRelayCell(introduceCell);
	
	final RelayCell response = introductionCircuit.receiveRelayCell();
	if(response == null) {
		logger.fine("Timeout waiting for response to INTRODUCE1 cell");
		return false;
	} else if(response.getRelayCommand() != RelayCell.RELAY_COMMAND_INTRODUCE_ACK) {
		logger.info("Unexpected relay cell type received waiting for response to INTRODUCE1 cell: "+ response.getRelayCommand());
		return false;
	} else if(response.cellBytesRemaining() == 0) {
		return true;
	} else {
		logger.info("INTRODUCE_ACK indicates that introduction was not forwarded: "+ response.getByte());
		return false;
	} 
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:24,代码来源:IntroductionProcessor.java


示例2: receiveRelayResponse

import com.subgraph.orchid.Router; //导入依赖的package包/类
public RelayCell receiveRelayResponse(int expectedCommand, Router extendTarget) {
	final RelayCell cell = circuit.receiveRelayCell();
	if(cell == null) {
		throw new TorException("Timeout building circuit");
	}
	final int command = cell.getRelayCommand();
	if(command == RelayCell.RELAY_TRUNCATED) {
		final int code = cell.getByte() & 0xFF;
		final String msg = CellImpl.errorToDescription(code);
		final String source = nodeToName(cell.getCircuitNode());
		if(code == Cell.ERROR_PROTOCOL) {
			logProtocolViolation(source, extendTarget);
		}
		throw new TorException("Error from ("+ source +") while extending to ("+ extendTarget.getNickname() + "): "+ msg);
	} else if(command != expectedCommand) {
		final String expected = RelayCellImpl.commandToDescription(expectedCommand);
		final String received = RelayCellImpl.commandToDescription(command);
		throw new TorException("Received incorrect extend response, expecting "+ expected + " but received "+ received);
	} else {
		return cell;
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:23,代码来源:CircuitExtender.java


示例3: chooseRandomBridge

import com.subgraph.orchid.Router; //导入依赖的package包/类
BridgeRouter chooseRandomBridge(Set<Router> excluded) throws InterruptedException {
	
	synchronized(lock) {
		if(!bridgesInitialized && !bridgesInitializing) {
			initializeBridges();
		}
		while(!bridgesInitialized && !hasCandidates(excluded)) {
			lock.wait();
		}
		final List<BridgeRouter> candidates = getCandidates(excluded);
		if(candidates.isEmpty()) {
			logger.warning("Bridges enabled but no usable bridges configured");
			return null;
		}
		return candidates.get(random.nextInt(candidates.size()));
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:18,代码来源:Bridges.java


示例4: selectDirectoriesAtIndex

import com.subgraph.orchid.Router; //导入依赖的package包/类
private List<Router> selectDirectoriesAtIndex(int idx) {
	if(idx < 0 || idx >= hsDirectories.size()) {
		throw new IllegalArgumentException("idx = "+ idx);
	}
	if(hsDirectories.size() < DIR_CLUSTER_SZ) {
		throw new IllegalStateException();
	}
	final List<Router> dirs = new ArrayList<Router>(DIR_CLUSTER_SZ);
	for(int i = 0; i < DIR_CLUSTER_SZ; i++) {
		dirs.add(hsDirectories.get(idx));
		idx += 1;
		if(idx == hsDirectories.size()) {
			idx = 0;
		}
	}
	randomShuffle(dirs);
	return dirs;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:19,代码来源:HSDirectories.java


示例5: checkMinimumRouterInfo

import com.subgraph.orchid.Router; //导入依赖的package包/类
private synchronized void checkMinimumRouterInfo() {
	if(currentConsensus == null || !currentConsensus.isLive()) {
		needRecalculateMinimumRouterInfo = true;
		haveMinimumRouterInfo = false;
		return;
	}

	int routerCount = 0;
	int descriptorCount = 0;
	for(Router r: routersByIdentity.values()) {
		routerCount++;
		if(!r.isDescriptorDownloadable())
			descriptorCount++;
	}
	needRecalculateMinimumRouterInfo = false;
	haveMinimumRouterInfo = (descriptorCount * 4 > routerCount);
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:18,代码来源:DirectoryImpl.java


示例6: filterForExitTargets

import com.subgraph.orchid.Router; //导入依赖的package包/类
private List<Router> filterForExitTargets(List<Router> routers, List<ExitTarget> exitTargets) {
	int bestSupport = 0;
	if(exitTargets.isEmpty()) {
		return routers;
	}
	
	final int[] nSupport = new int[routers.size()];
	
	for(int i = 0; i < routers.size(); i++) {
		final Router r = routers.get(i);
		nSupport[i] = countTargetSupport(r, exitTargets);
		if(nSupport[i] > bestSupport) {
			bestSupport = nSupport[i];
		}
	}
	
	if(bestSupport == 0) {
		return routers;
	}

	final List<Router> results = new ArrayList<Router>();
	for(int i = 0; i < routers.size(); i++) {
		if(nSupport[i] == bestSupport) {
			results.add(routers.get(i));
		}
	}
	return results;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:29,代码来源:CircuitPathChooser.java


示例7: ConnectionImpl

import com.subgraph.orchid.Router; //导入依赖的package包/类
public ConnectionImpl(TorConfig config, SSLSocket socket, Router router, TorInitializationTracker tracker, boolean isDirectoryConnection) {
	this.config = config;
	this.socket = socket;
	this.router = router;
	this.circuitMap = new HashMap<Integer, Circuit>();
	this.readCellsThread = new Thread(createReadCellsRunnable());
	this.readCellsThread.setDaemon(true);
	this.connectionControlCells = new LinkedBlockingQueue<Cell>();
	this.initializationTracker = tracker;
	this.isDirectoryConnection = isDirectoryConnection;
	initializeCurrentCircuitId();
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:13,代码来源:ConnectionImpl.java


示例8: chooseRandomNode

import com.subgraph.orchid.Router; //导入依赖的package包/类
/**
 * 
 * @param rule
 * @param routerFilter
 * @return The chosen router or 'null' if no suitable router is available.
 */
public Router chooseRandomNode(WeightRule rule, RouterFilter routerFilter) {
	final List<Router> candidates = getFilteredRouters(routerFilter, true);
	final Router choice = chooseByBandwidth(candidates, rule);
	if(choice == null) {
		// try again with more permissive flags
		return null;
	}
	return choice;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:16,代码来源:CircuitNodeChooser.java


示例9: verifyIdentityKey

import com.subgraph.orchid.Router; //导入依赖的package包/类
protected void verifyIdentityKey(PublicKey publicKey) throws ConnectionHandshakeException {
	if(!(publicKey instanceof RSAPublicKey)) {
		throw new ConnectionHandshakeException("Identity certificate public key is not an RSA key as expected");
	}
	final TorPublicKey identityKey = new TorPublicKey((RSAPublicKey)publicKey);
	final Router router = connection.getRouter();
	if((router instanceof BridgeRouter) && (router.getIdentityHash() == null)) {
		logger.info("Setting Bridge fingerprint from connection handshake for "+ router);
		((BridgeRouter) router).setIdentity(identityKey.getFingerprint());
	} else if(!identityKey.getFingerprint().equals(router.getIdentityHash())) {
		throw new ConnectionHandshakeException("Router identity does not match certificate key");
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:14,代码来源:ConnectionHandshake.java


示例10: extendTo

import com.subgraph.orchid.Router; //导入依赖的package包/类
CircuitNode extendTo(Router targetRouter) {
	if(circuit.getCircuitLength() == 0) {
		throw new TorException("Cannot EXTEND an empty circuit");
	}
	
	if(useNtor(targetRouter)) {
		final NTorCircuitExtender nce = new NTorCircuitExtender(this, targetRouter);
		return nce.extendTo();
	} else {
		final TapCircuitExtender tce = new TapCircuitExtender(this, targetRouter);
		return tce.extendTo();
	}
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:14,代码来源:CircuitExtender.java


示例11: getRouterListByNames

import com.subgraph.orchid.Router; //导入依赖的package包/类
public List<Router> getRouterListByNames(List<String> names) {
	waitUntilLoaded();
	final List<Router> routers = new ArrayList<Router>();
	for(String n: names) {
		final Router r = getRouterByName(n);
		if(r == null)
			throw new TorException("Could not find router named: "+ n);
		routers.add(r);
	}
	return routers;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:12,代码来源:DirectoryImpl.java


示例12: getFutureFor

import com.subgraph.orchid.Router; //导入依赖的package包/类
private Future<ConnectionImpl> getFutureFor(Router router, boolean isDirectoryConnection) {
	Future<ConnectionImpl> f = activeConnections.get(router);
	if(f != null) {
		return f;
	}
	return createFutureForIfAbsent(router, isDirectoryConnection);
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:8,代码来源:ConnectionCacheImpl.java


示例13: getPeers

import com.subgraph.orchid.Router; //导入依赖的package包/类
@Override
public InetSocketAddress[] getPeers(long timeoutValue, TimeUnit timeoutUnit) throws PeerDiscoveryException {
    if (hostNames == null)
        throw new PeerDiscoveryException("Unable to find any peers via DNS");

    Set<Router> routers = Sets.newHashSet();
    ArrayList<ExitTarget> dummyTargets = Lists.newArrayList();

    // Collect exit nodes until we have enough
    while (routers.size() < ROUTER_LOOKUP_COUNT) {
        Router router = pathChooser.chooseExitNodeForTargets(dummyTargets);
        routers.add(router);
    }

    try {
        List<Circuit> circuits =
            getCircuits(torClient.getConfig().getCircuitBuildTimeout(), TimeUnit.MILLISECONDS, routers);
        if (circuits.isEmpty())
            throw new PeerDiscoveryException("Failed to open any circuit within " +
                                             String.valueOf(timeoutValue) + " " + timeoutUnit);

        Collection<InetSocketAddress> addresses = lookupAddresses(timeoutValue, timeoutUnit, circuits);

        if (addresses.size() < MINIMUM_ROUTER_COUNT)
            throw new PeerDiscoveryException("Unable to find enough peers via Tor - got " + addresses.size());
        ArrayList<InetSocketAddress> addressList = Lists.newArrayList();
        addressList.addAll(addresses);
        Collections.shuffle(addressList);
        return addressList.toArray(new InetSocketAddress[addressList.size()]);
    } catch (InterruptedException e) {
        throw new PeerDiscoveryException(e);
    }
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:34,代码来源:TorDiscovery.java


示例14: filter

import com.subgraph.orchid.Router; //导入依赖的package包/类
public boolean filter(Router router) {
	for(RouterFilter f: filterList) {
		if(f.filter(router)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:9,代码来源:ConfigNodeFilter.java


示例15: getCandidates

import com.subgraph.orchid.Router; //导入依赖的package包/类
private List<BridgeRouter> getCandidates(Set<Router> excluded) {
	if(bridgeRouters.isEmpty()) {
		return Collections.emptyList();
	}
	final List<BridgeRouter> candidates = new ArrayList<BridgeRouter>(bridgeRouters.size());
	for(BridgeRouter br: bridgeRouters) {
		if(!excluded.contains(br)) {
			candidates.add(br);
		}
	}
	return candidates;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:13,代码来源:Bridges.java


示例16: chooseEntryNode

import com.subgraph.orchid.Router; //导入依赖的package包/类
public Router chooseEntryNode(final Set<Router> excludedRouters) throws InterruptedException {
	if(useEntryGuards) {
		return entryGuards.chooseRandomGuard(excludedRouters);
	}

	return nodeChooser.chooseRandomNode(WeightRule.WEIGHT_FOR_GUARD, new RouterFilter() {
		public boolean filter(Router router) {
			return router.isPossibleGuard() && !excludedRouters.contains(router);
		}
	});
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:12,代码来源:CircuitPathChooser.java


示例17: isFamilyMember

import com.subgraph.orchid.Router; //导入依赖的package包/类
private boolean isFamilyMember(Collection<String> familyMemberNames, Router r) {
	for(String s: familyMemberNames) {
		Router member = directory.getRouterByName(s);
		if(member != null && member.equals(r)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:CircuitPathChooser.java


示例18: countTargetSupport

import com.subgraph.orchid.Router; //导入依赖的package包/类
private int countTargetSupport(Router router, List<ExitTarget> targets) {
	int count = 0;
	for(ExitTarget t: targets) {
		if(routerSupportsTarget(router, t)) {
			count += 1;
		}
	}
	return count;
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:10,代码来源:CircuitPathChooser.java


示例19: getUsableRouters

import com.subgraph.orchid.Router; //导入依赖的package包/类
List<Router> getUsableRouters(boolean needDescriptor) {
	final List<Router> routers = new ArrayList<Router>();
	for(Router r: directory.getAllRouters()) {
		if(r.isRunning() && 
				r.isValid() && 
				!r.isHibernating() && 
				!(needDescriptor && r.getCurrentDescriptor() == null)) {
			
			routers.add(r);
		}
	}
	
	return routers;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:CircuitNodeChooser.java


示例20: chooseRandomRouterByWeight

import com.subgraph.orchid.Router; //导入依赖的package包/类
Router chooseRandomRouterByWeight() {
	final long total = getScaledTotal();
	if(total == 0) {
		if(weightedRouters.size() == 0) {
			return null;
		}
		final int idx = random.nextInt(weightedRouters.size());
		return weightedRouters.get(idx).router;
	}
	return chooseFirstElementAboveRandom(random.nextLong(total));
}
 
开发者ID:DigiByte-Team,项目名称:digibytej-alice,代码行数:12,代码来源:BandwidthWeightedRouters.java



注:本文中的com.subgraph.orchid.Router类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JCContinue类代码示例发布时间:2022-05-22
下一篇:
Java CompoundSnapToHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap