npm.io
1.1.2 • Published 6 years agoCLI

htsync

Licence
MIT
Version
1.1.2
Deps
5
Size
34 kB
Vulns
0
Weekly
0

HTsync

Publish and download complete folder structures via HTTP(S).

Intention

Quick transfer of complete folder structures in situations where SCP, rsync, SFTP, or SMB shares are not an option because of firewall restrictions, platform incompatibility or installation complexity.

Requirements

  • NodeJS ≥ 10
  • A (potentially NAT forwared) port at the server side must be reachable form the client via HTTP(S) protocol.

Warning

HTsync server has no authentication feature (yet). Using it on a public port in an unsafe network environment can disclose data to an unwanted audience.

Installation

npm i -g htsync

Usage

You can show help for the command line arguments with htsync --help.

The htsync command knows three sub-commands: list, serve, and pull.

  • list [target] (aliases: l, ls)
    Print all relative file paths to the console, that would be published by the serve sub-command. Use it to test your include/exclude patterns before starting the HTsync server.
    The target is optional and defaults to the current working directory.
  • serve [-b <ip>] [-p <port>] [target] (aliases: s, svr)
    Start the HTsync server.
    The bound ip defaults to 0.0.0.0 (all network interfaces) and the port to 8080.
  • pull <url> [target] (aliases: p, u, update)
    Download files from the server, reachable by the url.
    The target is optional and defaults to the current working directory.

You can show specific help for a sub-command with htsync <command> --help.

You can set command line options via environment variables.

E. g. to prepare the server URL on the client side for multiple htsync pull executions, you can set HTSYNC_URL="http://your-server:12345".

Server side
  1. Navigate to the folder, you want to transfer
  2. Check which files get published with htsync list
  3. Run htsync serve -p 12345 to start the server
    Replace 12345 with a port, that is reachable by the client, possibly by port-forwarding in the firewall in front of your server.
Client side
  1. Navigate to the folder, in which you want to download the files from the server
  2. Run htsync pull http://your-server:12345
    Replace your-server by the IP of your server or a domain name resolving to the same, and 12345 by the port you specified on the server side.

Filtering

You can filter the files and directories at both sides of the transfer. You can limit the files transfered by specifying one or multiple include patterns with --include <pattern>* or -i <pattern>*. And you can block specific files by specifying one or multiple exclude patterns with --exclude <pattern>* or -x <pattern>*.

The patterns match case insensitive by default. Case-sensitive patterns can be specified with --cinclude/--ci and --cexclude/--cx.

Pattern Syntax

The pattern is searched in the relative path below the target directory of the server. The path is normalized on Windows by replacing back-slashes with forward-slashes.

By default, patterns are searched in the whole string. (image would match the relative path home/images/vacation)

To anchor the pattern at the beginning use a leading / in the pattern. (/image would match images/vacation but not home/images/vacation)

To anchor the pattern at the end use a trailing $ in the pattern. (.htm$ would match www/index.htm but not www/index.html)

You can use the wildcards ?, *, and ** in a pattern. The ? matches one arbitrary character. The * matches any number of characters, but not /. The ** matches any number of characters, including /.

Examples

Hint: To run the examples in the Windows CMD prompt, replace single quotes ' with double quotes ".

Publish only ISO files on the server side

htsync serve --include '**/*.iso

Publish only folders containing 2020 and 2021

htsync server --include '2020*/' '2021*/'

Download all sub-folders of work files/2020 and exclude Windows thumbnails

