Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
ea659848
Commit
ea659848
authored
Jan 30, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allocateDirect for NIO
parent
c102406c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
5 deletions
+5
-5
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
...rc/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
+1
-1
core/src/main/java/com/github/shadowsocks/net/Socks5Endpoint.kt
...rc/main/java/com/github/shadowsocks/net/Socks5Endpoint.kt
+4
-4
No files found.
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
View file @
ea659848
...
...
@@ -72,7 +72,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
configureBlocking
(
false
)
socket
().
bind
(
listen
)
monitor
.
register
(
this
,
SelectionKey
.
OP_READ
)
{
val
buffer
=
ByteBuffer
.
allocate
(
UDP_PACKET_SIZE
)
val
buffer
=
ByteBuffer
.
allocate
Direct
(
UDP_PACKET_SIZE
)
val
source
=
receive
(
buffer
)
!!
buffer
.
flip
()
launch
{
...
...
core/src/main/java/com/github/shadowsocks/net/Socks5Endpoint.kt
View file @
ea659848
...
...
@@ -49,7 +49,7 @@ class Socks5Endpoint(host: String, port: Int) {
fun
tcpWrap
(
message
:
ByteBuffer
):
ByteBuffer
{
check
(
message
.
remaining
()
<
65536
)
{
"TCP message too large"
}
return
ByteBuffer
.
allocate
(
8
+
dest
.
size
+
message
.
remaining
()).
apply
{
return
ByteBuffer
.
allocate
Direct
(
8
+
dest
.
size
+
message
.
remaining
()).
apply
{
put
(
Socks5Message
.
SOCKS_VERSION
.
toByte
())
put
(
1
)
// nmethods
put
(
0
)
// no authentication required
...
...
@@ -64,7 +64,7 @@ class Socks5Endpoint(host: String, port: Int) {
flip
()
}
}
fun
tcpReceiveBuffer
(
size
:
Int
)
=
ByteBuffer
.
allocate
(
headerReserved
+
4
+
size
)
fun
tcpReceiveBuffer
(
size
:
Int
)
=
ByteBuffer
.
allocate
Direct
(
headerReserved
+
4
+
size
)
suspend
fun
tcpUnwrap
(
buffer
:
ByteBuffer
,
reader
:
(
ByteBuffer
)
->
Int
,
wait
:
suspend
()
->
Unit
)
{
suspend
fun
readBytes
(
till
:
Int
)
{
if
(
buffer
.
position
()
>=
till
)
return
...
...
@@ -98,7 +98,7 @@ class Socks5Endpoint(host: String, port: Int) {
buffer
.
reset
()
}
fun
udpWrap
(
packet
:
ByteBuffer
)
=
ByteBuffer
.
allocate
(
3
+
dest
.
size
+
packet
.
remaining
()).
apply
{
fun
udpWrap
(
packet
:
ByteBuffer
)
=
ByteBuffer
.
allocate
Direct
(
3
+
dest
.
size
+
packet
.
remaining
()).
apply
{
// header
putShort
(
0
)
// reserved
put
(
0
)
// fragment number
...
...
@@ -107,7 +107,7 @@ class Socks5Endpoint(host: String, port: Int) {
put
(
packet
)
flip
()
}
fun
udpReceiveBuffer
(
size
:
Int
)
=
ByteBuffer
.
allocate
(
headerReserved
+
size
)
fun
udpReceiveBuffer
(
size
:
Int
)
=
ByteBuffer
.
allocate
Direct
(
headerReserved
+
size
)
fun
udpUnwrap
(
packet
:
ByteBuffer
)
{
packet
.
position
(
3
)
packet
.
position
(
6
+
when
(
packet
.
get
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment