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
8ece167f
Commit
8ece167f
authored
Jun 27, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add missing files
parent
aa711425
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
0 deletions
+135
-0
jni/main-jni.cpp
jni/main-jni.cpp
+84
-0
src/main/java/com/github/shadowsocks/Core.java
src/main/java/com/github/shadowsocks/Core.java
+51
-0
No files found.
jni/main-jni.cpp
0 → 100644
View file @
8ece167f
#include <jni.h>
#include <string.h>
#include <unistd.h>
typedef
unsigned
short
char16_t
;
class
String8
{
public:
String8
()
{
mString
=
0
;
}
~
String8
()
{
if
(
mString
)
{
free
(
mString
);
}
}
void
set
(
const
char16_t
*
o
,
size_t
numChars
)
{
if
(
mString
)
{
free
(
mString
);
}
mString
=
(
char
*
)
malloc
(
numChars
+
1
);
if
(
!
mString
)
{
return
;
}
for
(
size_t
i
=
0
;
i
<
numChars
;
i
++
)
{
mString
[
i
]
=
(
char
)
o
[
i
];
}
mString
[
numChars
]
=
'\0'
;
}
const
char
*
string
()
{
return
mString
;
}
private:
char
*
mString
;
};
extern
"C"
{
int
main
(
int
argc
,
char
*
args
[]);
#if defined(PDNSD_JNI)
jint
Java_com_github_shadowsocks_Core_pdnsd
(
JNIEnv
*
env
,
jobject
thiz
,
jobjectArray
argv
)
{
#elif defined(SSLOCAL_JNI)
jint
Java_com_github_shadowsocks_Core_sslocal
(
JNIEnv
*
env
,
jobject
thiz
,
jobjectArray
argv
)
{
#elif defined(SSTUNNEL_JNI)
jint
Java_com_github_shadowsocks_Core_sstunnel
(
JNIEnv
*
env
,
jobject
thiz
,
jobjectArray
argv
)
{
#elif defined(TUN2SOCKS_JNI)
jint
Java_com_github_shadowsocks_Core_tun2socks
(
JNIEnv
*
env
,
jobject
thiz
,
jobjectArray
argv
)
{
#else
#error "invalid header"
#endif
int
argc
=
argv
?
env
->
GetArrayLength
(
argv
)
:
0
;
char
**
args
=
NULL
;
String8
tmp_8
;
if
(
argc
>
0
)
{
args
=
(
char
**
)
malloc
((
argc
+
1
)
*
sizeof
(
char
*
));
for
(
int
i
=
0
;
i
<
argc
;
++
i
)
{
jstring
arg
=
reinterpret_cast
<
jstring
>
(
env
->
GetObjectArrayElement
(
argv
,
i
));
const
jchar
*
str
=
env
->
GetStringCritical
(
arg
,
0
);
tmp_8
.
set
(
str
,
env
->
GetStringLength
(
arg
));
env
->
ReleaseStringCritical
(
arg
,
str
);
args
[
i
]
=
strdup
(
tmp_8
.
string
());
}
args
[
argc
]
=
NULL
;
pid_t
pid
;
pid
=
fork
();
if
(
pid
==
0
)
{
int
ret
=
main
(
argc
,
args
);
return
ret
;
}
if
(
args
!=
NULL
)
free
(
args
);
}
return
0
;
}
}
src/main/java/com/github/shadowsocks/Core.java
0 → 100755
View file @
8ece167f
/* Shadowsocks - A shadowsocks client for Android
* Copyright (C) 2012 <max.c.lv@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
* ___====-_ _-====___
* _--^^^#####// \\#####^^^--_
* _-^##########// ( ) \\##########^-_
* -############// |\^^/| \\############-
* _/############// (@::@) \\############\_
* /#############(( \\// ))#############\
* -###############\\ (oo) //###############-
* -#################\\ / VV \ //#################-
* -###################\\/ \//###################-
* _#/|##########/\######( /\ )######/\##########|\#_
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
* ` ` ` ` / | | | | \ ' ' ' '
* ( | | | | )
* __\ | | | | /__
* (vvv(VVV)(VVV)vvv)
*
* HERE BE DRAGONS
*
*/
package
com.github.shadowsocks
;
public
class
Core
{
static
{
java
.
lang
.
System
.
loadLibrary
(
"ss-local-jni"
);
java
.
lang
.
System
.
loadLibrary
(
"tun2socks-jni"
);
java
.
lang
.
System
.
loadLibrary
(
"pdnsd-jni"
);
}
public
static
native
void
sslocal
(
String
[]
cmd
);
public
static
native
void
tun2socks
(
String
[]
cmd
);
public
static
native
void
pdnsd
(
String
[]
cmd
);
}
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