本文整理汇总了Java中com.subgraph.orchid.data.exitpolicy.ExitTarget类的典型用法代码示例。如果您正苦于以下问题:Java ExitTarget类的具体用法?Java ExitTarget怎么用?Java ExitTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExitTarget类属于com.subgraph.orchid.data.exitpolicy包,在下文中一共展示了ExitTarget类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: canHandleExitTo
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
public boolean canHandleExitTo(ExitTarget target) {
synchronized(failedExitRequests) {
if(failedExitRequests.contains(target)) {
return false;
}
}
if(isMarkedForClose()) {
return false;
}
if(target.isAddressTarget()) {
return exitRouter.exitPolicyAccepts(target.getAddress(), target.getPort());
} else {
return exitRouter.exitPolicyAccepts(target.getPort());
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:18,代码来源:ExitCircuitImpl.java
示例2: buildCircuitIfNeeded
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
private void buildCircuitIfNeeded() {
if (connectionCache.isClosed()) {
logger.warning("Not building circuits, because connection cache is closed");
return;
}
final List<StreamExitRequest> pendingExitStreams = circuitManager.getPendingExitStreams();
final List<PredictedPortTarget> predictedPorts = predictor.getPredictedPortTargets();
final List<ExitTarget> exitTargets = new ArrayList<ExitTarget>();
for(StreamExitRequest streamRequest: pendingExitStreams) {
if(!streamRequest.isReserved() && countCircuitsSupportingTarget(streamRequest, false) == 0) {
exitTargets.add(streamRequest);
}
}
for(PredictedPortTarget ppt: predictedPorts) {
if(countCircuitsSupportingTarget(ppt, true) < 2) {
exitTargets.add(ppt);
}
}
buildCircuitToHandleExitTargets(exitTargets);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:22,代码来源:CircuitCreationTask.java
示例3: buildCircuitIfNeeded
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
private void buildCircuitIfNeeded() {
final List<StreamExitRequest> pendingExitStreams = circuitManager.getPendingExitStreams();
final List<PredictedPortTarget> predictedPorts = predictor.getPredictedPortTargets();
final List<ExitTarget> exitTargets = new ArrayList<ExitTarget>();
for(StreamExitRequest streamRequest: pendingExitStreams) {
if(!streamRequest.isReserved() && countCircuitsSupportingTarget(streamRequest, false) == 0) {
exitTargets.add(streamRequest);
}
}
for(PredictedPortTarget ppt: predictedPorts) {
if(countCircuitsSupportingTarget(ppt, true) < 2) {
exitTargets.add(ppt);
}
}
buildCircuitToHandleExitTargets(exitTargets);
}
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:17,代码来源:CircuitCreationTask.java
示例4: countCircuitsSupportingTarget
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
private int countCircuitsSupportingTarget(final ExitTarget target, final boolean needClean) {
final CircuitFilter filter = new CircuitFilter() {
public boolean filter(Circuit circuit) {
if(!(circuit instanceof ExitCircuit)) {
return false;
}
final ExitCircuit ec = (ExitCircuit) circuit;
final boolean pendingOrConnected = circuit.isPending() || circuit.isConnected();
final boolean isCleanIfNeeded = !(needClean && !circuit.isClean());
return pendingOrConnected && isCleanIfNeeded && ec.canHandleExitTo(target);
}
};
return circuitManager.getCircuitsByFilter(filter).size();
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:CircuitCreationTask.java
示例5: buildCircuitToHandleExitTargets
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
private void buildCircuitToHandleExitTargets(List<ExitTarget> exitTargets) {
if(exitTargets.isEmpty()) {
return;
}
if(!directory.haveMinimumRouterInfo())
return;
if(circuitManager.getPendingCircuitCount() >= MAX_PENDING_CIRCUITS)
return;
if(logger.isLoggable(Level.FINE)) {
logger.fine("Building new circuit to handle "+ exitTargets.size() +" pending streams and predicted ports");
}
launchBuildTaskForTargets(exitTargets);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:16,代码来源:CircuitCreationTask.java
示例6: launchBuildTaskForTargets
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
private void launchBuildTaskForTargets(List<ExitTarget> exitTargets) {
final Router exitRouter = pathChooser.chooseExitNodeForTargets(exitTargets);
if(exitRouter == null) {
logger.warning("Failed to select suitable exit node for targets");
return;
}
final Circuit circuit = circuitManager.createNewExitCircuit(exitRouter);
final CircuitCreationRequest request = new CircuitCreationRequest(pathChooser, circuit, buildHandler, false);
final CircuitBuildTask task = new CircuitBuildTask(request, connectionCache, circuitManager.isNtorEnabled(), initializationTracker);
executor.execute(task);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:13,代码来源:CircuitCreationTask.java
示例7: filterForExitTargets
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的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:HashEngineering,项目名称:namecoinj,代码行数:29,代码来源:CircuitPathChooser.java
示例8: countTargetSupport
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的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:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:CircuitPathChooser.java
示例9: routerSupportsTarget
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
private boolean routerSupportsTarget(Router router, ExitTarget target) {
if(target.isAddressTarget()) {
return router.exitPolicyAccepts(target.getAddress(), target.getPort());
} else {
return router.exitPolicyAccepts(target.getPort());
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:CircuitPathChooser.java
示例10: getPeers
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的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:HashEngineering,项目名称:namecoinj,代码行数:34,代码来源:TorDiscovery.java
示例11: getPeers
import com.subgraph.orchid.data.exitpolicy.ExitTarget; //导入依赖的package包/类
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() < MINIMUM_ROUTER_LOOKUP_COUNT) {
Router router = pathChooser.chooseExitNodeForTargets(dummyTargets);
routers.add(router);
}
try {
List<Circuit> circuits = getCircuits(timeoutValue, timeoutUnit, routers);
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:HashEngineering,项目名称:quarkcoinj,代码行数:29,代码来源:TorDiscovery.java
注:本文中的com.subgraph.orchid.data.exitpolicy.ExitTarget类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论