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
e5449329
Commit
e5449329
authored
Feb 22, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refine
parent
01fbabb4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
assets/shadowsocks
assets/shadowsocks
+0
-0
jni/shadowsocks/encrypt.c
jni/shadowsocks/encrypt.c
+5
-5
jni/shadowsocks/encrypt.h
jni/shadowsocks/encrypt.h
+1
-1
jni/shadowsocks/local.c
jni/shadowsocks/local.c
+6
-6
No files found.
assets/shadowsocks
View file @
e5449329
No preview for this file type
jni/shadowsocks/encrypt.c
View file @
e5449329
...
...
@@ -11,7 +11,7 @@ static int random_compare(const void *_x, const void *_y) {
return
(
a
%
(
x
+
i
)
-
a
%
(
y
+
i
));
}
static
void
md5
(
const
u
nsigned
char
*
text
,
unsigned
char
*
digest
)
{
static
void
md5
(
const
u
int8_t
*
text
,
uint8_t
*
digest
)
{
md5_state_t
state
;
md5_init
(
&
state
);
md5_append
(
&
state
,
text
,
strlen
((
char
*
)
text
));
...
...
@@ -119,7 +119,7 @@ static void merge_sort(uint8_t array[], int length) {
void
encrypt
(
char
*
buf
,
int
len
,
struct
rc4_state
*
ctx
)
{
if
(
ctx
!=
NULL
)
{
rc4_crypt
(
ctx
,
(
u
nsigned
char
*
)
buf
,
(
unsigned
char
*
)
buf
,
len
);
rc4_crypt
(
ctx
,
(
u
int8_t
*
)
buf
,
(
uint8_t
*
)
buf
,
len
);
}
else
{
char
*
end
=
buf
+
len
;
while
(
buf
<
end
)
{
...
...
@@ -131,7 +131,7 @@ void encrypt(char *buf, int len, struct rc4_state *ctx) {
void
decrypt
(
char
*
buf
,
int
len
,
struct
rc4_state
*
ctx
)
{
if
(
ctx
!=
NULL
)
{
rc4_crypt
(
ctx
,
(
u
nsigned
char
*
)
buf
,
(
unsigned
char
*
)
buf
,
len
);
rc4_crypt
(
ctx
,
(
u
int8_t
*
)
buf
,
(
uint8_t
*
)
buf
,
len
);
}
else
{
char
*
end
=
buf
+
len
;
while
(
buf
<
end
)
{
...
...
@@ -150,7 +150,7 @@ void enc_ctx_init(struct rc4_state *ctx, int enc) {
void
enc_key_init
(
const
char
*
pass
)
{
enc_ctx
.
rc4
.
key_len
=
16
;
enc_ctx
.
rc4
.
key
=
malloc
(
16
);
md5
((
const
u
nsigned
char
*
)
pass
,
enc_ctx
.
rc4
.
key
);
md5
((
const
u
int8_t
*
)
pass
,
enc_ctx
.
rc4
.
key
);
}
void
get_table
(
const
char
*
pass
)
{
...
...
@@ -159,7 +159,7 @@ void get_table(const char *pass) {
uint8_t
digest
[
16
];
uint32_t
i
;
md5
((
const
u
nsigned
char
*
)
pass
,
digest
);
md5
((
const
u
int8_t
*
)
pass
,
digest
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
_a
+=
OFFSET_ROL
(
digest
,
i
);
...
...
jni/shadowsocks/encrypt.h
View file @
e5449329
...
...
@@ -21,7 +21,7 @@ union {
}
table
;
struct
{
u
nsigned
char
*
key
;
u
int8_t
*
key
;
int
key_len
;
}
rc4
;
}
enc_ctx
;
...
...
jni/shadowsocks/local.c
View file @
e5449329
...
...
@@ -30,14 +30,14 @@ static char *_remote_port;
static
int
_timeout
;
static
char
*
_key
;
int
setnonblocking
(
int
fd
)
{
static
int
setnonblocking
(
int
fd
)
{
int
flags
;
if
(
-
1
==
(
flags
=
fcntl
(
fd
,
F_GETFL
,
0
)))
flags
=
0
;
return
fcntl
(
fd
,
F_SETFL
,
flags
|
O_NONBLOCK
);
}
int
create_and_bind
(
const
char
*
port
)
{
static
int
create_and_bind
(
const
char
*
port
)
{
struct
addrinfo
hints
;
struct
addrinfo
*
result
,
*
rp
;
int
s
,
listen_sock
;
...
...
@@ -178,7 +178,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) {
}
char
addr_to_send
[
256
];
u
nsigned
char
addr_len
=
0
;
u
int8_t
addr_len
=
0
;
addr_to_send
[
addr_len
++
]
=
request
->
atyp
;
// get remote addr and port
...
...
@@ -191,14 +191,14 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) {
}
else
if
(
request
->
atyp
==
3
)
{
// Domain name
u
nsigned
char
name_len
=
*
(
unsigned
char
*
)(
server
->
buf
+
4
);
u
int8_t
name_len
=
*
(
uint8_t
*
)(
server
->
buf
+
4
);
addr_to_send
[
addr_len
++
]
=
name_len
;
memcpy
(
addr_to_send
+
addr_len
,
server
->
buf
+
4
+
1
,
name_len
);
addr_len
+=
name_len
;
// get port
addr_to_send
[
addr_len
++
]
=
*
(
u
nsigned
char
*
)(
server
->
buf
+
4
+
1
+
name_len
);
addr_to_send
[
addr_len
++
]
=
*
(
u
nsigned
char
*
)(
server
->
buf
+
4
+
1
+
name_len
+
1
);
addr_to_send
[
addr_len
++
]
=
*
(
u
int8_t
*
)(
server
->
buf
+
4
+
1
+
name_len
);
addr_to_send
[
addr_len
++
]
=
*
(
u
int8_t
*
)(
server
->
buf
+
4
+
1
+
name_len
+
1
);
}
else
{
LOGE
(
"unsupported addrtype: %d
\n
"
,
request
->
atyp
);
close_and_free_remote
(
EV_A_
remote
);
...
...
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