1
1
import { RnTor } from 'react-native-nitro-tor' ;
2
-
2
+ export interface RnTor {
3
+ initTorService ( config : {
4
+ socks_port : number
5
+ data_dir : string
6
+ timeout_ms : number
7
+ } ) : Promise < boolean >
8
+
9
+ createHiddenService ( config : {
10
+ port : number
11
+ target_port : number
12
+ } ) : Promise < {
13
+ is_success : boolean
14
+ onion_address : string
15
+ } >
16
+
17
+ getServiceStatus ( ) : Promise < number >
18
+
19
+ shutdownService ( ) : Promise < boolean >
20
+ }
3
21
// Initialize Tor service
4
- const initTor = async ( ) => {
22
+ export const initTor = async ( ) => {
5
23
const initialized = await RnTor . initTorService ( {
6
24
socks_port : 9050 ,
7
25
data_dir : '/path/to/tor/data' ,
@@ -14,9 +32,8 @@ const initTor = async () => {
14
32
}
15
33
return false ;
16
34
} ;
17
-
18
35
// Create a hidden service
19
- const createService = async ( ) => {
36
+ export const createService = async ( ) => {
20
37
const serviceResult = await RnTor . createHiddenService ( {
21
38
port : 9055 ,
22
39
target_port : 9056 ,
@@ -34,13 +51,13 @@ const createService = async () => {
34
51
// 2: Stopped/Not running/error.
35
52
36
53
// Check service status
37
- const checkStatus = async ( ) => {
54
+ export const checkStatus = async ( ) => {
38
55
const status = await RnTor . getServiceStatus ( ) ;
39
56
console . log ( `Current Tor service status: ${ status } ` ) ;
40
57
} ;
41
58
42
59
// Shutdown Tor service
43
- const shutdown = async ( ) => {
60
+ export const shutdown = async ( ) => {
44
61
const result = await RnTor . shutdownService ( ) ;
45
62
console . log ( `Tor shutdown ${ result ? 'successful' : 'failed' } ` ) ;
46
63
} ;
0 commit comments