本文整理汇总了Java中com.subgraph.orchid.Cell类的典型用法代码示例。如果您正苦于以下问题:Java Cell类的具体用法?Java Cell怎么用?Java Cell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cell类属于com.subgraph.orchid包,在下文中一共展示了Cell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
public void sendCell(Cell cell) throws ConnectionIOException {
if(!socket.isConnected()) {
throw new ConnectionIOException("Cannot send cell because connection is not connected");
}
updateLastActivity();
outputLock.lock();
try {
try {
output.write(cell.getCellBytes());
} catch (IOException e) {
logger.fine("IOException writing cell to connection "+ e.getMessage());
closeSocket();
throw new ConnectionIOException(e.getClass().getName() + " : "+ e.getMessage());
}
} finally {
outputLock.unlock();
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:19,代码来源:ConnectionImpl.java
示例2: recvCerts
import com.subgraph.orchid.Cell; //导入依赖的package包/类
void recvCerts() throws ConnectionHandshakeException {
final Cell cell = expectCell(Cell.CERTS);
final int ncerts = cell.getByte();
if(ncerts != 2) {
throw new ConnectionHandshakeException("Expecting 2 certificates and got "+ ncerts);
}
linkCertificate = null;
identityCertificate = null;
for(int i = 0; i < ncerts; i++) {
int type = cell.getByte();
if(type == 1) {
linkCertificate = testAndReadCertificate(cell, linkCertificate, "Link (type = 1)");
} else if(type == 2) {
identityCertificate = testAndReadCertificate(cell, identityCertificate, "Identity (type = 2)");
} else {
throw new ConnectionHandshakeException("Unexpected certificate type = "+ type + " in CERTS cell");
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:23,代码来源:ConnectionHandshakeV3.java
示例3: receiveRelayResponse
import com.subgraph.orchid.Cell; //导入依赖的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
示例4: createIntroductionBuffer
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private ByteBuffer createIntroductionBuffer(int timestamp, Router rr, byte[] cookie, byte[] dhPublic) {
final ByteBuffer buffer = ByteBuffer.allocate(Cell.CELL_LEN);
final byte[] rpAddress = rr.getAddress().getAddressDataBytes();
final short rpPort = (short) rr.getOnionPort();
final byte[] rpIdentity = rr.getIdentityHash().getRawBytes();
final byte[] rpOnionKey = rr.getOnionKey().getRawBytes();
buffer.put((byte) INTRODUCTION_PROTOCOL_VERSION); // VER Version byte: set to 3. [1 octet]
addAuthentication(buffer);
//buffer.put((byte) 0); // AUTHT The auth type that is used [1 octet]
buffer.putInt(timestamp); // TS A timestamp [4 octets]
buffer.put(rpAddress); // IP Rendezvous point's address [4 octets]
buffer.putShort(rpPort); // PORT Rendezvous point's OR port [2 octets]
buffer.put(rpIdentity); // ID Rendezvous point identity ID [20 octets]
buffer.putShort((short) rpOnionKey.length); // KLEN Length of onion key [2 octets]
buffer.put(rpOnionKey); // KEY Rendezvous point onion key [KLEN octets]
buffer.put(cookie); // RC Rendezvous cookie [20 octets]
buffer.put(dhPublic); // g^x Diffie-Hellman data, part 1 [128 octets]
return buffer;
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:22,代码来源:IntroductionProcessor.java
示例5: ConnectionImpl
import com.subgraph.orchid.Cell; //导入依赖的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
示例6: readConnectionControlCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
Cell readConnectionControlCell() throws ConnectionIOException {
try {
return connectionControlCells.take();
} catch (InterruptedException e) {
closeSocket();
throw new ConnectionIOException();
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:9,代码来源:ConnectionImpl.java
示例7: processCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private void processCell(Cell cell) {
updateLastActivity();
final int command = cell.getCommand();
if(command == Cell.RELAY) {
processRelayCell(cell);
return;
}
switch(command) {
case Cell.NETINFO:
case Cell.VERSIONS:
case Cell.CERTS:
case Cell.AUTH_CHALLENGE:
connectionControlCells.add(cell);
break;
case Cell.CREATED:
case Cell.CREATED_FAST:
case Cell.DESTROY:
processControlCell(cell);
break;
default:
// Ignore everything else
break;
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:28,代码来源:ConnectionImpl.java
示例8: processRelayCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private void processRelayCell(Cell cell) {
Circuit circuit;
circuitsLock.lock();
try {
circuit = circuitMap.get(cell.getCircuitId());
if(circuit == null) {
logger.warning("Could not deliver relay cell for circuit id = "+ cell.getCircuitId() +" on connection "+ this +". Circuit not found");
return;
}
} finally {
circuitsLock.unlock();
}
circuit.deliverRelayCell(cell);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:16,代码来源:ConnectionImpl.java
示例9: processControlCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private void processControlCell(Cell cell) {
Circuit circuit;
circuitsLock.lock();
try {
circuit = circuitMap.get(cell.getCircuitId());
} finally {
circuitsLock.unlock();
}
if(circuit != null) {
circuit.deliverControlCell(cell);
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:14,代码来源:ConnectionImpl.java
示例10: testAndReadCertificate
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private X509Certificate testAndReadCertificate(Cell cell, X509Certificate currentValue, String type) throws ConnectionHandshakeException {
if(currentValue == null) {
return readCertificateFromCell(cell);
} else {
throw new ConnectionHandshakeException("Duplicate "+ type + " certificates in CERTS cell");
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:ConnectionHandshakeV3.java
示例11: readCertificateFromCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private X509Certificate readCertificateFromCell(Cell cell) {
try {
final CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
final int clen = cell.getShort();
final byte[] certificateBuffer = new byte[clen];
cell.getByteArray(certificateBuffer);
final ByteArrayInputStream bis = new ByteArrayInputStream(certificateBuffer);
return (X509Certificate) certificateFactory.generateCertificate(bis);
} catch (CertificateException e) {
return null;
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:14,代码来源:ConnectionHandshakeV3.java
示例12: recvAuthChallengeAndNetinfo
import com.subgraph.orchid.Cell; //导入依赖的package包/类
void recvAuthChallengeAndNetinfo() throws ConnectionHandshakeException {
final Cell cell = expectCell(Cell.AUTH_CHALLENGE, Cell.NETINFO);
if(cell.getCommand() == Cell.NETINFO) {
processNetInfo(cell);
return;
}
final Cell netinfo = expectCell(Cell.NETINFO);
processNetInfo(netinfo);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:10,代码来源:ConnectionHandshakeV3.java
示例13: expectCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
protected Cell expectCell(Integer... expectedTypes) throws ConnectionHandshakeException {
try {
final Cell c = connection.readConnectionControlCell();
for(int t: expectedTypes) {
if(c.getCommand() == t) {
return c;
}
}
final List<Integer> expected = Arrays.asList(expectedTypes);
throw new ConnectionHandshakeException("Expecting Cell command "+ expected + " and got [ "+ c.getCommand() +" ] instead");
} catch (ConnectionIOException e) {
throw new ConnectionHandshakeException("Connection exception while performing handshake "+ e);
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:ConnectionHandshake.java
示例14: sendVersions
import com.subgraph.orchid.Cell; //导入依赖的package包/类
protected void sendVersions(int... versions) throws ConnectionIOException {
final Cell cell = CellImpl.createVarCell(0, Cell.VERSIONS, versions.length * 2);
for(int v: versions) {
cell.putShort(v);
}
connection.sendCell(cell);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:ConnectionHandshake.java
示例15: sendNetinfo
import com.subgraph.orchid.Cell; //导入依赖的package包/类
protected void sendNetinfo() throws ConnectionIOException {
final Cell cell = CellImpl.createCell(0, Cell.NETINFO);
putTimestamp(cell);
putIPv4Address(cell, connection.getRouter().getAddress());
putMyAddresses(cell);
connection.sendCell(cell);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:ConnectionHandshake.java
示例16: processNetInfo
import com.subgraph.orchid.Cell; //导入依赖的package包/类
protected void processNetInfo(Cell netinfoCell) {
remoteTimestamp = netinfoCell.getInt();
myAddress = readAddress(netinfoCell);
final int addressCount = netinfoCell.getByte();
for(int i = 0; i < addressCount; i++) {
IPv4Address addr = readAddress(netinfoCell);
if(addr != null) {
remoteAddresses.add(addr);
}
}
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:12,代码来源:ConnectionHandshake.java
示例17: readAddress
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private IPv4Address readAddress(Cell cell) {
final int type = cell.getByte();
final int len = cell.getByte();
if(type == Cell.ADDRESS_TYPE_IPV4 && len == 4) {
return new IPv4Address(cell.getInt());
}
final byte[] buffer = new byte[len];
cell.getByteArray(buffer);
return null;
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:ConnectionHandshake.java
示例18: RelayCellImpl
import com.subgraph.orchid.Cell; //导入依赖的package包/类
public RelayCellImpl(CircuitNode node, int circuit, int stream, int relayCommand, boolean isRelayEarly) {
super(circuit, (isRelayEarly) ? (Cell.RELAY_EARLY) : (Cell.RELAY));
this.circuitNode = node;
this.relayCommand = relayCommand;
this.streamId = stream;
this.isOutgoing = true;
putByte(relayCommand); // Command
putShort(0); // 'Recognized'
putShort(stream); // Stream
putInt(0); // Digest
putShort(0); // Length
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:13,代码来源:RelayCellImpl.java
示例19: receiveAndProcessCreateFastResponse
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private CircuitNode receiveAndProcessCreateFastResponse(Router targetRouter, TorKeyAgreement kex) {
final Cell cell = circuit.receiveControlCellResponse();
if(cell == null) {
throw new TorException("Timeout building circuit waiting for CREATE_FAST response from "+ targetRouter);
}
return processCreatedFastCell(targetRouter, cell, kex);
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:9,代码来源:CircuitExtender.java
示例20: processCreatedFastCell
import com.subgraph.orchid.Cell; //导入依赖的package包/类
private CircuitNode processCreatedFastCell(Router targetRouter, Cell cell, TorKeyAgreement kex) {
final byte[] payload = new byte[TorMessageDigest.TOR_DIGEST_SIZE * 2];
final byte[] keyMaterial = new byte[CircuitNodeCryptoState.KEY_MATERIAL_SIZE];
final byte[] verifyHash = new byte[TorMessageDigest.TOR_DIGEST_SIZE];
cell.getByteArray(payload);
if(!kex.deriveKeysFromHandshakeResponse(payload, keyMaterial, verifyHash)) {
// XXX
return null;
}
final CircuitNode node = CircuitNodeImpl.createFirstHop(targetRouter, keyMaterial, verifyHash);
circuit.appendNode(node);
return node;
}
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:14,代码来源:CircuitExtender.java
注:本文中的com.subgraph.orchid.Cell类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论