fix: remove test file
This commit is contained in:
parent
72de7de29a
commit
5998959869
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
import 'react-native';
|
||||
import React from 'react';
|
||||
import App from '../App';
|
||||
|
||||
// Note: test renderer must be required after react-native.
|
||||
import renderer from 'react-test-renderer';
|
||||
|
||||
it('renders correctly', () => {
|
||||
renderer.create(<App />);
|
||||
});
|
||||
66
example_rn66/package-lock.json
generated
66
example_rn66/package-lock.json
generated
@ -9,7 +9,8 @@
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"react": "17.0.2",
|
||||
"react-native": "0.67.1"
|
||||
"react-native": "0.67.1",
|
||||
"react-native-tor": "../"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.9",
|
||||
@ -28,6 +29,39 @@
|
||||
"typescript": "^4.4.4"
|
||||
}
|
||||
},
|
||||
"..": {
|
||||
"version": "0.1.7",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/async": "^3.2.6",
|
||||
"async": "^3.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/config-conventional": "^8.3.4",
|
||||
"@react-native-community/bob": "^0.16.2",
|
||||
"@react-native-community/eslint-config": "^2.0.0",
|
||||
"@release-it/conventional-changelog": "^1.1.4",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/react": "^16.9.19",
|
||||
"@types/react-native": "0.62.13",
|
||||
"commitlint": "^8.3.5",
|
||||
"eslint": "^7.2.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^26.0.1",
|
||||
"pod-install": "^0.1.0",
|
||||
"prettier": "^2.0.5",
|
||||
"react": "16.11.0",
|
||||
"react-native": "0.62.2",
|
||||
"release-it": "^13.5.8",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
"version": "7.16.7",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.7.tgz",
|
||||
@ -9923,6 +9957,10 @@
|
||||
"nullthrows": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-tor": {
|
||||
"resolved": "..",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/react-native/node_modules/ws": {
|
||||
"version": "6.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz",
|
||||
@ -19232,6 +19270,32 @@
|
||||
"nullthrows": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"react-native-tor": {
|
||||
"version": "file:..",
|
||||
"requires": {
|
||||
"@commitlint/config-conventional": "^8.3.4",
|
||||
"@react-native-community/bob": "^0.16.2",
|
||||
"@react-native-community/eslint-config": "^2.0.0",
|
||||
"@release-it/conventional-changelog": "^1.1.4",
|
||||
"@types/async": "^3.2.6",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/react": "^16.9.19",
|
||||
"@types/react-native": "0.62.13",
|
||||
"async": "^3.2.0",
|
||||
"commitlint": "^8.3.5",
|
||||
"eslint": "^7.2.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^26.0.1",
|
||||
"pod-install": "^0.1.0",
|
||||
"prettier": "^2.0.5",
|
||||
"react": "16.11.0",
|
||||
"react-native": "0.62.2",
|
||||
"release-it": "^13.5.8",
|
||||
"typescript": "^3.8.3"
|
||||
}
|
||||
},
|
||||
"react-refresh": {
|
||||
"version": "0.4.3",
|
||||
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.4.3.tgz",
|
||||
|
||||
@ -1,24 +1,21 @@
|
||||
import * as React from 'react';
|
||||
import { StyleSheet, View, Text, Button, TextInput } from 'react-native';
|
||||
import {StyleSheet, View, Text, Button, TextInput} from 'react-native';
|
||||
import TorBridge from 'react-native-tor';
|
||||
|
||||
type Await<T> = T extends PromiseLike<infer U> ? U : T;
|
||||
const client = TorBridge();
|
||||
let tcpStream: Await<
|
||||
ReturnType<typeof client['createTcpConnection']>
|
||||
> | null = null;
|
||||
let tcpStream: Await<ReturnType<typeof client['createTcpConnection']>> | null =
|
||||
null;
|
||||
|
||||
export default function App() {
|
||||
const [socksPort, setSocksPort] = React.useState<number | undefined>();
|
||||
const [trustSSL, setTrustSSL] = React.useState<boolean>(true);
|
||||
const [onion, setOnion] = React.useState<string | undefined>(
|
||||
'http://3g2upl4pq6kufc4m.onion'
|
||||
'http://3g2upl4pq6kufc4m.onion',
|
||||
);
|
||||
const [hasStream, setHasStream] = React.useState(false);
|
||||
const [
|
||||
streamConnectionTimeoutMS,
|
||||
setStreamConnectionTimeoutMS,
|
||||
] = React.useState(15000);
|
||||
const [streamConnectionTimeoutMS, setStreamConnectionTimeoutMS] =
|
||||
React.useState(15000);
|
||||
React.useEffect(() => {
|
||||
_init();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@ -82,13 +79,13 @@ export default function App() {
|
||||
if (!onion) throw 'No onion detected';
|
||||
let resp = await client.post(
|
||||
onion,
|
||||
JSON.stringify({ q: 'hello' }),
|
||||
JSON.stringify({q: 'hello'}),
|
||||
{
|
||||
'Content-Type': 'application/json',
|
||||
// also supports
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
trustSSL
|
||||
trustSSL,
|
||||
);
|
||||
console.log('got resp', resp);
|
||||
} catch (err) {
|
||||
@ -118,10 +115,10 @@ export default function App() {
|
||||
'kciybn4d4vuqvobdl2kdp3r2rudqbqvsymqwg4jomzft6m6gaibaf6yd.onion:50001';
|
||||
console.log('starting');
|
||||
const conn = await client.createTcpConnection(
|
||||
{ target, connectionTimeout: timeoutMs || streamConnectionTimeoutMS },
|
||||
{target, connectionTimeout: timeoutMs || streamConnectionTimeoutMS},
|
||||
(data, err) => {
|
||||
console.log('tcp got msg', data, err);
|
||||
}
|
||||
},
|
||||
);
|
||||
console.log('after');
|
||||
tcpStream = conn;
|
||||
@ -156,7 +153,7 @@ export default function App() {
|
||||
{!!socksPort && (
|
||||
<View>
|
||||
<TextInput
|
||||
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
|
||||
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
|
||||
onChangeText={setOnion}
|
||||
value={onion}
|
||||
/>
|
||||
@ -167,8 +164,8 @@ export default function App() {
|
||||
title="Start Tcp Stream"
|
||||
/>
|
||||
<TextInput
|
||||
style={{ height: 40, borderColor: 'gray', borderWidth: 1 }}
|
||||
onChangeText={(x) => setStreamConnectionTimeoutMS(Number(x))}
|
||||
style={{height: 40, borderColor: 'gray', borderWidth: 1}}
|
||||
onChangeText={x => setStreamConnectionTimeoutMS(Number(x))}
|
||||
value={String(streamConnectionTimeoutMS)}
|
||||
/>
|
||||
{hasStream && (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user