jointhis.proxy 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.js +18 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +97 -0
- package/dist/error.d.ts +6 -0
- package/dist/error.js +7 -0
- package/dist/guide.d.ts +2 -0
- package/dist/guide.js +32 -0
- package/dist/main.d.ts +6 -0
- package/dist/main.js +88 -0
- package/dist/tunnel.d.ts +9 -0
- package/dist/tunnel.js +27 -0
- package/dist/ui.d.ts +2 -0
- package/dist/ui.js +42 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# jointhis.proxy
|
|
2
|
+
|
|
3
|
+
Jointhis.party proxy client CLI tool.
|
|
4
|
+
|
|
5
|
+
## Running in development:
|
|
6
|
+
|
|
7
|
+
```zsh
|
|
8
|
+
pnpm build > /dev/null && node ./dist/cli.js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
$ npm install --global jointhis.proxy
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## CLI
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
Usage
|
|
21
|
+
$ jointhis.proxy
|
|
22
|
+
|
|
23
|
+
Options
|
|
24
|
+
--port Internal port to assign.
|
|
25
|
+
--key Authentication key.
|
|
26
|
+
--subdomain Jointhis.party subdomain to assign.
|
|
27
|
+
--service Service to host, for example: minecraft -> mc
|
|
28
|
+
|
|
29
|
+
Examples
|
|
30
|
+
$ jointhis.proxy --key "3002348970847937423423" --subdomain "mycoolserver" --service "mc"
|
|
31
|
+
|
|
32
|
+
For interactive setup, just ru:
|
|
33
|
+
$ jointhis.proxy
|
|
34
|
+
```
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type Props = {
|
|
3
|
+
port: number | undefined;
|
|
4
|
+
key: string | undefined;
|
|
5
|
+
subdomain: string | undefined;
|
|
6
|
+
service: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
export default function App({ port, key, subdomain, service }: Props): React.JSX.Element;
|
|
9
|
+
export {};
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
import { Box } from 'ink';
|
|
4
|
+
export default function App({ port, key, subdomain, service }) {
|
|
5
|
+
if (port || key || subdomain || service) {
|
|
6
|
+
if (!key) {
|
|
7
|
+
return React.createElement(Text, { color: 'red' }, "Authentication missing.");
|
|
8
|
+
}
|
|
9
|
+
if (!port && !service) {
|
|
10
|
+
return React.createElement(Text, { color: 'red' }, "No service or port given.");
|
|
11
|
+
}
|
|
12
|
+
return (React.createElement(Box, { margin: 2, width: 100, flexDirection: "column", justifyContent: "center", alignItems: "center" }, "Creating record..."));
|
|
13
|
+
}
|
|
14
|
+
return (React.createElement(Box, { margin: 2, width: 50, flexDirection: "column", justifyContent: "center", alignItems: "center" },
|
|
15
|
+
React.createElement(Text, null, "Welcome to the Jointhis.proxy CLI"),
|
|
16
|
+
React.createElement(Text, null, "---------------------------------"),
|
|
17
|
+
React.createElement(Text, null, "What do you want to do next:")));
|
|
18
|
+
}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render } from 'ink';
|
|
4
|
+
import meow from 'meow';
|
|
5
|
+
import Error from './error.js';
|
|
6
|
+
import UI from './ui.js';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { Spawn } from 'ink-spawn';
|
|
9
|
+
export const version = `0.0.5`;
|
|
10
|
+
const cli = meow(`
|
|
11
|
+
Usage
|
|
12
|
+
$ jointhis.proxy
|
|
13
|
+
|
|
14
|
+
Options
|
|
15
|
+
--tcp Internal TCP port.
|
|
16
|
+
--udp Internal UDP port.
|
|
17
|
+
--key Authentication key.
|
|
18
|
+
--subdomain Jointhis.party subdomain to assign.
|
|
19
|
+
--service Service to host, for example: minecraft -> mc
|
|
20
|
+
|
|
21
|
+
Examples
|
|
22
|
+
$ jointhis.proxy --key=3002348970847937423423 --subdomain=mycoolserver --tcp=25565 --udp=19132
|
|
23
|
+
|
|
24
|
+
For interactive setup, just run:
|
|
25
|
+
$ jointhis.proxy
|
|
26
|
+
`, {
|
|
27
|
+
importMeta: import.meta,
|
|
28
|
+
flags: {
|
|
29
|
+
udp: {
|
|
30
|
+
type: 'number',
|
|
31
|
+
},
|
|
32
|
+
tcp: {
|
|
33
|
+
type: 'number',
|
|
34
|
+
},
|
|
35
|
+
key: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
},
|
|
38
|
+
subdomain: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
},
|
|
41
|
+
service: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
// If any flags are given
|
|
47
|
+
if (cli.flags.udp ||
|
|
48
|
+
cli.flags.tcp ||
|
|
49
|
+
cli.flags.service ||
|
|
50
|
+
cli.flags.key ||
|
|
51
|
+
cli.flags.subdomain) {
|
|
52
|
+
if (!cli.flags.key) {
|
|
53
|
+
render(React.createElement(Error, { message: "Authentication token missing" }));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
if ((!cli.flags.tcp || !cli.flags.udp) && !cli.flags.service) {
|
|
57
|
+
render(React.createElement(Error, { message: "No service or port given." }));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
var tcp;
|
|
61
|
+
var udp;
|
|
62
|
+
if (cli.flags.service == 'mc') {
|
|
63
|
+
tcp = `25565`;
|
|
64
|
+
udp = `19132`;
|
|
65
|
+
}
|
|
66
|
+
else if (cli.flags.service == 'http') {
|
|
67
|
+
tcp = `80`;
|
|
68
|
+
udp = `80`;
|
|
69
|
+
}
|
|
70
|
+
else if (cli.flags.service == 'https') {
|
|
71
|
+
tcp = `443`;
|
|
72
|
+
udp = `443`;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
tcp = cli.flags.tcp;
|
|
76
|
+
udp = cli.flags.udp;
|
|
77
|
+
}
|
|
78
|
+
const response = await fetch(`https://www.jointhis.party/api/cli/${cli.flags.key}/${tcp}/${udp}`);
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
console.error('Error fetching configuration file from remote server.', 'ERROR', response.status);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
throw new Error(`${response.status}`);
|
|
83
|
+
}
|
|
84
|
+
const result = await response.json();
|
|
85
|
+
const config = result.config;
|
|
86
|
+
fs.writeFile('./rtun.yml', config, function (err) {
|
|
87
|
+
if (err) {
|
|
88
|
+
console.log('Unable to write configuration file.');
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
render(React.createElement(Spawn, { maxOutputLines: 4, runningText: "", command: "./rtun-linux-amd64", args: ['-f ./rtun.yml'], shell: true }));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Start automated guide-through
|
|
96
|
+
const { clear } = render(React.createElement(UI, null));
|
|
97
|
+
}
|
package/dist/error.d.ts
ADDED
package/dist/error.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
import { Box } from 'ink';
|
|
4
|
+
export default function Error({ message }) {
|
|
5
|
+
return (React.createElement(Box, { flexDirection: "column", justifyContent: "flex-start", alignItems: "flex-start" },
|
|
6
|
+
React.createElement(Text, { inverse: true, color: 'red' }, message)));
|
|
7
|
+
}
|
package/dist/guide.d.ts
ADDED
package/dist/guide.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
import { Box } from 'ink';
|
|
4
|
+
import { version } from './cli.js';
|
|
5
|
+
import SelectInput from 'ink-select-input';
|
|
6
|
+
import Main from './main.js';
|
|
7
|
+
export default function Guide() {
|
|
8
|
+
const [value, Setvalue] = useState('0');
|
|
9
|
+
const handleSelect = (item) => {
|
|
10
|
+
Setvalue(item.value);
|
|
11
|
+
};
|
|
12
|
+
const items = [
|
|
13
|
+
{
|
|
14
|
+
label: 'Create a tunnel',
|
|
15
|
+
value: '1',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: 'Create a DNS record',
|
|
19
|
+
value: '2',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'Manage your tunnels',
|
|
23
|
+
value: '3',
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
return (React.createElement(Box, { alignSelf: "center", paddingX: 4, paddingY: 1, margin: 0, flexDirection: "column", justifyContent: "center", alignItems: "center", borderStyle: "round" },
|
|
27
|
+
React.createElement(Text, null, "Welcome to the Jointhis.proxy CLI"),
|
|
28
|
+
React.createElement(Text, null, "---------------------------------"),
|
|
29
|
+
React.createElement(Box, { margin: 1, flexDirection: "column", justifyContent: "flex-start", alignItems: "flex-start" }, value == '0' ? (React.createElement(SelectInput, { onSelect: handleSelect, items: items })) : (React.createElement(Main, { view: value }))),
|
|
30
|
+
React.createElement(Text, null, "---------------------------------"),
|
|
31
|
+
React.createElement(Text, { dimColor: true }, `Jointhis.proxy CLI V${version}`)));
|
|
32
|
+
}
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
import TextInput from 'ink-text-input';
|
|
4
|
+
import { Stepper, Step } from 'ink-stepper';
|
|
5
|
+
import SelectInput from 'ink-select-input';
|
|
6
|
+
import { Box } from 'ink';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { Spawn } from 'ink-spawn';
|
|
9
|
+
export default function Main({ view }) {
|
|
10
|
+
const [key, Setkey] = useState('');
|
|
11
|
+
const [sub, Setsub] = useState('');
|
|
12
|
+
const [service, Setservice] = useState('');
|
|
13
|
+
const [fetchSuccess, Setsuccess] = useState(false);
|
|
14
|
+
const services = [
|
|
15
|
+
{
|
|
16
|
+
label: 'MC',
|
|
17
|
+
value: '1',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: 'Web (http)',
|
|
21
|
+
value: '2',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'web (https)',
|
|
25
|
+
value: '3',
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
const handleSelect = (item) => {
|
|
29
|
+
Setservice(item.value);
|
|
30
|
+
getConfig(key, item.value);
|
|
31
|
+
};
|
|
32
|
+
switch (view) {
|
|
33
|
+
case '1': {
|
|
34
|
+
return (React.createElement(Stepper, { showProgress: false, onComplete: () => process.exit(0), onCancel: () => process.exit(1) },
|
|
35
|
+
React.createElement(Step, { name: "auth" },
|
|
36
|
+
React.createElement(Text, null, "Please input your authentication key:"),
|
|
37
|
+
React.createElement(TextInput, { value: key, onChange: Setkey, showCursor: true, mask: "*" })),
|
|
38
|
+
React.createElement(Step, { name: "select service" },
|
|
39
|
+
React.createElement(Text, null, "Select a service:"),
|
|
40
|
+
React.createElement(SelectInput, { onSelect: handleSelect, items: services }),
|
|
41
|
+
React.createElement(Text, null, "For custom, use the CLI flags.")),
|
|
42
|
+
React.createElement(Step, { name: "last" },
|
|
43
|
+
React.createElement(Spawn, { maxOutputLines: 4, runningText: "", command: "./rtun-linux-amd64", args: ['-f ./rtun.yml'], shell: true }),
|
|
44
|
+
React.createElement(Box, { marginTop: 1 },
|
|
45
|
+
React.createElement(Text, { dimColor: true }, "Press enter to quit")))));
|
|
46
|
+
}
|
|
47
|
+
case '2': {
|
|
48
|
+
return React.createElement(Text, null, "Creating DNS record...");
|
|
49
|
+
}
|
|
50
|
+
default: {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function getConfig(token, service) {
|
|
56
|
+
var tcp;
|
|
57
|
+
var udp;
|
|
58
|
+
if (service == '1') {
|
|
59
|
+
tcp = `25565`;
|
|
60
|
+
udp = `19132`;
|
|
61
|
+
}
|
|
62
|
+
else if (service == '2') {
|
|
63
|
+
tcp = `80`;
|
|
64
|
+
udp = `80`;
|
|
65
|
+
}
|
|
66
|
+
else if (service == '3') {
|
|
67
|
+
tcp = `443`;
|
|
68
|
+
udp = `443`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
tcp = `25565`;
|
|
72
|
+
udp = `19132`;
|
|
73
|
+
}
|
|
74
|
+
const response = await fetch(`https://www.jointhis.party/api/cli/${token}/${tcp}/${udp}`);
|
|
75
|
+
if (!response.ok) {
|
|
76
|
+
console.error('Error fetching configuration file from remote server.', 'ERROR', response.status);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
throw new Error(`${response.status}`);
|
|
79
|
+
}
|
|
80
|
+
const result = await response.json();
|
|
81
|
+
const config = result.config;
|
|
82
|
+
fs.writeFile('./rtun.yml', config, function (err) {
|
|
83
|
+
if (err) {
|
|
84
|
+
console.log('Unable to write configuration file.');
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
package/dist/tunnel.d.ts
ADDED
package/dist/tunnel.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Box, Text } from 'ink';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export default function Status({ authkey, sub, service, port }) {
|
|
4
|
+
return (React.createElement(Box, { marginBottom: -1, flexDirection: "column" },
|
|
5
|
+
React.createElement(Text, { color: "green" },
|
|
6
|
+
"Tunnel running on port",
|
|
7
|
+
' ',
|
|
8
|
+
React.createElement(Text, { bold: true },
|
|
9
|
+
22 /* placeholder */,
|
|
10
|
+
" |",
|
|
11
|
+
' ',
|
|
12
|
+
React.createElement(Text, { color: "yellow" },
|
|
13
|
+
"Ping:",
|
|
14
|
+
' ',
|
|
15
|
+
React.createElement(Text, { color: "green", bold: true }, 22 /* placeholder */)))),
|
|
16
|
+
React.createElement(Text, null,
|
|
17
|
+
"Bedrock IP: ",
|
|
18
|
+
sub,
|
|
19
|
+
".jointhis.party:",
|
|
20
|
+
2324 /* placeholder */),
|
|
21
|
+
React.createElement(Text, null,
|
|
22
|
+
"Java IP: ",
|
|
23
|
+
sub,
|
|
24
|
+
".jointhis.party"),
|
|
25
|
+
React.createElement(Box, { marginTop: 1 },
|
|
26
|
+
React.createElement(Text, { dimColor: true }, "Press enter to quit"))));
|
|
27
|
+
}
|
package/dist/ui.d.ts
ADDED
package/dist/ui.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Text } from 'ink';
|
|
3
|
+
import { Box } from 'ink';
|
|
4
|
+
import { version } from './cli.js';
|
|
5
|
+
import SelectInput from 'ink-select-input';
|
|
6
|
+
import Main from './main.js';
|
|
7
|
+
export default function UI() {
|
|
8
|
+
const [value, Setvalue] = useState('0');
|
|
9
|
+
const [status, Setstatus] = useState('Welcome to JoinThis.proxy');
|
|
10
|
+
const handleSelect = (item) => {
|
|
11
|
+
Setvalue(item.value);
|
|
12
|
+
switch (item.value) {
|
|
13
|
+
case '1': {
|
|
14
|
+
Setstatus('JoinThis.tunnel');
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
case '2': {
|
|
18
|
+
Setstatus('JoinThis.record');
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
default: {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const items = [
|
|
27
|
+
{
|
|
28
|
+
label: 'Create a tunnel',
|
|
29
|
+
value: '1',
|
|
30
|
+
},
|
|
31
|
+
// {
|
|
32
|
+
// label: 'Create a DNS record',
|
|
33
|
+
// value: '2',
|
|
34
|
+
// },
|
|
35
|
+
];
|
|
36
|
+
return (React.createElement(Box, { alignSelf: "center", paddingX: 4, paddingY: 1, margin: 0, flexDirection: "column", justifyContent: "center", alignItems: "center", borderStyle: "round" },
|
|
37
|
+
React.createElement(Text, null, status),
|
|
38
|
+
React.createElement(Text, null, "----------------------------------------------"),
|
|
39
|
+
React.createElement(Box, { margin: 1, flexDirection: "column", justifyContent: "flex-start", alignItems: "flex-start" }, value == '0' ? (React.createElement(SelectInput, { onSelect: handleSelect, items: items })) : (React.createElement(Main, { view: value }))),
|
|
40
|
+
React.createElement(Text, null, "----------------------------------------------"),
|
|
41
|
+
React.createElement(Text, { dimColor: true }, `JoinThis.proxy CLI V${version}`)));
|
|
42
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jointhis.proxy",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"bin": "dist/cli.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=16"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"test": "prettier --check . && xo && ava"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"fs": "0.0.1-security",
|
|
20
|
+
"ink": "^4.1.0",
|
|
21
|
+
"ink-select-input": "^6.2.0",
|
|
22
|
+
"ink-spawn": "^0.1.4",
|
|
23
|
+
"ink-stepper": "^0.2.1",
|
|
24
|
+
"ink-text-input": "^6.0.0",
|
|
25
|
+
"meow": "^11.0.0",
|
|
26
|
+
"react": "^18.2.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@sindresorhus/tsconfig": "^3.0.1",
|
|
30
|
+
"@types/react": "^18.0.32",
|
|
31
|
+
"@vdemedes/prettier-config": "^2.0.1",
|
|
32
|
+
"ava": "^5.2.0",
|
|
33
|
+
"chalk": "^5.2.0",
|
|
34
|
+
"eslint-config-xo-react": "^0.27.0",
|
|
35
|
+
"eslint-plugin-react": "^7.32.2",
|
|
36
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
37
|
+
"ink-testing-library": "^3.0.0",
|
|
38
|
+
"prettier": "^2.8.8",
|
|
39
|
+
"ts-node": "^10.9.1",
|
|
40
|
+
"typescript": "^5.0.3",
|
|
41
|
+
"xo": "^0.53.1"
|
|
42
|
+
},
|
|
43
|
+
"ava": {
|
|
44
|
+
"extensions": {
|
|
45
|
+
"ts": "module",
|
|
46
|
+
"tsx": "module"
|
|
47
|
+
},
|
|
48
|
+
"nodeArguments": [
|
|
49
|
+
"--loader=ts-node/esm"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"xo": {
|
|
53
|
+
"extends": "xo-react",
|
|
54
|
+
"prettier": true,
|
|
55
|
+
"rules": {
|
|
56
|
+
"react/prop-types": "off"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"prettier": "@vdemedes/prettier-config"
|
|
60
|
+
}
|