undertow-core-2.0.13.Final.jar
登录
|
io.undertow:undertow-core:2.0.13.Final
io
undertow
io
UndertowOptions.java
security
protocols
conduits
predicate
connector
util
PathTemplate.java
Headers.java
NewInstanceObjectPool.java
SubstringMap.java
Methods.java
SimpleAttachmentKey.java
HeaderToken.java
NetworkUtils.java
ByteRange.java
StringReadChannelListener.java
CopyOnWriteMap.java
WorkerUtils.java
CanonicalPathUtils.java
ImmediatePooled.java
URLUtils.java
StringWriteChannelListener.java
StatusCodes.java
Attachable.java
LegacyCookieSupport.java
QValueParser.java
ConduitFactory.java
ImmediatePooledByteBuffer.java
ChainedHandlerWrapper.java
RedirectBuilder.java
ImmediateConduitFactory.java
ETag.java
LocaleUtils.java
Cookies.java
MimeMappings.java
Transfer.java
PooledAdaptor.java
HeaderMap.java
FileUtils.java
MalformedMessageException.java
ParameterLimitException.java
ETagUtils.java
ConnectionUtils.java
AttachmentKey.java
Rfc6265CookieSupport.java
Protocols.java
PathTemplateMatch.java
Certificates.java
PathMatcher.java
HeaderValues.java
PooledObject.java
ClosingChannelExceptionHandler.java
AbstractAttachable.java
MultipartParser.java
Sessions.java
FlexBase64.java
BadRequestException.java
HeaderTokenParser.java
PathTemplateMatcher.java
AttachmentList.java
HttpString.java
SimpleObjectPool.java
ImmediateAuthenticationMechanismFactory.java
HexConverter.java
FastConcurrentDirectDeque.java
SameThreadExecutor.java
ConcurrentDirectDeque.java
ObjectPool.java
PipeliningExecutor.java
PortableConcurrentDirectDeque.java
DateUtils.java
ReferenceCountedPooled.java
QueryParameterUtils.java
Version.java
Undertow.java
UndertowLogger.java
version.properties
channels
UndertowLogger_$logger.java
server
attribute
UndertowMessages_$bundle.java
Handlers.java
client
websockets
UndertowMessages.java
META-INF
NetworkUtils.java
清空
类结构
/* * JBoss, Home of Professional Open Source. * Copyright 2014 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.undertow.util; import io.undertow.
UndertowMessages
; import java.io.
IOException
; import java.net.
InetAddress
; /** * @author Stuart Douglas */ public class
NetworkUtils
{ public static
String
formatPossibleIpv6Address
(
String
address
) { if (
address
== null) { return null; } if (!
address
.
contains
(":")) { return
address
; } if (
address
.
startsWith
("[") &&
address
.
endsWith
("]")) { return
address
; } return "[" +
address
+ "]"; } public static
InetAddress
parseIpv4Address
(
String
addressString
) throws
IOException
{
String
[]
parts
=
addressString
.
split
("\\."); if (
parts
.length != 4) { throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); } byte[]
data
= new byte[4]; for (int
i
= 0;
i
< 4; ++
i
) {
String
part
=
parts
[
i
]; if (
part
.
length
() == 0 || (
part
.
charAt
(0) == '0' &&
part
.
length
() > 1)) { //leading zeros are not allowed throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); }
data
[
i
] = (byte)
Integer
.
parseInt
(
part
); } return
InetAddress
.
getByAddress
(
data
); } public static
InetAddress
parseIpv6Address
(
String
addressString
) throws
IOException
{ boolean
startsWithColon
=
addressString
.
startsWith
(":"); if (
startsWithColon
&& !
addressString
.
startsWith
("::")) { throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); }
String
[]
parts
= (
startsWithColon
?
addressString
.
substring
(1) :
addressString
).
split
(":"); //because of the way split works we want to change a leading double colon to a single one. We have already verified that the address does not actually start with a single colon byte[]
data
= new byte[16]; int
partOffset
= 0; boolean
seenEmpty
= false; if (
parts
.length > 8) { throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); } for (int
i
= 0;
i
<
parts
.length; ++
i
) {
String
part
=
parts
[
i
]; if (
part
.
length
() > 4) { throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); } else if (
part
.
isEmpty
()) { if (
seenEmpty
) { throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); }
seenEmpty
= true; int
off
= 8 -
parts
.length;//this works because of the empty part that represents the double colon, so the parts list is one larger than the number of digits if (
off
< 0) { throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); }
partOffset
=
off
* 2; } else if (
part
.
length
() > 1 &&
part
.
charAt
(0) == '0') { //leading zeros are not allowed throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); } else { int
num
=
Integer
.
parseInt
(
part
, 16);
data
[
i
* 2 +
partOffset
] = (byte) (
num
>> 8);
data
[
i
* 2 +
partOffset
+ 1] = (byte) (
num
); } } if (
parts
.length < 8 && !
seenEmpty
) { //address was too small throw
UndertowMessages
.
MESSAGES
.
invalidIpAddress
(
addressString
); } return
InetAddress
.
getByAddress
(
data
); } private
NetworkUtils
() { } }
查找资源
Jre/Lib
输入类名或文件名
类结构窗口