jointhis.proxy 0.2.10 → 0.3.2

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/dist/cli.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- export declare const version = "0.2.10";
2
+ export declare const version = "0.3.2";
3
3
  export declare var rtun: any;
package/dist/cli.js CHANGED
@@ -7,35 +7,9 @@ import UI from './ui.js';
7
7
  import fs from 'node:fs';
8
8
  import { Spawn } from 'ink-spawn';
9
9
  import { exec } from 'node:child_process';
10
- export const version = `0.2.10`;
10
+ import { clear } from 'node:console';
11
+ export const version = `0.3.2`;
11
12
  export var rtun;
12
- // Get backend executable
13
- if (process.platform == 'linux') {
14
- fs.open('./rtun-linux-amd64', 'r', (err, fd) => {
15
- if (err) {
16
- exec('wget https://github.com/snsinfu/reverse-tunnel/releases/download/v1.3.2/rtun-linux-amd64').on('exit', function () {
17
- exec('chmod +x ./rtun-linux-amd64');
18
- });
19
- }
20
- });
21
- rtun = './rtun-linux-amd64';
22
- }
23
- else if (process.platform == 'win32') {
24
- console.log('Windows support is experimental.');
25
- fs.open('./rtun-windows-amd64.exe', 'r', (err, fd) => {
26
- if (err) {
27
- exec('curl.exe -L -O https://github.com/snsinfu/reverse-tunnel/releases/download/v1.3.2/rtun-windows-amd64.exe');
28
- }
29
- });
30
- rtun = 'rtun-windows-amd64.exe';
31
- }
32
- else if (process.platform == 'darwin') {
33
- console.log('Mac support is not yet implemented.');
34
- process.exit(1);
35
- }
36
- else {
37
- console.error('Unsupported Operating System.');
38
- }
39
13
  const cli = meow(`
40
14
  Usage
41
15
  $ jointhis.proxy
@@ -72,57 +46,103 @@ const cli = meow(`
72
46
  },
73
47
  },
74
48
  });
