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
a5014a62
Commit
a5014a62
authored
Jan 08, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new libsystem
parent
ff206e56
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
107 additions
and
20 deletions
+107
-20
jni/Android.mk
jni/Android.mk
+4
-4
jni/node.c
jni/node.c
+0
-10
jni/system.cpp
jni/system.cpp
+97
-0
jni/termExec.cpp
jni/termExec.cpp
+1
-1
libs/armeabi/libexec.so
libs/armeabi/libexec.so
+0
-0
libs/armeabi/libsystem.so
libs/armeabi/libsystem.so
+0
-0
src/com/github/shadowsocks/Exec.java
src/com/github/shadowsocks/Exec.java
+1
-1
src/com/github/shadowsocks/ShadowsocksService.java
src/com/github/shadowsocks/ShadowsocksService.java
+2
-2
src/com/github/shadowsocks/System.java
src/com/github/shadowsocks/System.java
+2
-2
No files found.
jni/Android.mk
View file @
a5014a62
...
...
@@ -61,7 +61,7 @@ include $(BUILD_EXECUTABLE)
include
$(CLEAR_VARS)
LOCAL_MODULE
:=
lib
exec
LOCAL_MODULE
:=
exec
LOCAL_SRC_FILES
:=
\
termExec.cpp
...
...
@@ -72,12 +72,12 @@ include $(BUILD_SHARED_LIBRARY)
include
$(CLEAR_VARS)
LOCAL_MODULE
:=
node
LOCAL_MODULE
:=
system
LOCAL_SRC_FILES
:=
\
node.c
system.cpp
LOCAL_LDLIBS
:=
-ldl
LOCAL_LDLIBS
:=
-ldl
-llog
include
$(BUILD_SHARED_LIBRARY)
...
...
jni/node.c
deleted
100644 → 0
View file @
ff206e56
#include <jni.h>
void
Java_com_github_shadowsocks_Node_exec
(
JNIEnv
*
env
,
jobject
thiz
,
jstring
cmd
)
{
const
char
*
str
=
(
*
env
)
->
GetStringUTFChars
(
env
,
cmd
,
0
);
setenv
(
"LD_LIBRARY_PATH"
,
"/vendor/lib:/system/lib"
,
1
);
setegid
(
getgid
());
seteuid
(
getuid
());
system
(
str
);
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
cmd
,
str
);
}
jni/system.cpp
0 → 100644
View file @
a5014a62
#define LOG_TAG "Shadowsocks"
#include "jni.h"
#include <android/log.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define LOGI(...) do { __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__); } while(0)
#define LOGW(...) do { __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); } while(0)
#define LOGE(...) do { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); } while(0)
void
Java_com_github_shadowsocks_Node_exec
(
JNIEnv
*
env
,
jobject
thiz
,
jstring
cmd
)
{
const
char
*
str
=
env
->
GetStringUTFChars
(
cmd
,
0
);
setenv
(
"LD_LIBRARY_PATH"
,
"/vendor/lib:/system/lib"
,
1
);
setegid
(
getgid
());
seteuid
(
getuid
());
system
(
str
);
env
->
ReleaseStringUTFChars
(
cmd
,
str
);
}
static
const
char
*
classPathName
=
"com/github/shadowsocks/System"
;
static
JNINativeMethod
method_table
[]
=
{
{
"exec"
,
"(Ljava/lang/String;)V"
,
(
void
*
)
Java_com_github_shadowsocks_Node_exec
}
};
/*
* Register several native methods for one class.
*/
static
int
registerNativeMethods
(
JNIEnv
*
env
,
const
char
*
className
,
JNINativeMethod
*
gMethods
,
int
numMethods
)
{
jclass
clazz
;
clazz
=
env
->
FindClass
(
className
);
if
(
clazz
==
NULL
)
{
LOGE
(
"Native registration unable to find class '%s'"
,
className
);
return
JNI_FALSE
;
}
if
(
env
->
RegisterNatives
(
clazz
,
gMethods
,
numMethods
)
<
0
)
{
LOGE
(
"RegisterNatives failed for '%s'"
,
className
);
return
JNI_FALSE
;
}
return
JNI_TRUE
;
}
/*
* Register native methods for all classes we know about.
*
* returns JNI_TRUE on success.
*/
static
int
registerNatives
(
JNIEnv
*
env
)
{
if
(
!
registerNativeMethods
(
env
,
classPathName
,
method_table
,
sizeof
(
method_table
)
/
sizeof
(
method_table
[
0
])))
{
return
JNI_FALSE
;
}
return
JNI_TRUE
;
}
/*
* This is called by the VM when the shared library is first loaded.
*/
typedef
union
{
JNIEnv
*
env
;
void
*
venv
;
}
UnionJNIEnvToVoid
;
jint
JNI_OnLoad
(
JavaVM
*
vm
,
void
*
reserved
)
{
UnionJNIEnvToVoid
uenv
;
uenv
.
venv
=
NULL
;
jint
result
=
-
1
;
JNIEnv
*
env
=
NULL
;
LOGI
(
"JNI_OnLoad"
);
if
(
vm
->
GetEnv
(
&
uenv
.
venv
,
JNI_VERSION_1_4
)
!=
JNI_OK
)
{
LOGE
(
"ERROR: GetEnv failed"
);
goto
bail
;
}
env
=
uenv
.
env
;
if
(
registerNatives
(
env
)
!=
JNI_TRUE
)
{
LOGE
(
"ERROR: registerNatives failed"
);
goto
bail
;
}
result
=
JNI_VERSION_1_4
;
bail:
return
result
;
}
jni/termExec.cpp
View file @
a5014a62
...
...
@@ -30,7 +30,7 @@
* limitations under the License.
*/
#define LOG_TAG "
Exec
"
#define LOG_TAG "
Shadowsocks
"
#include "jni.h"
#include <android/log.h>
...
...
libs/armeabi/libexec.so
View file @
a5014a62
No preview for this file type
libs/armeabi/lib
node
.so
→
libs/armeabi/lib
system
.so
View file @
a5014a62
No preview for this file type
src/com/github/shadowsocks/Exec.java
View file @
a5014a62
...
...
@@ -28,7 +28,7 @@ import java.io.FileDescriptor;
public
class
Exec
{
static
{
System
.
loadLibrary
(
"exec"
);
java
.
lang
.
System
.
loadLibrary
(
"exec"
);
}
/**
...
...
src/com/github/shadowsocks/ShadowsocksService.java
View file @
a5014a62
...
...
@@ -210,7 +210,7 @@ public class ShadowsocksService extends Service {
final
String
cmd
=
String
.
format
(
BASE
+
"shadowsocks -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\""
,
appHost
,
remotePort
,
localPort
,
sitekey
,
encMethod
);
Node
.
exec
(
cmd
);
System
.
exec
(
cmd
);
}
}.
start
();
}
...
...
@@ -222,7 +222,7 @@ public class ShadowsocksService extends Service {
final
String
cmd
=
String
.
format
(
BASE
+
"polipo proxyPort=%d socksParentProxy=127.0.0.1:%d daemonise=true pidFile=\"%s\" logLevel=1 logFile=\"%s\""
,
localPort
+
1
,
localPort
,
BASE
+
"polipo.pid"
,
BASE
+
"polipo.log"
);
Node
.
exec
(
cmd
);
System
.
exec
(
cmd
);
}
}.
start
();
}
...
...
src/com/github/shadowsocks/
Node
.java
→
src/com/github/shadowsocks/
System
.java
View file @
a5014a62
...
...
@@ -38,9 +38,9 @@
package
com.github.shadowsocks
;
public
class
Node
{
public
class
System
{
static
{
System
.
loadLibrary
(
"node
"
);
java
.
lang
.
System
.
loadLibrary
(
"system
"
);
}
public
static
native
void
exec
(
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