htsync pull --include `/work files/2020/*/` --exclude `**/Thumbs.db

HTsync

Publish and download complete folder structures via HTTP(S).

Intention

Quick transfer of complete folder structures in situations where SCP, rsync, SFTP, or SMB shares are not an option because of firewall restrictions, platform incompatibility or installation complexity.

Requirements

  • NodeJS ≥ 10
  • A (potentially NAT forwared) port at the server side must be reachable form the client via HTTP(S) protocol.

Warning

HTsync server has no authentication feature (yet). Using it on a public port in an unsafe network environment can disclose data to an unwanted audience.

Installation

npm i -g htsync

Usage

You can show help for the command line arguments with __INLINE_CODE_0__.

The __INLINE_CODE_1__ command knows three sub-commands: __INLINE_CODE_2__, __INLINE_CODE_3__, and __INLINE_CODE_4__.

  • __INLINE_CODE_5__ (aliases: __INLINE_CODE_6__, __INLINE_CODE_7__)
    Print all relative file paths to the console, that would be published by the __INLINE_CODE_8__ sub-command. Use it to test your include/exclude patterns before starting the HTsync server.
    The __INLINE_CODE_9__ is optional and defaults to the current working directory.
  • __INLINE_CODE_10__ (aliases: __INLINE_CODE_11__, __INLINE_CODE_12__)
    Start the HTsync server.
    The bound __INLINE_CODE_13__ defaults to __INLINE_CODE_14__ (all network interfaces) and the __INLINE_CODE_15__ to __INLINE_CODE_16__.
  • __INLINE_CODE_17__ (aliases: __INLINE_CODE_18__, __INLINE_CODE_19__, __INLINE_CODE_20__)
    Download files from the server, reachable by the __INLINE_CODE_21__.
    The __INLINE_CODE_22__ is optional and defaults to the current working directory.

You can show specific help for a sub-command with __INLINE_CODE_23__.

You can set command line options via environment variables.

E. g. to prepare the server URL on the client side for multiple __INLINE_CODE_24__ executions, you can __INLINE_CODE_25__.

Server side
  1. Navigate to the folder, you want to transfer
  2. Check which files get published with __INLINE_CODE_26__
  3. Run __INLINE_CODE_27__ to start the server
    Replace __INLINE_CODE_28__ with a port, that is reachable by the client, possibly by port-forwarding in the firewall in front of your server.
Client side
  1. Navigate to the folder, in which you want to download the files from the server
  2. Run __INLINE_CODE_29__
    Replace __INLINE_CODE_30__ by the IP of your server or a domain name resolving to the same, and __INLINE_CODE_31__ by the port you specified on the server side.

Filtering

You can filter the files and directories at both sides of the transfer. You can limit the files transfered by specifying one or multiple include patterns with __INLINE_CODE_32__ or __INLINE_CODE_33__. And you can block specific files by specifying one or multiple exclude patterns with __INLINE_CODE_34__ or __INLINE_CODE_35__.

The patterns match case insensitive by default. Case-sensitive patterns can be specified with __INLINE_CODE_36__/__INLINE_CODE_37__ and __INLINE_CODE_38__/__INLINE_CODE_39__.

Pattern Syntax

The pattern is searched in the relative path below the target directory of the server. The path is normalized on Windows by replacing back-slashes with forward-slashes.

By default, patterns are searched in the whole string. (__INLINE_CODE_40__ would match the relative path __INLINE_CODE_41__)

To anchor the pattern at the beginning use a leading __INLINE_CODE_42__ in the pattern. (__INLINE_CODE_43__ would match __INLINE_CODE_44__ but not __INLINE_CODE_45__)

To anchor the pattern at the end use a trailing __INLINE_CODE_46__ in the pattern. (__INLINE_CODE_47__ would match __INLINE_CODE_48__ but not __INLINE_CODE_49__)

You can use the wildcards __INLINE_CODE_50__, __INLINE_CODE_51__, and __INLINE_CODE_52__ in a pattern. The __INLINE_CODE_53__ matches one arbitrary character. The __INLINE_CODE_54__ matches any number of characters, but not __INLINE_CODE_55__. The __INLINE_CODE_56__ matches any number of characters, including __INLINE_CODE_57__.

Examples

Hint: To run the examples in the Windows CMD prompt, replace single quotes __INLINE_CODE_58__ with double quotes __INLINE_CODE_59__.

Publish only ISO files on the server side

htsync serve --include '**/*.iso

Publish only folders containing __INLINE_CODE_60__ and __INLINE_CODE_61__

htsync server --include '2020*/' '2021*/'

Download all sub-folders of __INLINE_CODE_62__ and exclude Windows thumbnails

License

The project is published under the MIT license.
Copyright (c) 2020 Tobias Kiertscher dev@mastersign.de.

Some parts of the server code is borrowed from serve by Leo Lamprecht - Vercel. Thanks a lot!

Publish only folders containing __INLINE_CODE_60__ and __INLINE_CODE_61__

__CODE_BLOCK_2__

Download all sub-folders of __INLINE_CODE_62__ and exclude Windows thumbnails

__CODE_BLOCK_3__
License

The project is published under the MIT license.
Copyright (c) 2020 Tobias Kiertscher dev@mastersign.de.

Some parts of the server code is borrowed from serve by Leo Lamprecht - Vercel. Thanks a lot!