Remove 'get' prefix
This commit is contained in:
parent
eacc474cda
commit
4472fe9795
@ -28,7 +28,7 @@ import java.net.URI;
|
||||
*/
|
||||
public abstract class WebSocketClientHandshaker {
|
||||
|
||||
private final URI webSocketUrl;
|
||||
private final URI uri;
|
||||
|
||||
private final WebSocketVersion version;
|
||||
|
||||
@ -45,7 +45,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
/**
|
||||
* Base constructor
|
||||
*
|
||||
* @param webSocketUrl
|
||||
* @param uri
|
||||
* URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
|
||||
* sent to this URL.
|
||||
* @param version
|
||||
@ -57,9 +57,9 @@ public abstract class WebSocketClientHandshaker {
|
||||
* @param maxFramePayloadLength
|
||||
* Maximum length of a frame's payload
|
||||
*/
|
||||
protected WebSocketClientHandshaker(URI webSocketUrl, WebSocketVersion version, String subprotocol,
|
||||
protected WebSocketClientHandshaker(URI uri, WebSocketVersion version, String subprotocol,
|
||||
HttpHeaders customHeaders, int maxFramePayloadLength) {
|
||||
this.webSocketUrl = webSocketUrl;
|
||||
this.uri = uri;
|
||||
this.version = version;
|
||||
expectedSubprotocol = subprotocol;
|
||||
this.customHeaders = customHeaders;
|
||||
@ -69,21 +69,21 @@ public abstract class WebSocketClientHandshaker {
|
||||
/**
|
||||
* Returns the URI to the web socket. e.g. "ws://myhost.com/path"
|
||||
*/
|
||||
public URI getWebSocketUrl() {
|
||||
return webSocketUrl;
|
||||
public URI uri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of the web socket specification that is being used
|
||||
*/
|
||||
public WebSocketVersion getVersion() {
|
||||
public WebSocketVersion version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max length for any frame's payload
|
||||
*/
|
||||
public int getMaxFramePayloadLength() {
|
||||
public int maxFramePayloadLength() {
|
||||
return maxFramePayloadLength;
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
/**
|
||||
* Returns the CSV of requested subprotocol(s) sent to the server as specified in the constructor
|
||||
*/
|
||||
public String getExpectedSubprotocol() {
|
||||
public String expectedSubprotocol() {
|
||||
return expectedSubprotocol;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public abstract class WebSocketClientHandshaker {
|
||||
* Returns the subprotocol response sent by the server. Only available after end of handshake.
|
||||
* Null if no subprotocol was requested or confirmed by the server.
|
||||
*/
|
||||
public String getActualSubprotocol() {
|
||||
public String actualSubprotocol() {
|
||||
return actualSubprotocol;
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
expectedChallengeResponseBytes = WebSocketUtil.md5(challenge);
|
||||
|
||||
// Get path
|
||||
URI wsURL = getWebSocketUrl();
|
||||
URI wsURL = uri();
|
||||
String path = wsURL.getPath();
|
||||
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
|
||||
path = wsURL.getPath() + '?' + wsURL.getQuery();
|
||||
@ -159,7 +159,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
.add(Names.SEC_WEBSOCKET_KEY1, key1)
|
||||
.add(Names.SEC_WEBSOCKET_KEY2, key2);
|
||||
|
||||
String expectedSubprotocol = getExpectedSubprotocol();
|
||||
String expectedSubprotocol = expectedSubprotocol();
|
||||
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
|
||||
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
|
||||
}
|
||||
@ -250,7 +250,7 @@ public class WebSocketClientHandshaker00 extends WebSocketClientHandshaker {
|
||||
ChannelPipeline p = channel.pipeline();
|
||||
p.remove(HttpRequestEncoder.class);
|
||||
p.get(HttpResponseDecoder.class).replace(
|
||||
"ws-decoder", new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
|
||||
"ws-decoder", new WebSocket00FrameDecoder(maxFramePayloadLength()));
|
||||
}
|
||||
|
||||
private static String insertRandomCharacters(String key) {
|
||||
|
@ -100,7 +100,7 @@ public class WebSocketClientHandshaker07 extends WebSocketClientHandshaker {
|
||||
@Override
|
||||
public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
|
||||
// Get path
|
||||
URI wsURL = getWebSocketUrl();
|
||||
URI wsURL = uri();
|
||||
String path = wsURL.getPath();
|
||||
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
|
||||
path = wsURL.getPath() + '?' + wsURL.getQuery();
|
||||
@ -141,7 +141,7 @@ public class WebSocketClientHandshaker07 extends WebSocketClientHandshaker {
|
||||
}
|
||||
headers.add(Names.SEC_WEBSOCKET_ORIGIN, originValue);
|
||||
|
||||
String expectedSubprotocol = getExpectedSubprotocol();
|
||||
String expectedSubprotocol = expectedSubprotocol();
|
||||
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
|
||||
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
|
||||
}
|
||||
@ -224,6 +224,6 @@ public class WebSocketClientHandshaker07 extends WebSocketClientHandshaker {
|
||||
ChannelPipeline p = channel.pipeline();
|
||||
p.get(HttpResponseDecoder.class).replace(
|
||||
"ws-decoder",
|
||||
new WebSocket07FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
|
||||
new WebSocket07FrameDecoder(false, allowExtensions, maxFramePayloadLength()));
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
@Override
|
||||
public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
|
||||
// Get path
|
||||
URI wsURL = getWebSocketUrl();
|
||||
URI wsURL = uri();
|
||||
String path = wsURL.getPath();
|
||||
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
|
||||
path = wsURL.getPath() + '?' + wsURL.getQuery();
|
||||
@ -141,7 +141,7 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
}
|
||||
headers.add(Names.SEC_WEBSOCKET_ORIGIN, originValue);
|
||||
|
||||
String expectedSubprotocol = getExpectedSubprotocol();
|
||||
String expectedSubprotocol = expectedSubprotocol();
|
||||
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
|
||||
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
|
||||
}
|
||||
@ -225,6 +225,6 @@ public class WebSocketClientHandshaker08 extends WebSocketClientHandshaker {
|
||||
p.remove(HttpRequestEncoder.class);
|
||||
p.get(HttpResponseDecoder.class).replace(
|
||||
"ws-decoder",
|
||||
new WebSocket08FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
|
||||
new WebSocket08FrameDecoder(false, allowExtensions, maxFramePayloadLength()));
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
@Override
|
||||
public ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
|
||||
// Get path
|
||||
URI wsURL = getWebSocketUrl();
|
||||
URI wsURL = uri();
|
||||
String path = wsURL.getPath();
|
||||
if (wsURL.getQuery() != null && !wsURL.getQuery().isEmpty()) {
|
||||
path = wsURL.getPath() + '?' + wsURL.getQuery();
|
||||
@ -141,7 +141,7 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
}
|
||||
headers.add(Names.SEC_WEBSOCKET_ORIGIN, originValue);
|
||||
|
||||
String expectedSubprotocol = getExpectedSubprotocol();
|
||||
String expectedSubprotocol = expectedSubprotocol();
|
||||
if (expectedSubprotocol != null && !expectedSubprotocol.isEmpty()) {
|
||||
headers.add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
|
||||
}
|
||||
@ -224,6 +224,6 @@ public class WebSocketClientHandshaker13 extends WebSocketClientHandshaker {
|
||||
p.remove(HttpRequestEncoder.class);
|
||||
p.get(HttpResponseDecoder.class).replace(
|
||||
"ws-decoder",
|
||||
new WebSocket13FrameDecoder(false, allowExtensions, getMaxFramePayloadLength()));
|
||||
new WebSocket13FrameDecoder(false, allowExtensions, maxFramePayloadLength()));
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
|
||||
private static final String[] EMPTY_ARRAY = new String[0];
|
||||
|
||||
private final String webSocketUrl;
|
||||
private final String uri;
|
||||
|
||||
private final String[] subprotocols;
|
||||
|
||||
@ -47,7 +47,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
*
|
||||
* @param version
|
||||
* the protocol version
|
||||
* @param webSocketUrl
|
||||
* @param uri
|
||||
* URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be
|
||||
* sent to this URL.
|
||||
* @param subprotocols
|
||||
@ -56,10 +56,10 @@ public abstract class WebSocketServerHandshaker {
|
||||
* Maximum length of a frame's payload
|
||||
*/
|
||||
protected WebSocketServerHandshaker(
|
||||
WebSocketVersion version, String webSocketUrl, String subprotocols,
|
||||
WebSocketVersion version, String uri, String subprotocols,
|
||||
int maxFramePayloadLength) {
|
||||
this.version = version;
|
||||
this.webSocketUrl = webSocketUrl;
|
||||
this.uri = uri;
|
||||
if (subprotocols != null) {
|
||||
String[] subprotocolArray = StringUtil.split(subprotocols, ',');
|
||||
for (int i = 0; i < subprotocolArray.length; i++) {
|
||||
@ -75,14 +75,14 @@ public abstract class WebSocketServerHandshaker {
|
||||
/**
|
||||
* Returns the URL of the web socket
|
||||
*/
|
||||
public String getWebSocketUrl() {
|
||||
return webSocketUrl;
|
||||
public String uri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CSV of supported sub protocols
|
||||
*/
|
||||
public Set<String> getSubprotocols() {
|
||||
public Set<String> subprotocols() {
|
||||
Set<String> ret = new LinkedHashSet<String>();
|
||||
Collections.addAll(ret, subprotocols);
|
||||
return ret;
|
||||
@ -91,7 +91,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
/**
|
||||
* Returns the version of the specification being supported
|
||||
*/
|
||||
public WebSocketVersion getVersion() {
|
||||
public WebSocketVersion version() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
*
|
||||
* @return The maximum length for a frame's payload
|
||||
*/
|
||||
public int getMaxFramePayloadLength() {
|
||||
public int maxFramePayloadLength() {
|
||||
return maxFramePayloadLength;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ public abstract class WebSocketServerHandshaker {
|
||||
* This is only available AFTER <tt>handshake()</tt> has been called.
|
||||
* </p>
|
||||
*/
|
||||
public String getSelectedSubprotocol() {
|
||||
public String selectedSubprotocol() {
|
||||
return selectedSubprotocol;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
||||
if (isHixie76) {
|
||||
// New handshake method with a challenge:
|
||||
res.headers().add(SEC_WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
|
||||
res.headers().add(SEC_WEBSOCKET_LOCATION, getWebSocketUrl());
|
||||
res.headers().add(SEC_WEBSOCKET_LOCATION, uri());
|
||||
String subprotocols = req.headers().get(SEC_WEBSOCKET_PROTOCOL);
|
||||
if (subprotocols != null) {
|
||||
String selectedSubprotocol = selectSubprotocol(subprotocols);
|
||||
@ -172,7 +172,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
||||
} else {
|
||||
// Old Hixie 75 handshake method with no challenge:
|
||||
res.headers().add(WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
|
||||
res.headers().add(WEBSOCKET_LOCATION, getWebSocketUrl());
|
||||
res.headers().add(WEBSOCKET_LOCATION, uri());
|
||||
String protocol = req.headers().get(WEBSOCKET_PROTOCOL);
|
||||
if (protocol != null) {
|
||||
res.headers().add(WEBSOCKET_PROTOCOL, selectSubprotocol(protocol));
|
||||
@ -189,7 +189,7 @@ public class WebSocketServerHandshaker00 extends WebSocketServerHandshaker {
|
||||
p.remove(HttpObjectAggregator.class);
|
||||
}
|
||||
p.get(HttpRequestDecoder.class).replace("wsdecoder",
|
||||
new WebSocket00FrameDecoder(getMaxFramePayloadLength()));
|
||||
new WebSocket00FrameDecoder(maxFramePayloadLength()));
|
||||
|
||||
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket00FrameEncoder());
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class WebSocketServerHandshaker07 extends WebSocketServerHandshaker {
|
||||
}
|
||||
|
||||
p.get(HttpRequestDecoder.class).replace("wsdecoder",
|
||||
new WebSocket07FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
|
||||
new WebSocket07FrameDecoder(true, allowExtensions, maxFramePayloadLength()));
|
||||
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket07FrameEncoder(false));
|
||||
}
|
||||
});
|
||||
|
@ -156,7 +156,7 @@ public class WebSocketServerHandshaker08 extends WebSocketServerHandshaker {
|
||||
}
|
||||
|
||||
p.get(HttpRequestDecoder.class).replace("wsdecoder",
|
||||
new WebSocket08FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
|
||||
new WebSocket08FrameDecoder(true, allowExtensions, maxFramePayloadLength()));
|
||||
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket08FrameEncoder(false));
|
||||
}
|
||||
});
|
||||
|
@ -156,7 +156,7 @@ public class WebSocketServerHandshaker13 extends WebSocketServerHandshaker {
|
||||
}
|
||||
|
||||
p.get(HttpRequestDecoder.class).replace("wsdecoder",
|
||||
new WebSocket13FrameDecoder(true, allowExtensions, getMaxFramePayloadLength()));
|
||||
new WebSocket13FrameDecoder(true, allowExtensions, maxFramePayloadLength()));
|
||||
p.replace(HttpResponseEncoder.class, "wsencoder", new WebSocket13FrameEncoder(false));
|
||||
}
|
||||
});
|
||||
|
@ -96,7 +96,7 @@ public abstract class SpdyOrHttpChooser extends ChannelHandlerAdapter implements
|
||||
throw new IllegalStateException("SslHandler is needed for SPDY");
|
||||
}
|
||||
|
||||
SelectedProtocol protocol = getProtocol(handler.getEngine());
|
||||
SelectedProtocol protocol = getProtocol(handler.engine());
|
||||
switch (protocol) {
|
||||
case None:
|
||||
// Not done with choosing the protocol, so just return here for now,
|
||||
|
@ -153,10 +153,8 @@ public class WebSocketServerProtocolHandlerTest {
|
||||
content = "processed: " + msg.text();
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public final class SocksAuthRequest extends SocksRequest {
|
||||
*
|
||||
* @return username that needs to be authenticated
|
||||
*/
|
||||
public String getUsername() {
|
||||
public String username() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public final class SocksAuthRequest extends SocksRequest {
|
||||
*
|
||||
* @return password that needs to be validated
|
||||
*/
|
||||
public String getPassword() {
|
||||
public String password() {
|
||||
return password;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public final class SocksAuthResponse extends SocksResponse {
|
||||
*
|
||||
* @return The {@link AuthStatus} of this {@link SocksAuthResponse}
|
||||
*/
|
||||
public AuthStatus getAuthStatus() {
|
||||
public AuthStatus authStatus() {
|
||||
return authStatus;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public final class SocksCmdRequest extends SocksRequest {
|
||||
*
|
||||
* @return The {@link CmdType} of this {@link SocksCmdRequest}
|
||||
*/
|
||||
public CmdType getCmdType() {
|
||||
public CmdType cmdType() {
|
||||
return cmdType;
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public final class SocksCmdRequest extends SocksRequest {
|
||||
*
|
||||
* @return The {@link AddressType} of this {@link SocksCmdRequest}
|
||||
*/
|
||||
public AddressType getAddressType() {
|
||||
public AddressType addressType() {
|
||||
return addressType;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public final class SocksCmdRequest extends SocksRequest {
|
||||
*
|
||||
* @return host that is used as a parameter in {@link CmdType}
|
||||
*/
|
||||
public String getHost() {
|
||||
public String host() {
|
||||
return IDN.toUnicode(host);
|
||||
}
|
||||
|
||||
@ -104,13 +104,13 @@ public final class SocksCmdRequest extends SocksRequest {
|
||||
*
|
||||
* @return port that is used as a parameter in {@link CmdType}
|
||||
*/
|
||||
public int getPort() {
|
||||
public int port() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeAsByteBuf(ByteBuf byteBuf) {
|
||||
byteBuf.writeByte(getProtocolVersion().getByteValue());
|
||||
byteBuf.writeByte(protocolVersion().getByteValue());
|
||||
byteBuf.writeByte(cmdType.getByteValue());
|
||||
byteBuf.writeByte(0x00);
|
||||
byteBuf.writeByte(addressType.getByteValue());
|
||||
|
@ -51,7 +51,7 @@ public final class SocksCmdResponse extends SocksResponse {
|
||||
*
|
||||
* @return The {@link CmdStatus} of this {@link SocksCmdResponse}
|
||||
*/
|
||||
public CmdStatus getCmdStatus() {
|
||||
public CmdStatus cmdStatus() {
|
||||
return cmdStatus;
|
||||
}
|
||||
|
||||
@ -60,13 +60,13 @@ public final class SocksCmdResponse extends SocksResponse {
|
||||
*
|
||||
* @return The {@link AddressType} of this {@link SocksCmdResponse}
|
||||
*/
|
||||
public AddressType getAddressType() {
|
||||
public AddressType addressType() {
|
||||
return addressType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeAsByteBuf(ByteBuf byteBuf) {
|
||||
byteBuf.writeByte(getProtocolVersion().getByteValue());
|
||||
byteBuf.writeByte(protocolVersion().getByteValue());
|
||||
byteBuf.writeByte(cmdStatus.getByteValue());
|
||||
byteBuf.writeByte(0x00);
|
||||
byteBuf.writeByte(addressType.getByteValue());
|
||||
|
@ -42,13 +42,13 @@ public final class SocksInitRequest extends SocksRequest {
|
||||
*
|
||||
* @return The List<{@link AuthScheme}> of this {@link SocksInitRequest}
|
||||
*/
|
||||
public List<AuthScheme> getAuthSchemes() {
|
||||
public List<AuthScheme> authSchemes() {
|
||||
return Collections.unmodifiableList(authSchemes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeAsByteBuf(ByteBuf byteBuf) {
|
||||
byteBuf.writeByte(getProtocolVersion().getByteValue());
|
||||
byteBuf.writeByte(protocolVersion().getByteValue());
|
||||
byteBuf.writeByte(authSchemes.size());
|
||||
for (AuthScheme authScheme : authSchemes) {
|
||||
byteBuf.writeByte(authScheme.getByteValue());
|
||||
|
@ -39,13 +39,13 @@ public final class SocksInitResponse extends SocksResponse {
|
||||
*
|
||||
* @return The {@link AuthScheme} of this {@link SocksInitResponse}
|
||||
*/
|
||||
public AuthScheme getAuthScheme() {
|
||||
public AuthScheme authScheme() {
|
||||
return authScheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeAsByteBuf(ByteBuf byteBuf) {
|
||||
byteBuf.writeByte(getProtocolVersion().getByteValue());
|
||||
byteBuf.writeByte(protocolVersion().getByteValue());
|
||||
byteBuf.writeByte(authScheme.getByteValue());
|
||||
}
|
||||
}
|
||||
|
@ -26,14 +26,14 @@ import io.netty.buffer.ByteBuf;
|
||||
*/
|
||||
|
||||
public abstract class SocksMessage {
|
||||
private final MessageType messageType;
|
||||
private final MessageType type;
|
||||
private final ProtocolVersion protocolVersion = ProtocolVersion.SOCKS5;
|
||||
|
||||
protected SocksMessage(MessageType messageType) {
|
||||
if (messageType == null) {
|
||||
throw new NullPointerException("messageType");
|
||||
protected SocksMessage(MessageType type) {
|
||||
if (type == null) {
|
||||
throw new NullPointerException("type");
|
||||
}
|
||||
this.messageType = messageType;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,8 +41,8 @@ public abstract class SocksMessage {
|
||||
*
|
||||
* @return The {@link MessageType} of this {@link SocksMessage}
|
||||
*/
|
||||
public MessageType getMessageType() {
|
||||
return messageType;
|
||||
public MessageType type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public enum MessageType {
|
||||
@ -239,7 +239,7 @@ public abstract class SocksMessage {
|
||||
*
|
||||
* @return The {@link ProtocolVersion} of this {@link SocksMessage}
|
||||
*/
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
public ProtocolVersion protocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
|
@ -25,14 +25,14 @@ package io.netty.handler.codec.socks;
|
||||
* @see UnknownSocksRequest
|
||||
*/
|
||||
public abstract class SocksRequest extends SocksMessage {
|
||||
private final SocksRequestType socksRequestType;
|
||||
private final SocksRequestType requestType;
|
||||
|
||||
protected SocksRequest(SocksRequestType socksRequestType) {
|
||||
protected SocksRequest(SocksRequestType requestType) {
|
||||
super(MessageType.REQUEST);
|
||||
if (socksRequestType == null) {
|
||||
throw new NullPointerException("socksRequestType");
|
||||
if (requestType == null) {
|
||||
throw new NullPointerException("requestType");
|
||||
}
|
||||
this.socksRequestType = socksRequestType;
|
||||
this.requestType = requestType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,8 +40,8 @@ public abstract class SocksRequest extends SocksMessage {
|
||||
*
|
||||
* @return socks request type
|
||||
*/
|
||||
public SocksRequestType getSocksRequestType() {
|
||||
return socksRequestType;
|
||||
public SocksRequestType requestType() {
|
||||
return requestType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,14 +25,14 @@ package io.netty.handler.codec.socks;
|
||||
* @see UnknownSocksResponse
|
||||
*/
|
||||
public abstract class SocksResponse extends SocksMessage {
|
||||
private final SocksResponseType socksResponseType;
|
||||
private final SocksResponseType responseType;
|
||||
|
||||
protected SocksResponse(SocksResponseType socksResponseType) {
|
||||
protected SocksResponse(SocksResponseType responseType) {
|
||||
super(MessageType.RESPONSE);
|
||||
if (socksResponseType == null) {
|
||||
throw new NullPointerException("socksResponseType");
|
||||
if (responseType == null) {
|
||||
throw new NullPointerException("responseType");
|
||||
}
|
||||
this.socksResponseType = socksResponseType;
|
||||
this.responseType = responseType;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,8 +40,8 @@ public abstract class SocksResponse extends SocksMessage {
|
||||
*
|
||||
* @return socks response type
|
||||
*/
|
||||
public SocksResponseType getSocksResponseType() {
|
||||
return socksResponseType;
|
||||
public SocksResponseType responseType() {
|
||||
return responseType;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,13 +17,11 @@ package io.netty.handler.codec.socks;
|
||||
|
||||
import io.netty.channel.embedded.EmbeddedByteChannel;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SocksAuthRequestDecoderTest {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SocksAuthRequestDecoderTest.class);
|
||||
|
||||
@Test
|
||||
public void testAuthRequestDecoder() {
|
||||
String username = "test";
|
||||
@ -33,8 +31,8 @@ public class SocksAuthRequestDecoderTest {
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
|
||||
msg = (SocksAuthRequest) embedder.readInbound();
|
||||
assertEquals(msg.getUsername(), username);
|
||||
assertEquals(msg.getUsername(), password);
|
||||
assertEquals(msg.username(), username);
|
||||
assertEquals(msg.username(), password);
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class SocksAuthResponseDecoderTest {
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
|
||||
msg = (SocksAuthResponse) embedder.readInbound();
|
||||
assertSame(msg.getAuthStatus(), authStatus);
|
||||
assertSame(msg.authStatus(), authStatus);
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
|
||||
|
@ -32,14 +32,14 @@ public class SocksCmdRequestDecoderTest {
|
||||
SocksCmdRequestDecoder decoder = new SocksCmdRequestDecoder();
|
||||
EmbeddedByteChannel embedder = new EmbeddedByteChannel(decoder);
|
||||
SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
|
||||
if (msg.getAddressType() == SocksMessage.AddressType.UNKNOWN) {
|
||||
if (msg.addressType() == SocksMessage.AddressType.UNKNOWN) {
|
||||
assertTrue(embedder.readInbound() instanceof UnknownSocksRequest);
|
||||
} else {
|
||||
msg = (SocksCmdRequest) embedder.readInbound();
|
||||
assertSame(msg.getCmdType(), cmdType);
|
||||
assertSame(msg.getAddressType(), addressType);
|
||||
assertEquals(msg.getHost(), host);
|
||||
assertEquals(msg.getPort(), port);
|
||||
assertSame(msg.cmdType(), cmdType);
|
||||
assertSame(msg.addressType(), addressType);
|
||||
assertEquals(msg.host(), host);
|
||||
assertEquals(msg.port(), port);
|
||||
}
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class SocksCmdResponseDecoderTest {
|
||||
assertTrue(embedder.readInbound() instanceof UnknownSocksResponse);
|
||||
} else {
|
||||
msg = (SocksResponse) embedder.readInbound();
|
||||
assertEquals(((SocksCmdResponse) msg).getCmdStatus(), cmdStatus);
|
||||
assertEquals(((SocksCmdResponse) msg).cmdStatus(), cmdStatus);
|
||||
}
|
||||
assertNull(embedder.readInbound());
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class WebSocketSslServerInitializer extends ChannelInitializer<SocketChan
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
ChannelPipeline pipeline = ch.pipeline();
|
||||
|
||||
SSLEngine engine = WebSocketSslServerSslContext.getInstance().getServerContext().createSSLEngine();
|
||||
SSLEngine engine = WebSocketSslServerSslContext.getInstance().serverContext().createSSLEngine();
|
||||
engine.setUseClientMode(false);
|
||||
pipeline.addLast("ssl", new SslHandler(engine));
|
||||
|
||||
|
@ -95,7 +95,7 @@ public final class WebSocketSslServerSslContext {
|
||||
/**
|
||||
* Returns the server context with server side key store
|
||||
*/
|
||||
public SSLContext getServerContext() {
|
||||
public SSLContext serverContext() {
|
||||
return _serverContext;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class SecureChatServerHandler extends ChannelInboundMessageHandlerAdapter
|
||||
" secure chat service!\n");
|
||||
ctx.write(
|
||||
"Your session is protected by " +
|
||||
ctx.pipeline().get(SslHandler.class).getEngine().getSession().getCipherSuite() +
|
||||
ctx.pipeline().get(SslHandler.class).engine().getSession().getCipherSuite() +
|
||||
" cipher suite.\n");
|
||||
|
||||
channels.add(ctx.channel());
|
||||
|
@ -49,7 +49,7 @@ public final class SocksServerConnectHandler extends ChannelInboundMessageHandle
|
||||
CallbackNotifier cb = new CallbackNotifier() {
|
||||
@Override
|
||||
public void onSuccess(final ChannelHandlerContext outboundCtx) {
|
||||
ctx.channel().write(new SocksCmdResponse(SocksMessage.CmdStatus.SUCCESS, request.getAddressType()))
|
||||
ctx.channel().write(new SocksCmdResponse(SocksMessage.CmdStatus.SUCCESS, request.addressType()))
|
||||
.addListener(new ChannelFutureListener() {
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture channelFuture) throws Exception {
|
||||
@ -62,7 +62,7 @@ public final class SocksServerConnectHandler extends ChannelInboundMessageHandle
|
||||
|
||||
@Override
|
||||
public void onFailure(ChannelHandlerContext outboundCtx, Throwable cause) {
|
||||
ctx.channel().write(new SocksCmdResponse(SocksMessage.CmdStatus.FAILURE, request.getAddressType()));
|
||||
ctx.channel().write(new SocksCmdResponse(SocksMessage.CmdStatus.FAILURE, request.addressType()));
|
||||
SocksServerUtils.closeOnFlush(ctx.channel());
|
||||
}
|
||||
};
|
||||
@ -73,7 +73,7 @@ public final class SocksServerConnectHandler extends ChannelInboundMessageHandle
|
||||
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
|
||||
.option(ChannelOption.SO_KEEPALIVE, true)
|
||||
.handler(new DirectClientInitializer(cb))
|
||||
.remoteAddress(request.getHost(), request.getPort());
|
||||
.remoteAddress(request.host(), request.port());
|
||||
b.connect();
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,12 @@ package io.netty.example.socksproxy;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||
import io.netty.handler.codec.socks.SocksAuthResponse;
|
||||
import io.netty.handler.codec.socks.SocksCmdRequest;
|
||||
import io.netty.handler.codec.socks.SocksCmdRequestDecoder;
|
||||
import io.netty.handler.codec.socks.SocksInitResponse;
|
||||
import io.netty.handler.codec.socks.SocksMessage;
|
||||
import io.netty.handler.codec.socks.SocksRequest;
|
||||
import io.netty.handler.codec.socks.SocksAuthResponse;
|
||||
import io.netty.handler.codec.socks.SocksCmdRequest;
|
||||
|
||||
|
||||
@ChannelHandler.Sharable
|
||||
@ -40,7 +40,7 @@ public final class SocksServerHandler extends ChannelInboundMessageHandlerAdapte
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, SocksRequest socksRequest) throws Exception {
|
||||
switch (socksRequest.getSocksRequestType()) {
|
||||
switch (socksRequest.requestType()) {
|
||||
case INIT: {
|
||||
// auth support example
|
||||
// ctx.pipeline().addFirst("socksAuthRequestDecoder",new SocksAuthRequestDecoder());
|
||||
@ -55,7 +55,7 @@ public final class SocksServerHandler extends ChannelInboundMessageHandlerAdapte
|
||||
break;
|
||||
case CMD:
|
||||
SocksCmdRequest req = (SocksCmdRequest) socksRequest;
|
||||
if (req.getCmdType() == SocksMessage.CmdType.CONNECT) {
|
||||
if (req.cmdType() == SocksMessage.CmdType.CONNECT) {
|
||||
ctx.pipeline().addLast(SocksServerConnectHandler.getName(), new SocksServerConnectHandler());
|
||||
ctx.pipeline().remove(this);
|
||||
ctx.nextInboundMessageBuffer().add(socksRequest);
|
||||
|
@ -268,7 +268,7 @@ public class SslHandler
|
||||
/**
|
||||
* Returns the {@link SSLEngine} which is used by this handler.
|
||||
*/
|
||||
public SSLEngine getEngine() {
|
||||
public SSLEngine engine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
@ -263,8 +263,8 @@ public abstract class AbstractTrafficShapingHandler extends ChannelHandlerAdapte
|
||||
|
||||
// compute the number of ms to wait before reopening the channel
|
||||
long wait = getTimeToWait(readLimit,
|
||||
trafficCounter.getCurrentReadBytes(),
|
||||
trafficCounter.getLastTime(), curtime);
|
||||
trafficCounter.currentReadBytes(),
|
||||
trafficCounter.lastTime(), curtime);
|
||||
if (wait >= MINIMAL_WAIT) { // At least 10ms seems a minimal
|
||||
// time in order to
|
||||
// try to limit the traffic
|
||||
@ -324,8 +324,8 @@ public abstract class AbstractTrafficShapingHandler extends ChannelHandlerAdapte
|
||||
// compute the number of ms to wait before continue with the
|
||||
// channel
|
||||
long wait = getTimeToWait(writeLimit,
|
||||
trafficCounter.getCurrentWrittenBytes(),
|
||||
trafficCounter.getLastTime(), curtime);
|
||||
trafficCounter.currentWrittenBytes(),
|
||||
trafficCounter.lastTime(), curtime);
|
||||
if (wait >= MINIMAL_WAIT) {
|
||||
ctx.executor().schedule(new Runnable() {
|
||||
@Override
|
||||
@ -344,7 +344,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelHandlerAdapte
|
||||
* @return the current TrafficCounter (if
|
||||
* channel is still connected)
|
||||
*/
|
||||
public TrafficCounter getTrafficCounter() {
|
||||
public TrafficCounter trafficCounter() {
|
||||
return trafficCounter;
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ public class TrafficCounter {
|
||||
* @return the current checkInterval between two computations of traffic counter
|
||||
* in millisecond
|
||||
*/
|
||||
public long getCheckInterval() {
|
||||
public long checkInterval() {
|
||||
return checkInterval.get();
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ public class TrafficCounter {
|
||||
*
|
||||
* @return the Read Throughput in bytes/s computes in the last check interval
|
||||
*/
|
||||
public long getLastReadThroughput() {
|
||||
public long lastReadThroughput() {
|
||||
return lastReadThroughput;
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ public class TrafficCounter {
|
||||
*
|
||||
* @return the Write Throughput in bytes/s computes in the last check interval
|
||||
*/
|
||||
public long getLastWriteThroughput() {
|
||||
public long lastWriteThroughput() {
|
||||
return lastWriteThroughput;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ public class TrafficCounter {
|
||||
*
|
||||
* @return the number of bytes read during the last check Interval
|
||||
*/
|
||||
public long getLastReadBytes() {
|
||||
public long lastReadBytes() {
|
||||
return lastReadBytes;
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ public class TrafficCounter {
|
||||
*
|
||||
* @return the number of bytes written during the last check Interval
|
||||
*/
|
||||
public long getLastWrittenBytes() {
|
||||
public long lastWrittenBytes() {
|
||||
return lastWrittenBytes;
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ public class TrafficCounter {
|
||||
*
|
||||
* @return the current number of bytes read since the last checkInterval
|
||||
*/
|
||||
public long getCurrentReadBytes() {
|
||||
public long currentReadBytes() {
|
||||
return currentReadBytes.get();
|
||||
}
|
||||
|
||||
@ -330,28 +330,28 @@ public class TrafficCounter {
|
||||
*
|
||||
* @return the current number of bytes written since the last check Interval
|
||||
*/
|
||||
public long getCurrentWrittenBytes() {
|
||||
public long currentWrittenBytes() {
|
||||
return currentWrittenBytes.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Time in millisecond of the last check as of System.currentTimeMillis()
|
||||
*/
|
||||
public long getLastTime() {
|
||||
public long lastTime() {
|
||||
return lastTime.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cumulativeWrittenBytes
|
||||
*/
|
||||
public long getCumulativeWrittenBytes() {
|
||||
public long cumulativeWrittenBytes() {
|
||||
return cumulativeWrittenBytes.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cumulativeReadBytes
|
||||
*/
|
||||
public long getCumulativeReadBytes() {
|
||||
public long cumulativeReadBytes() {
|
||||
return cumulativeReadBytes.get();
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ public class TrafficCounter {
|
||||
* @return the lastCumulativeTime in millisecond as of System.currentTimeMillis()
|
||||
* when the cumulative counters were reset to 0.
|
||||
*/
|
||||
public long getLastCumulativeTime() {
|
||||
public long lastCumulativeTime() {
|
||||
return lastCumulativeTime;
|
||||
}
|
||||
|
||||
@ -375,7 +375,7 @@ public class TrafficCounter {
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class RxtxChannel extends AbstractOioByteChannel {
|
||||
@Override
|
||||
protected void doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
|
||||
RxtxDeviceAddress remote = (RxtxDeviceAddress) remoteAddress;
|
||||
final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.getDeviceAddress());
|
||||
final CommPortIdentifier cpi = CommPortIdentifier.getPortIdentifier(remote.value());
|
||||
final CommPort commPort = cpi.open(getClass().getName(), 1000);
|
||||
|
||||
deviceAddress = remote;
|
||||
|
@ -25,21 +25,21 @@ public class RxtxDeviceAddress extends SocketAddress {
|
||||
|
||||
private static final long serialVersionUID = -2907820090993709523L;
|
||||
|
||||
private final String deviceAddress;
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
* Creates a RxtxDeviceAddress representing the address of the serial port.
|
||||
*
|
||||
* @param deviceAddress the address of the device (e.g. COM1, /dev/ttyUSB0, ...)
|
||||
* @param value the address of the device (e.g. COM1, /dev/ttyUSB0, ...)
|
||||
*/
|
||||
public RxtxDeviceAddress(String deviceAddress) {
|
||||
this.deviceAddress = deviceAddress;
|
||||
public RxtxDeviceAddress(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The serial port address of the device (e.g. COM1, /dev/ttyUSB0, ...)
|
||||
*/
|
||||
public String getDeviceAddress() {
|
||||
return deviceAddress;
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public interface ChannelGroupFuture extends Iterable<ChannelFuture> {
|
||||
/**
|
||||
* Returns the {@link ChannelGroup} which is associated with this future.
|
||||
*/
|
||||
ChannelGroup getGroup();
|
||||
ChannelGroup group();
|
||||
|
||||
/**
|
||||
* Returns the {@link ChannelFuture} of the individual I/O operation which
|
||||
|
@ -115,7 +115,7 @@ public class DefaultChannelGroupFuture implements ChannelGroupFuture {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelGroup getGroup() {
|
||||
public ChannelGroup group() {
|
||||
return group;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user