本文整理汇总了Java中com.subgraph.orchid.GuardEntry类的典型用法代码示例。如果您正苦于以下问题:Java GuardEntry类的具体用法?Java GuardEntry怎么用?Java GuardEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GuardEntry类属于com.subgraph.orchid包,在下文中一共展示了GuardEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createGuardEntryFor
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
public GuardEntry createGuardEntryFor(Router router) {
final GuardEntryImpl entry = new GuardEntryImpl(directory, this, router.getNickname(), router.getIdentityHash().toString());
final String version = Tor.getImplementation() + "-" + Tor.getVersion();
entry.setVersion(version);
/*
* "Choose expiry time smudged over the last month."
*
* See add_an_entry_guard() in entrynodes.c
*/
final long createTime = (new Date()).getTime() - (random.nextInt(3600 * 24 * 30) * 1000L);
entry.setCreatedTime(new Date(createTime));
return entry;
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:StateFile.java
示例2: addGuardEntry
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private void addGuardEntry(GuardEntry entry, boolean writeFile) {
synchronized(guardEntries) {
if(guardEntries.contains(entry)) {
return;
}
final GuardEntryImpl impl = (GuardEntryImpl) entry;
guardEntries.add(impl);
synchronized (impl) {
impl.setAddedFlag();
if(writeFile) {
writeFile();
}
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:16,代码来源:StateFile.java
示例3: EntryGuards
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
public EntryGuards(TorConfig config, ConnectionCache connectionCache, DirectoryDownloader directoryDownloader, Directory directory) {
this.config = config;
this.random = new TorRandom();
this.nodeChooser = new CircuitNodeChooser(config, directory);
this.connectionCache = connectionCache;
this.directory = directory;
this.pendingProbes = new HashSet<GuardEntry>();
this.bridges = new Bridges(config, directoryDownloader);
this.lock = new Object();
this.executor = Threading.newPool("EntryGuards worker");
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:12,代码来源:EntryGuards.java
示例4: probeConnectionSucceeded
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
void probeConnectionSucceeded(GuardEntry entry) {
synchronized (lock) {
pendingProbes.remove(entry);
if(entry.isAdded()) {
retestProbeSucceeded(entry);
} else {
initialProbeSucceeded(entry);
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:EntryGuards.java
示例5: probeConnectionFailed
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
void probeConnectionFailed(GuardEntry entry) {
synchronized (lock) {
pendingProbes.remove(entry);
if(entry.isAdded()) {
retestProbeFailed(entry);
}
lock.notifyAll();
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:EntryGuards.java
示例6: retestAllUnreachable
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private void retestAllUnreachable() {
for(GuardEntry e: directory.getGuardEntries()) {
if(e.getDownSince() != null) {
launchEntryProbe(e);
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:EntryGuards.java
示例7: testStatusOfAllGuards
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private void testStatusOfAllGuards() {
for(GuardEntry entry: directory.getGuardEntries()) {
if(isPermanentlyUnlisted(entry) || isExpired(entry)) {
directory.removeGuardEntry(entry);
} else if(needsUnreachableTest(entry)) {
launchEntryProbe(entry);
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:EntryGuards.java
示例8: getUsableGuardRouters
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private List<Router> getUsableGuardRouters(Set<Router> excluded) {
List<Router> usableRouters = new ArrayList<Router>();
for(GuardEntry entry: directory.getGuardEntries()) {
addRouterIfUsableAndNotExcluded(entry, excluded, usableRouters);
}
return usableRouters;
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:EntryGuards.java
示例9: addRouterIfUsableAndNotExcluded
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private void addRouterIfUsableAndNotExcluded(GuardEntry entry, Set<Router> excluded, List<Router> routers) {
if(entry.testCurrentlyUsable() && entry.getDownSince() == null) {
final Router r = entry.getRouterForEntry();
if(r != null && !excluded.contains(r)) {
routers.add(r);
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:9,代码来源:EntryGuards.java
示例10: addPendingInitialConnections
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private void addPendingInitialConnections(Set<Router> routerSet) {
for(GuardEntry entry: pendingProbes) {
if(!entry.isAdded()) {
Router r = entry.getRouterForEntry();
if(r != null) {
routerSet.add(r);
}
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:EntryGuards.java
示例11: maybeChooseNew
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private void maybeChooseNew(int usableSize, int minSize, Set<Router> excluded) {
int sz = usableSize + countPendingInitialProbes();
while(sz < minSize) {
Router newGuard = chooseNewGuard(excluded);
if(newGuard == null) {
logger.warning("Need to add entry guards but no suitable guard routers are available");
return;
}
logger.fine("Testing "+ newGuard + " as a new guard since we only have "+ usableSize + " usable guards");
final GuardEntry entry = directory.createGuardEntryFor(newGuard);
launchEntryProbe(entry);
sz += 1;
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:EntryGuards.java
示例12: countPendingInitialProbes
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private int countPendingInitialProbes() {
int count = 0;
for(GuardEntry entry: pendingProbes) {
if(!entry.isAdded()) {
count += 1;
}
}
return count;
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:EntryGuards.java
示例13: launchEntryProbe
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private void launchEntryProbe(GuardEntry entry) {
if(!entry.testCurrentlyUsable() || pendingProbes.contains(entry)) {
return;
}
pendingProbes.add(entry);
executor.execute(new GuardProbeTask(connectionCache, this, entry));
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:EntryGuards.java
示例14: isPermanentlyUnlisted
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private boolean isPermanentlyUnlisted(GuardEntry entry) {
final Date unlistedSince = entry.getUnlistedSince();
if(unlistedSince == null || pendingProbes.contains(entry)) {
return false;
}
final Date now = new Date();
final long unlistedTime = now.getTime() - unlistedSince.getTime();
return unlistedTime > THIRTY_DAYS;
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:EntryGuards.java
示例15: needsUnreachableTest
import com.subgraph.orchid.GuardEntry; //导入依赖的package包/类
private boolean needsUnreachableTest(GuardEntry entry) {
final Date downSince = entry.getDownSince();
if(downSince == null || !entry.testCurrentlyUsable()) {
return false;
}
final Date now = new Date();
final Date lastConnect = entry.getLastConnectAttempt();
final long timeDown = now.getTime() - downSince.getTime();
final long timeSinceLastRetest = (lastConnect == null) ? timeDown : (now.getTime() - lastConnect.getTime());
return timeSinceLastRetest > getRetestInterval(timeDown);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:13,代码来源:EntryGuards.java
注:本文中的com.subgraph.orchid.GuardEntry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论