Skip to content

Commit 41e7ca2

Browse files
committed
Fix Tor backend
1 parent 7cb2ce7 commit 41e7ca2

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

src/app/ip/tor/client.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
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+
}
321
// Initialize Tor service
4-
const initTor = async () => {
22+
export const initTor = async () => {
523
const initialized = await RnTor.initTorService({
624
socks_port: 9050,
725
data_dir: '/path/to/tor/data',
@@ -14,9 +32,8 @@ const initTor = async () => {
1432
}
1533
return false;
1634
};
17-
1835
// Create a hidden service
19-
const createService = async () => {
36+
export const createService = async () => {
2037
const serviceResult = await RnTor.createHiddenService({
2138
port: 9055,
2239
target_port: 9056,
@@ -34,13 +51,13 @@ const createService = async () => {
3451
// 2: Stopped/Not running/error.
3552

3653
// Check service status
37-
const checkStatus = async () => {
54+
export const checkStatus = async () => {
3855
const status = await RnTor.getServiceStatus();
3956
console.log(`Current Tor service status: ${status}`);
4057
};
4158

4259
// Shutdown Tor service
43-
const shutdown = async () => {
60+
export const shutdown = async () => {
4461
const result = await RnTor.shutdownService();
4562
console.log(`Tor shutdown ${result ? 'successful' : 'failed'}`);
4663
};

0 commit comments

Comments
 (0)