@mytmpvpn/mytmpvpn-cli 1.6.1 → 1.8.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # mytmpvpn-cli
2
2
 
3
- Command Line Interface for the [`MyTmpVpn`](https://gitlab.com/mytmpvpn) project.
3
+ Command Line Interface for the [`MyTmpVpn`](https://mytmpvpn.com) service.
4
4
 
5
5
  ## Getting started
6
6
 
package/dist/mytmpvpn.js CHANGED
@@ -185,20 +185,30 @@ program.command('get')
185
185
  program.command('download-config')
186
186
  .description('Download configuration of the given vpn to the given file')
187
187
  .argument('<vpnId>', 'vpnId to get config file from')
188
- .option('--file <file>', 'file where the config should be downloaded to. Default is <vpnId>.tar.gz')
188
+ .option('--file <file>', 'file where the config should be downloaded to. Default is <vpnId>.conf')
189
189
  .option('--path <path>', 'path where the config file should be written to', (0, userconfig_1.getDefaultUserConfigDir)())
190
190
  .action((vpnId, _, command) => {
191
191
  const options = command.optsWithGlobals();
192
- const file = options.file ? options.file : `${vpnId}.tar.gz`;
192
+ const file = options.file ? options.file : `${vpnId}.conf`;
193
193
  const fullpath = path.join(options.path, file);
194
194
  auth.getLoggedInClientFromFiles({ appConfigFile: options.appConfig, userConfigFile: options.userConfig, profileName: options.profile }, (err, client) => {
195
195
  if (err) {
196
196
  handleError(err);
197
197
  return;
198
198
  }
199
- client.writeVpnConfigTo(vpnId, fs.createWriteStream(fullpath))
200
- .then(() => log.info(fullpath))
201
- .catch(err => handleError(err));
199
+ client.getVpnConfig(vpnId)
200
+ .then(b64 => {
201
+ const vpnConfig = Buffer.from(b64, 'base64');
202
+ log.debug(`Writing config file to ${fullpath}`);
203
+ // Write the config file to the given path
204
+ fs.writeFile(fullpath, vpnConfig, (err) => {
205
+ if (err) {
206
+ handleError(err);
207
+ return;
208
+ }
209
+ log.info(`Config file written to ${fullpath}`);
210
+ });
211
+ }).catch(err => handleError(err));
202
212
  });
203
213
  });
204
214
  program.command('list')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mytmpvpn/mytmpvpn-cli",
3
- "version": "1.6.1",
3
+ "version": "1.8.1",
4
4
  "description": "MyTmpVpn CLI",
5
5
  "main": "./dist/mytmpvpn.js",
6
6
  "bin": {
@@ -27,8 +27,8 @@
27
27
  "dependencies": {
28
28
  "commander": "^9.4.1",
29
29
  "loglevel": "^1.8.1",
30
- "@mytmpvpn/mytmpvpn-client": "^1.7.1",
31
- "@mytmpvpn/mytmpvpn-common": "^1.4.0"
30
+ "@mytmpvpn/mytmpvpn-client": "^2.2.1",
31
+ "@mytmpvpn/mytmpvpn-common": "^2.1.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jest": "^29.2.2",
package/src/mytmpvpn.ts CHANGED
@@ -47,6 +47,7 @@ program
47
47
  .option('--appConfig <file>', 'Path to the application config file', getDefaultAppConfigFile())
48
48
  .option('--userConfig <file>', 'Path to the user config file', getDefaultUserConfigFile())
49
49
  .option('--profile <name>', 'Name of the profile in the user config file to use', getDefaultUserProfile())
50
+
50
51
  program.on('option:verbose', function () {
51
52
  log.setDefaultLevel("trace")
52
53
  })
@@ -194,20 +195,30 @@ program.command('get')
194
195
  program.command('download-config')
195
196
  .description('Download configuration of the given vpn to the given file')
196
197
  .argument('<vpnId>', 'vpnId to get config file from')
197
- .option('--file <file>', 'file where the config should be downloaded to. Default is <vpnId>.tar.gz')
198
+ .option('--file <file>', 'file where the config should be downloaded to. Default is <vpnId>.conf')
198
199
  .option('--path <path>', 'path where the config file should be written to', getDefaultUserConfigDir())
199
200
  .action((vpnId, _, command) => {
200
201
  const options = command.optsWithGlobals()
201
- const file = options.file ? options.file : `${vpnId}.tar.gz`
202
+ const file = options.file ? options.file : `${vpnId}.conf`
202
203
  const fullpath = path.join(options.path, file)
203
204
  auth.getLoggedInClientFromFiles({ appConfigFile: options.appConfig, userConfigFile: options.userConfig, profileName: options.profile }, (err, client) => {
204
205
  if (err) {
205
206
  handleError(err)
206
207
  return
207
208
  }
208
- client.writeVpnConfigTo(vpnId, fs.createWriteStream(fullpath))
209
- .then(() => log.info(fullpath))
210
- .catch(err => handleError(err))
209
+ client.getVpnConfig(vpnId)
210
+ .then(b64 => {
211
+ const vpnConfig = Buffer.from(b64, 'base64')
212
+ log.debug(`Writing config file to ${fullpath}`)
213
+ // Write the config file to the given path
214
+ fs.writeFile(fullpath, vpnConfig, (err) => {
215
+ if (err) {
216
+ handleError(err)
217
+ return
218
+ }
219
+ log.info(`Config file written to ${fullpath}`)
220
+ })
221
+ }).catch(err => handleError(err))
211
222
  })
212
223
  })
213
224
 
@@ -56,7 +56,7 @@ fi
56
56
  new_ip_addr=$(curl ifconfig.me)
57
57
 
58
58
  if test "${old_ip_addr}" == "${new_ip_addr}"; then
59
- 1>$2 echo "external IP address has not changed: old IP ${old_ip_addr} new ${new_ip_addr}"
59
+ 1>&2 echo "external IP address has not changed: old IP ${old_ip_addr} new ${new_ip_addr}"
60
60
  exit 1
61
61
  fi
62
62
  # Test region