jointhis.proxy 0.3.0 → 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.3.0";
2
+ export declare const version = "0.3.2";
3
3
  export declare var rtun: any;
package/dist/cli.js CHANGED
@@ -7,34 +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.3.0`;
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
- fs.open('./rtun-windows-amd64.exe', 'r', (err, fd) => {
25
- if (err) {
26
- exec('curl.exe -L -O https://github.com/snsinfu/reverse-tunnel/releases/download/v1.3.2/rtun-windows-amd64.exe');
27
- }
28
- });
29
- rtun = 'rtun-windows-amd64.exe';
30
- }
31
- else if (process.platform == 'darwin') {
32
- console.log('Mac support is not yet implemented.');
33
- process.exit(1);
34
- }
35
- else {
36
- console.error('Unsupported Operating System.');
37
- }
38
13
  const cli = meow(`
39
14
  Usage
40
15
  $ jointhis.proxy
@@ -71,57 +46,103 @@ const cli = meow(`
71
46
  },
72
47
  },
73
48
  });
74
- // If any flags are given
75
- if (cli.flags.udp ||
76
- cli.flags.tcp ||
77
- cli.flags.service ||
78
- cli.flags.key ||
79
- cli.flags.subdomain) {
80
- if (!cli.flags.key) {
81
- render(React.createElement(Error, { message: "Authentication token missing" }));
82
- process.exit(1);
83
- }
84
- if ((!cli.flags.tcp || !cli.flags.udp) && !cli.flags.service) {
85
- render(React.createElement(Error, { message: "No service or port given." }));
86
- process.exit(1);
87
- }
88
- var tcp;
89
- var udp;
90
- if (cli.flags.service == 'mc') {
91
- tcp = `25565`;
92
- udp = `19132`;
93
- }
94
- else if (cli.flags.service == 'http') {
95
- tcp = `80`;
96
- udp = `80`;
97
- }
98
- else if (cli.flags.service == 'https') {
99
- tcp = `443`;
100
- udp = `443`;
101
- }
102
- else {
103
- tcp = cli.flags.tcp;
104
- udp = cli.flags.udp;
105
- }
106
- const response = await fetch(`https://www.jointhis.party/api/cli/${cli.flags.key}/${tcp}/${udp}`);
107
- if (!response.ok) {
108
- console.error('Error fetching configuration file from remote server.', 'ERROR', response.status);
109
- process.exit(1);
110
- throw new Error(`${response.status}`);
111
- }
112
- const result = await response.json();
113
- const config = result.config;
114
- fs.writeFile('./rtun.yml', config, function (err) {
49
+ // Download backend
50
+ if (process.platform == 'linux') {
51
+ fs.open('./rtun-linux-amd64', 'r', (err, fd) => {
115
52
  if (err) {
116
- console.log('Unable to write configuration file.');
117
- 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
+ });
118
60
  }
119
61
  else {
120
- render(React.createElement(Spawn, { maxOutputLines: 4, runningText: "", command: rtun, args: ['-f ./rtun.yml'], shell: true }));
62
+ // downloaded
63
+ main();
121
64
  }
122
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);
123
87
  }
124
88
  else {
125
- // Start automated guide-through
126
- 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
+ }
127
148
  }
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "jointhis.proxy",
3
- "version": "0.3.0",
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",