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

Java TorException类代码示例

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

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



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

示例1: base32Encode

import com.subgraph.orchid.TorException; //导入依赖的package包/类
public static String base32Encode(byte[] source, int offset, int length) {
	final int nbits = length * 8;
	if(nbits % 5 != 0) 
		throw new TorException("Base32 input length must be a multiple of 5 bits");
	
	final int outlen = nbits / 5;
	final StringBuffer outbuffer = new StringBuffer();
	int bit = 0;
	for(int i = 0; i < outlen; i++) {
		int v = (source[bit / 8] & 0xFF) << 8;
		if(bit + 5 < nbits) v += (source[bit / 8 + 1] & 0xFF);
		int u = (v >> (11 - (bit % 8))) & 0x1F;
		outbuffer.append(BASE32_CHARS.charAt(u));
		bit += 5;
	}		
	return outbuffer.toString();
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:18,代码来源:Base32.java


示例2: base32Decode

import com.subgraph.orchid.TorException; //导入依赖的package包/类
public static byte[] base32Decode(String source) {
	int[] v = stringToIntVector(source);
	
	int nbits = source.length() * 5;
	if(nbits % 8 != 0) 
		throw new TorException("Base32 decoded array must be a muliple of 8 bits");
	
	int outlen = nbits / 8;
	byte[] outbytes = new byte[outlen];
	
	int bit = 0;
	for(int i = 0; i < outlen; i++) {
		int bb = bit / 5;
		outbytes[i] = (byte) decodeByte(bit, v[bb], v[bb + 1], v[bb + 2]);
		bit += 8;	
	}
	return outbytes;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:19,代码来源:Base32.java


示例3: parseBase64Data

import com.subgraph.orchid.TorException; //导入依赖的package包/类
public byte[] parseBase64Data() {
	final StringBuilder string = new StringBuilder(getItem());
	switch(string.length() % 4) {
	case 2:
		string.append("==");
		break;
	case 3:
		string.append("=");
		break;
	default:
		break;
	}
	try {
		return Base64.decode(string.toString().getBytes("ISO-8859-1"));
	} catch (UnsupportedEncodingException e) {
		throw new TorException(e);
	}

}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:20,代码来源:DocumentFieldParserImpl.java


示例4: receiveRelayResponse

import com.subgraph.orchid.TorException; //导入依赖的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


示例5: addListeningPort

import com.subgraph.orchid.TorException; //导入依赖的package包/类
public void addListeningPort(int port) {
	if(port <= 0 || port > 65535) {
		throw new TorException("Illegal listening port: "+ port);
	}
	
	synchronized(listeningPorts) {
		if(isStopped) {
			throw new IllegalStateException("Cannot add listening port because Socks proxy has been stopped");
		}
		if(listeningPorts.contains(port))
			return;
		listeningPorts.add(port);
		try {
			startListening(port);
			logger.fine("Listening for SOCKS connections on port "+ port);
		} catch (IOException e) {
			listeningPorts.remove(port);
			throw new TorException("Failed to listen on port "+ port +" : "+ e.getMessage());
		}
	}
	
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:23,代码来源:SocksPortListenerImpl.java


示例6: createFromBase64

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private HSDescriptorCookie createFromBase64(String b64) {
	if(b64.length() != 22) {
		throw new IllegalArgumentException();
	}
	final byte[] decoded = Base64.decode(b64 + "A=");
	final byte lastByte = decoded[decoded.length - 1];
	final int flag = (lastByte & 0xFF) >> 4;
	final byte[] cookie = new byte[decoded.length - 1];
	System.arraycopy(decoded, 0, cookie, 0, cookie.length);
	switch(flag) {
	case 0:
		return new HSDescriptorCookie(CookieType.COOKIE_BASIC, cookie);
	case 1:
		return new HSDescriptorCookie(CookieType.COOKIE_STEALTH, cookie);
	default:
		throw new TorException("Illegal cookie descriptor with flag value: "+ flag);
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:19,代码来源:TorConfigHSAuth.java


示例7: createRandom

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private static SecureRandom createRandom() {
	try {
		return SecureRandom.getInstance("SHA1PRNG");
	} catch (NoSuchAlgorithmException e) {
		throw new TorException(e);
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:RandomSet.java


示例8: toInetAddress

import com.subgraph.orchid.TorException; //导入依赖的package包/类
public InetAddress toInetAddress() {
	try {
		return InetAddress.getByAddress(getAddressDataBytes());
	} catch (UnknownHostException e) {
		throw new TorException(e);
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:8,代码来源:IPv4Address.java


示例9: HexDigest

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private HexDigest(byte[] data) {
	if(data.length != TorMessageDigest.TOR_DIGEST_SIZE && data.length != TorMessageDigest.TOR_DIGEST256_SIZE) {
		throw new TorException("Digest data is not the correct length "+ data.length +" != (" + TorMessageDigest.TOR_DIGEST_SIZE + " or "+ TorMessageDigest.TOR_DIGEST256_SIZE +")");
	}
	digestBytes = new byte[data.length];
	isDigest256 = digestBytes.length == TorMessageDigest.TOR_DIGEST256_SIZE;
	System.arraycopy(data, 0, digestBytes, 0, data.length);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:9,代码来源:HexDigest.java


示例10: decodeByte

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private static int decodeByte(int bitOffset, int b0, int b1, int b2) {
	switch(bitOffset % 40) {
	case 0: 
		return ls(b0, 3) + rs(b1, 2);
	case 8:
		return ls(b0, 6) + ls(b1, 1) + rs (b2, 4);
	case 16:
		return ls(b0, 4) + rs(b1, 1);
	case 24:
		return ls(b0, 7) + ls(b1, 2) + rs(b2, 3);
	case 32:
		return ls(b0, 5) + (b1 & 0xFF);
	}
	throw new TorException("Illegal bit offset");
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:16,代码来源:Base32.java


示例11: stringToIntVector

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private static int[] stringToIntVector(String s) {
	final int[] ints = new int[s.length() + 1];
	for(int i = 0; i < s.length(); i++) {
		int b = s.charAt(i) & 0xFF;
		if(b > 0x60 && b < 0x7B)
			ints[i] = b - 0x61;
		else if(b > 0x31 && b < 0x38) 
			ints[i] = b - 0x18;
		else if(b > 0x40 && b < 0x5B) 
			ints[i] = b - 0x41;
		else
			throw new TorException("Illegal character in base32 encoded string: "+ s.charAt(i));
	}
	return ints;
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:16,代码来源:Base32.java


示例12: createSocket

import com.subgraph.orchid.TorException; //导入依赖的package包/类
SSLSocket createSocket() {
	try {
		final SSLSocket socket = (SSLSocket) socketFactory.createSocket();
		socket.setEnabledCipherSuites(MANDATORY_CIPHERS);
		socket.setUseClientMode(true);
		return socket;
	} catch (IOException e) {
		throw new TorException(e);
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:ConnectionSocketFactory.java


示例13: getRouterListByNames

import com.subgraph.orchid.TorException; //导入依赖的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:HashEngineering,项目名称:namecoinj,代码行数:12,代码来源:DirectoryImpl.java


示例14: updateStatus

import com.subgraph.orchid.TorException; //导入依赖的package包/类
void updateStatus(RouterStatus status) {
	if(!identityHash.equals(status.getIdentity()))
		throw new TorException("Identity hash does not match status update");
	this.status = status;
	this.cachedCountryCode = null;
	this.descriptor = null;
	refreshDescriptor();
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:9,代码来源:RouterImpl.java


示例15: processDocument

import com.subgraph.orchid.TorException; //导入依赖的package包/类
public void processDocument() {
	if(callbackHandler == null) 
		throw new TorException("DocumentFieldParser#processDocument() called with null callbackHandler");

	while(true) {
		final String line = readLine();
		if(line == null) {
			callbackHandler.endOfDocument();
			return;
		}
		if(processLine(line))
			callbackHandler.parseKeywordLine();
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:DocumentFieldParserImpl.java


示例16: processExtended2

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private CircuitNode processExtended2(RelayCell cell) {
	final int payloadLength = cell.getShort();
	if(payloadLength > cell.cellBytesRemaining()) {
		throw new TorException("Incorrect payload length value in RELAY_EXTENED2 cell");
	}
	byte[] payload = new byte[payloadLength];
	cell.getByteArray(payload);

	return processPayload(payload);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:11,代码来源:NTorCircuitExtender.java


示例17: buildCircuit

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private void buildCircuit(Router firstRouter) throws TorException {
	notifyInitialization();
	final CircuitNode firstNode = extender.createFastTo(firstRouter);
	creationRequest.nodeAdded(firstNode);
	
	for(int i = 1; i < creationRequest.getPathLength(); i++) {
		final CircuitNode extendedNode = extender.extendTo(creationRequest.getPathElement(i));
		creationRequest.nodeAdded(extendedNode);
	}
	creationRequest.circuitBuildCompleted(circuit);
	notifyDone();
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:13,代码来源:CircuitBuildTask.java


示例18: RelayCellImpl

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private RelayCellImpl(CircuitNode node, byte[] rawCell) {
	super(rawCell);
	this.circuitNode = node;
	this.relayCommand = getByte();
	getShort();
	this.streamId = getShort();
	this.isOutgoing = false;
	getInt();
	int payloadLength = getShort();
	cellBuffer.mark(); // End of header
	if(RelayCell.HEADER_SIZE + payloadLength > rawCell.length)
		throw new TorException("Header length field exceeds total size of cell");
	cellBuffer.limit(RelayCell.HEADER_SIZE + payloadLength);
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:15,代码来源:RelayCellImpl.java


示例19: waitForSendWindow

import com.subgraph.orchid.TorException; //导入依赖的package包/类
private void waitForSendWindow(boolean decrement) {
	synchronized(windowLock) {
		while(packageWindow == 0) {
			try {
				windowLock.wait();
			} catch (InterruptedException e) {
				throw new TorException("Thread interrupted while waiting for circuit send window");
			}
		}
		if(decrement)
			packageWindow--;
	}
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:14,代码来源:CircuitNodeImpl.java


示例20: receiveAndProcessCreateFastResponse

import com.subgraph.orchid.TorException; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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