75
- // If any flags are given
76
- if (cli.flags.udp ||
77
- cli.flags.tcp ||
78
- cli.flags.service ||
79
- cli.flags.key ||
80
- cli.flags.subdomain) {
81
- if (!cli.flags.key) {
82
- render(React.createElement(Error, { message: "Authentication token missing" }));
83
- process.exit(1);
84
- }
85
- if ((!cli.flags.tcp || !cli.flags.udp) && !cli.flags.service) {
86
- render(React.createElement(Error, { message: "No service or port given." }));
87
- process.exit(1);
88
- }
89
- var tcp;
90
- var udp;
91
- if (cli.flags.service == 'mc') {
92
- tcp = `25565`;
93
- udp = `19132`;
94
- }
95
- else if (cli.flags.service == 'http') {
96
- tcp = `80`;
97
- udp = `80`;
98
- }
99
- else if (cli.flags.service == 'https') {
100
- tcp = `443`;
101
- udp = `443`;
102
- }
103
- else {
104
- tcp = cli.flags.tcp;
105
- udp = cli.flags.udp;
106
- }
107
- const response = await fetch(`https://www.jointhis.party/api/cli/${cli.flags.key}/${tcp}/${udp}`);
108
- if (!response.ok) {
109
- console.error('Error fetching configuration file from remote server.', 'ERROR', response.status);
110
- process.exit(1);
111
- throw new Error(`${response.status}`);
112
- }
113
- const result = await response.json();
114
- const config = result.config;
115
- fs.writeFile('./rtun.yml', config, function (err) {
49
+ // Download backend
50
+ if (process.platform == 'linux') {
51
+ fs.open('./rtun-linux-amd64', 'r', (err, fd) => {
116
52
  if (err) {
117
- console.log('Unable to write configuration file.');
118
- process.exit(1);
53
+ console.log('Downloading binary, please wait...');
54
+ exec('wget https://github.com/snsinfu/reverse-tunnel/releases/download/v1.3.2/rtun-linux-amd64').on('exit', function () {
55
+ exec('chmod +x ./rtun-linux-amd64').on('exit', function () {
56
+ // downloaded
57
+ main();
58
+ });
59
+ });
119
60
  }
120
61
  else {
121
- render(React.createElement(Spawn, { maxOutputLines: 4, runningText: "", command: rtun, args: ['-f ./rtun.yml'], shell: true }));
62
+ // downloaded
63
+ main();
122
64
  }
123
65
  });
66
+ rtun = './rtun-linux-amd64';
67
+ }
68
+ else if (process.platform == 'win32') {
69
+ fs.open('./rtun-windows-amd64.exe', 'r', (err, fd) => {
70
+ if (err) {
71
+ console.log('Downloading binary, please wait...');
72
+ exec('curl.exe -L -O https://github.com/snsinfu/reverse-tunnel/releases/download/v1.3.2/rtun-windows-amd64.exe').on('exit', function () {
73
+ // downloaded
74
+ main();
75
+ });
76
+ }
77
+ else {
78
+ // downloaded
79
+ main();
80
+ }
81
+ });
82
+ rtun = 'rtun-windows-amd64.exe';
83
+ }
84
+ else if (process.platform == 'darwin') {
85
+ console.log('Mac support is not yet implemented.');
86
+ process.exit(1);
124
87
  }
125
88
  else {
126
- // Start automated guide-through
127
- const { clear } = render(React.createElement(UI, null));
89
+ console.error('Unsupported Operating System.');
90
+ }
91
+ // END download backend
92
+ async function main() {
93
+ clear();
94
+ // If any flags are given
95
+ if (cli.flags.udp ||
96
+ cli.flags.tcp ||
97
+ cli.flags.service ||
98
+ cli.flags.key ||
99
+ cli.flags.subdomain) {
100
+ if (!cli.flags.key) {
101
+ render(React.createElement(Error, { message: "Authentication token missing" }));
102
+ process.exit(1);
103
+ }
104
+ if ((!cli.flags.tcp || !cli.flags.udp) && !cli.flags.service) {
105
+ render(React.createElement(Error, { message: "No service or port given." }));
106
+ process.exit(1);
107
+ }
108
+ var tcp;
109
+ var udp;
110
+ if (cli.flags.service == 'mc') {
111
+ tcp = `25565`;
112
+ udp = `19132`;
113
+ }
114
+ else if (cli.flags.service == 'http') {
115
+ tcp = `80`;
116
+ udp = `80`;
117
+ }
118
+ else if (cli.flags.service == 'https') {
119
+ tcp = `443`;
120
+ udp = `443`;
121
+ }
122
+ else {
123
+ tcp = cli.flags.tcp;
124
+ udp = cli.flags.udp;
125
+ }
126
+ const response = await fetch(`https://www.jointhis.party/api/cli/${cli.flags.key}/${tcp}/${udp}`);
127
+ if (!response.ok) {
128
+ console.error('Error fetching configuration file from remote server.', 'ERROR', response.status);
129
+ process.exit(1);
130
+ throw new Error(`${response.status}`);
131
+ }
132
+ const result = await response.json();
133
+ const config = result.config;
134
+ fs.writeFile('./rtun.yml', config, function (err) {
135
+ if (err) {
136
+ console.log('Unable to write configuration file.');
137
+ process.exit(1);
138
+ }
139
+ else {
140
+ render(React.createElement(Spawn, { maxOutputLines: 4, runningText: "", command: rtun, args: ['-f ./rtun.yml'], shell: true }));
141
+ }
142
+ });
143
+ }
144
+ else {
145
+ // Start automated guide-through
146
+ render(React.createElement(UI, null));
147
+ }
128
148
  }
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "jointhis.proxy",
3
- "version": "0.2.10",
3
+ "version": "0.3.2",
4
4
  "license": "MIT",
5
- "bin": "dist/cli.js",
5
+ "bin": {
6
+ "jointhis.proxy": "dist/cli.js",
7
+ "jointhis-proxy": "dist/cli.js"
8
+ },
6
9
  "type": "module",
7
10
  "engines": {
8
11
  "node": ">=16"
@@ -17,17 +20,17 @@
17
20
  ],
18
21
  "dependencies": {
19
22
  "fs": "0.0.1-security",
20
- "ink": "^4.4.1",
23
+ "ink": "^6.8.0",
21
24
  "ink-select-input": "^6.2.0",
22
25
  "ink-spawn": "^0.1.4",
23
26
  "ink-stepper": "^0.2.1",
24
27
  "ink-text-input": "^6.0.0",
25
28
  "meow": "^11.0.0",
26
- "react": "^18.3.1"
29
+ "react": "^19.2.4"
27
30
  },
28
31
  "devDependencies": {
29
32
  "@sindresorhus/tsconfig": "^3.0.1",
30
- "@types/react": "^18.3.28",
33
+ "@types/react": "^19.2.14",
31
34
  "@vdemedes/prettier-config": "^2.0.1",
32
35
  "ava": "^5.3.1",
33
36
  "chalk": "^5.6.2",