File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -148,25 +148,13 @@ pub mod native {
148
148
/// Run the overtls client with config file.
149
149
#[ no_mangle]
150
150
pub unsafe extern "C" fn Java_com_github_shadowsocks_bg_OverTlsWrapper_runClient (
151
- env : JNIEnv ,
151
+ mut env : JNIEnv ,
152
152
class : JClass ,
153
153
vpn_service : JObject ,
154
154
config_path : JString ,
155
155
stat_path : JString ,
156
156
verbosity : jint ,
157
157
) -> jint {
158
- let shutdown_token = crate :: CancellationToken :: new ( ) ;
159
- {
160
- let mut lock = EXITING_FLAG . lock ( ) . unwrap ( ) ;
161
- if lock. is_some ( ) {
162
- log:: error!( "tun2proxy already started" ) ;
163
- return -1 ;
164
- }
165
- * lock = Some ( shutdown_token. clone ( ) ) ;
166
- }
167
-
168
- let mut env = env;
169
-
170
158
let log_level = ArgVerbosity :: try_from ( verbosity) . unwrap ( ) . to_string ( ) ;
171
159
let root = module_path ! ( ) . split ( "::" ) . next ( ) . unwrap ( ) ;
172
160
let filter_str = & format ! ( "off,{root}={log_level}" ) ;
@@ -178,10 +166,22 @@ pub mod native {
178
166
. with_filter ( filter) ,
179
167
) ;
180
168
169
+ log:: info!( "Starting overtls client on Android" ) ;
170
+
171
+ let shutdown_token = crate :: CancellationToken :: new ( ) ;
172
+ {
173
+ let mut lock = EXITING_FLAG . lock ( ) . unwrap ( ) ;
174
+ if lock. is_some ( ) {
175
+ log:: error!( "overtls already started" ) ;
176
+ return -1 ;
177
+ }
178
+ * lock = Some ( shutdown_token. clone ( ) ) ;
179
+ }
180
+
181
181
let block = || -> Result < ( ) > {
182
182
if let Ok ( stat_path) = get_java_string ( & mut env, & stat_path) {
183
- let mut stat = STAT_PATH . write ( ) . unwrap ( ) ;
184
- * stat = stat_path. to_owned ( ) ;
183
+ let mut stat = STAT_PATH . write ( ) . map_err ( |e| Error :: from ( e . to_string ( ) ) ) ? ;
184
+ * stat = stat_path;
185
185
}
186
186
let config_path = get_java_string ( & mut env, & config_path) ?. to_owned ( ) ;
187
187
set_panic_handler ( ) ;
You can’t perform that action at this time.
0 commit comments