88 Commits

Author SHA1 Message Date
veeso
7ad7a1580d fixed serializer 2023-02-19 18:46:10 +01:00
veeso
46f2954bc4 install.yml 2023-02-19 18:24:29 +01:00
veeso
0c88f559e2 0.11.0 2023-02-19 18:23:30 +01:00
veeso
8a0979578a deps 2023-02-13 09:35:10 +01:00
veeso
7ee28a00ae planned updates 2023-02-12 22:28:43 +01:00
Christian Visintin
82330f870e Optimize transfers (#147)
* When the file is exchanged, all times attributes are set (if supported by the protocol)

* If local/remote file have the same last modification time (`mtime`), the file is not transferred
2023-02-12 22:27:42 +01:00
veeso
54aecdc478 0.11.0 2023-02-11 12:49:30 +01:00
veeso
d5038a22ee fixed tests 2023-02-11 12:45:12 +01:00
Christian Visintin
c0bc493d21 125 installation missing aarch64 linux build (#146)
aarch64 build
2023-02-11 12:26:43 +01:00
Christian Visintin
1c75c7d386 SSH configuration path is not ~/.ssh/config by default (#145)
SSH configuration path is not `~/.ssh/config` by default
2023-02-11 12:23:57 +01:00
Christian Visintin
251b125cbb 126 new feature termscp doesnt use id rsa default ssh private key to authenticate to sftp scp endpoint (#144)
fixed issue 126 <https://github.com/veeso/termcp/issues/126>
2023-02-11 12:23:56 +01:00
veeso
efd2235ff3 fmt 2023-02-11 12:23:56 +01:00
veeso
1db2ff7ec5 Popup with fixed sizes or percentage 2023-02-11 12:23:56 +01:00
veeso
4d5f3a6b63 lint 2023-02-11 12:23:56 +01:00
veeso
62003308a7 lint 2023-02-11 12:23:56 +01:00
veeso
cb037cfca9 updated dependencies 2023-02-11 12:23:56 +01:00
Sergei Akhmatdinov
15fffdf0c9 fix install script for FreeBSD, add doas priv elevation 2023-01-31 15:03:07 +01:00
veeso
c1b245b4c9 fixed install script for freebsd 2023-01-30 12:15:56 +01:00
veeso
d14225c0b9 readme 2023-01-13 09:55:49 +01:00
veeso
d60be7dc80 0.10.0 2022-12-28 10:49:36 +01:00
Christian Visintin
146a1f3ed6 Create website.yml 2022-12-27 16:44:42 +01:00
veeso
12fe10100b termscp site 2022-12-27 16:42:25 +01:00
RakerZh
298d590306 fix typo 2022-11-08 09:30:48 +01:00
pin
8e6aae08b6 Add NetBSD 2022-10-25 18:10:00 +02:00
veeso
cb33ba114e fixed check on aarch64 2022-10-25 18:09:06 +02:00
veeso
6369ead491 Merge branch '0.10.0' into main 2022-10-15 14:01:40 +02:00
veeso
ae350b4bfa termscp 0.10 2022-10-15 14:01:00 +02:00
veeso
cd5bb28fb7 updated deps 2022-10-10 18:04:44 +02:00
veeso
f27a4e2a02 lint 2022-10-10 17:40:03 +02:00
veeso
0f432d0375 fixed build 2022-10-10 17:26:26 +02:00
veeso
8b67c59247 removed deps from docker build 2022-10-10 16:50:00 +02:00
veeso
fdd7901f7e removed libssl dependency 2022-10-10 16:21:32 +02:00
Christian Visintin
2eec7c4b2b Update README.md 2022-09-06 12:01:24 +02:00
veeso
64e3848c97 Use ssh2 config IdentityFile as fallback for key based authentication 2022-08-30 17:47:55 +02:00
veeso
833cd7d3ba Fixed version comparison when going above 0.9 2022-08-30 15:54:37 +02:00
veeso
2f1b644a40 backtab will now change the explorer tab; use P to change to log 2022-08-30 15:45:26 +02:00
veeso
6a5c248d35 Yes/No dialogs are now answerable by pressing Y or N on your keyboard 2022-08-30 15:29:34 +02:00
veeso
96df152220 fixed issue 122 <https://github.com/veeso/termscp/issues/122> 2022-08-30 15:10:41 +02:00
veeso
a22c5025d7 lint 2022-08-17 10:33:31 +02:00
veeso
cce0c92c0b dependencies updated 2022-08-17 10:28:44 +02:00
veeso
90d7083b24 lazy-regex 2022-08-17 10:24:13 +02:00
veeso
b3ab76e573 working on 0.10.0 2022-08-17 10:16:03 +02:00
Christian Visintin
66913d5fc1 Update README.md 2022-08-05 14:51:28 +02:00
veeso
f5174ccac0 removed dynamic libssl dep 2022-07-20 12:37:22 +02:00
veeso
82489e7459 homebrew notice 2022-07-20 12:08:11 +02:00
eric wong
ad562a7b09 Optimize the presentation of zh-CN/README.md (#117) 2022-07-18 09:31:31 +02:00
veeso
08c42e5acf release date 2022-06-18 13:35:03 +02:00
veeso
aac9cf4fa0 features updated 2022-06-10 12:18:38 +02:00
veeso
a26b21da89 0.9.0 2022-06-09 17:45:17 +02:00
veeso
bb95c9a4d0 updated dependencies 2022-06-09 15:11:55 +02:00
veeso
80dea3f71a Fixed SSH key list showing {hostname} at {username} instead of {username} at {hostname} 2022-06-09 15:08:02 +02:00
veeso
0057a657d2 removed license headers 2022-06-09 14:28:02 +02:00
Christian Visintin
816270d545 Fs watcher (#113)
fs watcher
2022-06-09 13:03:02 +02:00
veeso
2caa0432df Remote directory path in authentication form and in bookmarks parameters 2022-05-03 15:37:00 +02:00
Christian Visintin
e0d8b80cdf Bookmark name as hostname for cli args (#111)
bookmark name as hostname for cli args
2022-05-03 11:54:48 +02:00
veeso
f094979ddb working on 0.9.0 2022-05-03 09:16:38 +02:00
veeso
0c8144aaa8 0.8.2 2022-04-26 21:41:21 +02:00
veeso
3249e82873 lint 2022-04-22 09:56:10 +02:00
veeso
66adad3135 Fixed termscp panics when displaying long non-ascii filenames 2022-04-20 12:09:33 +02:00
veeso
f2e5bf4441 Working on 0.8.2 2022-04-07 11:08:47 +02:00
veeso
601b0595d4 Write exitcode on exit 2022-04-07 11:07:41 +02:00
veeso
c47fcb2225 fixed install script 2022-04-07 10:24:54 +02:00
veeso
550c7ca62a upcoming features 2022-03-22 20:55:54 +01:00
veeso
3256c276b4 0.8.1 2022-03-22 20:45:24 +01:00
veeso
04f43fff63 boolean release 2022-03-19 10:35:36 +01:00
veeso
82e8c84000 fixed make_pkg 2022-03-15 12:22:43 +01:00
veeso
31203d76ce install.sh m1 macos 2022-03-15 11:25:50 +01:00
veeso
572a948f2c macos arm64 build 2022-03-15 11:25:50 +01:00
veeso
b6ee49cfa6 updated donation link in install.sh 2022-03-09 17:07:35 +01:00
veeso
0334c5db78 Updated dependencies 2022-03-09 16:19:57 +01:00
veeso
c45ebec261 Fixed AltGr characters not allowed in auth form 2022-03-09 15:13:08 +01:00
veeso
ad2781b62c use latest rust in macos/windows ci 2022-03-09 11:27:26 +01:00
veeso
35dc11cce3 Strip binary with new 1.59 feature 2022-03-05 11:11:07 +01:00
veeso
8d9e7443ec updated user manuals 2022-03-05 11:06:14 +01:00
veeso
697ab225ea clippy 2022-03-05 11:06:14 +01:00
veeso
babbc5eadb new-path-style and endpoint s3 params 2022-03-05 11:06:14 +01:00
veeso
f28dba7660 added new s3 params 2022-03-05 11:06:14 +01:00
veeso
c5eba4b56a changed 'AWS S3' to 'S3' in forms 2022-03-05 11:06:14 +01:00
veeso
0b70819781 wtf git? 2022-02-06 11:09:44 +01:00
veeso
069fe8cae2 Merge branch '0.8.1' of github.com:veeso/termscp into 0.8.1 2022-02-06 10:57:44 +01:00
veeso
043f54e707 removed freebsd workflow. It is not supported anymore 2022-02-06 10:57:27 +01:00
veeso
b635554e52 updated freebsd vm version 2022-02-04 15:16:07 +01:00
veeso
9e35616568 updated dependencies 2022-02-04 15:14:11 +01:00
veeso
615dbda583 clippy 2022-02-04 15:06:11 +01:00
veeso
4b421a4a87 issue 94: color not reset after leaving text editor (SORCERY!!!) 2022-01-29 19:26:37 +01:00
veeso
0fe06eb52b updated deps 2022-01-29 19:04:22 +01:00
veeso
e8c6b8306f working on 0.8.1 2022-01-29 19:03:12 +01:00
Pascal Sommer
d1457253c4 fix: footer listed "Delete" shortcut as "Make Dir" 2022-01-12 21:03:15 +01:00
161 changed files with 7466 additions and 3939 deletions

View File

@@ -8,6 +8,7 @@ ignore:
- "../*"
- src/main.rs
- src/activity_manager.rs
- src/cli_opts.rs
- src/support.rs
- src/system/notifications.rs
- "src/ui/activities/*"

View File

@@ -1,22 +0,0 @@
name: FreeBSD
on: [push, pull_request]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: FreeBSD build
id: test
uses: vmactions/freebsd-vm@v0.1.4
with:
usesh: true
prepare: pkg install -y curl wget libssh gcc vim dbus pkgconf
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rustup.sh && \
chmod +x /tmp/rustup.sh && \
/tmp/rustup.sh -y
. $HOME/.cargo/env
cargo build --no-default-features
cargo test --no-default-features --verbose --features github-actions

19
.github/workflows/install.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Install.sh
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt update && sudo apt install -y curl wget
- name: Install termscp from script
run: |
./install.sh -v=0.11.0 -f
which termscp || exit 1

View File

@@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt update && sudo apt install -y libdbus-1-dev libssh2-1-dev libssl-dev
run: sudo apt update && sudo apt install -y libdbus-1-dev
- uses: actions-rs/toolchain@v1
with:
toolchain: stable

View File

@@ -11,6 +11,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Build
run: cargo build
- name: Run tests

41
.github/workflows/website.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: './site/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1

View File

@@ -11,6 +11,11 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Build
run: cargo build
- name: Run tests

1
.gitignore vendored
View File

@@ -23,3 +23,4 @@ dist/pkgs/arch/*.tar.gz
.DS_Store
dist/pkgs/
dist/build/macos/openssl/

View File

@@ -1,6 +1,11 @@
# Changelog
- [Changelog](#changelog)
- [0.11.0](#0110)
- [0.10.0](#0100)
- [0.9.0](#090)
- [0.8.2](#082)
- [0.8.1](#081)
- [0.8.0](#080)
- [0.7.0](#070)
- [0.6.1](#061)
@@ -22,6 +27,132 @@
---
## 0.11.0
Released on 20/02/2023
> 🦥 The lazy update
- **Transfers optimized**:
- If local/remote file have the same "last modification time" (`mtime`), the file is not transferred
- When the file is exchanged, all times attributes are set (if supported by the protocol)
- **Default ssh config path**:
- SSH configuration path is now `~/.ssh/config` by default
- Added ARM64 Linux builds
- **Bugfix**:
- Fixed [Issue 126](https://github.com/veeso/termscp/issues/126)
- Fixed [Issue 141](https://github.com/veeso/termscp/issues/141)
- Dependencies:
- Bump `remotefs-ssh` to `0.1.3`
- Bump `self_update` to `0.35`
- Bump `ssh2-config` to `0.1.4`
- Bump `toml` to `0.7`
## 0.10.0
Released on 15/10/2022
> ⭐ 500 stars update ⭐
> Thank you for supporting termscp and make it reaching 500 stars on Github
- **Changed keybindings for BACKTAB**: backtab will now change the explorer tab
- To active the LOG PANEL, use `P`
- **Yes/No dialogs** are now answerable by pressing `Y` or `N` on your keyboard ([Issue 121](https://github.com/veeso/termscp/issues/121))
- **Use ssh2 config IdentityFile** as fallback for key based authentication
- **Bugfix**
- Fixed [Issue 122](https://github.com/veeso/termscp/issues/122)
- Fixed version comparison when going above 0.9
- Dependencies:
- Bump `argh` to `0.1.9`
- Bump `chrono` to `0.4.22`
- Bump `keyring` to `1.2.0`
- Bump `notify-rust` to `4.5.10`
- Bump `open` to `3.0.3`
- Bump `rpassword` to `7.0.0`
- Changed `regex` to `lazy-regex 2.3.0`
- Bump `remotefs-ftp` to `0.1.2`
- Bump `remotefs-ssh` to `0.1.2`
- Bump `self_update` to `0.32`
- Bump `ssh2-config` to `0.1.3`
- Bump `tuirealm` to `1.8.0`
- Bump `tui-realm-stdlib` to `1.1.7`
- Bump `unicode-width` to `0.1.10`
- Added `version-compare 0.1.0`
- Bump `whoami` to `1.2.3`
- Bump `wildmatch` to `2.1.1`
- Removed libssl dependency
## 0.9.0
Released on 18/06/2022
> 🏖️ Tenerife Update 🍹
- **Bookmark name as hostname for CLI arguments**
- It is now possible to provide the name of the bookmark you want to connect to, instead of the address in command line arguments
To do so it is enough to run termscp as follows:
```sh
termscp -b <bookmark-name>
```
If the password is stored in the bookmark, it will be used, otherwise you will be prompted to type the password in.
- **Remote directory path in authentication form and in bookmarks parameters**:
- It is now possible to configure the directory path you want to enter when you connect to the remote host from the authentication form
- This parameter can be stored into bookmarks as you already do with the other parameters
- You can find this field scrolling down in the authentication form
- **File system watcher**:
- It is now possible to synchronize changes from a local path to the remote host
- Press `<T>` to start synchronizing changes from the selected directory/file to the remote directory
- The changes will be automatically applied to the remote host with a maximum delay of 5 seconds
- These changes are (if possible) applied: file removed, file changed, file renamed
- Press `<CTRL+T>` to show all the currently synchronized files
- **Enhancements**:
- Improved s3 auth form scrolling
- **Bugfix**:
- Fixed SSH key list showing `{hostname} at {username}` instead of `{username} at {hostname}`
- Dependencies:
- Updated `edit` to `0.1.4`
- Updated `log` to `0.4.17`
- Updated `magic-crypt` to `3.1.10`
- Updated `open` to `2.1.3`
- Updated `regex` to `1.5.6`
- Updated `rpassword` to `6.0.1`
- Updated `self_update` to `0.30.0`
- Updated `simplelog` to `0.12.0`
- Updated `toml` to `0.5.9`
- Updated `tui-realm` to `1.6.0`
## 0.8.2
Released on 26/04/2022
- **Enhancements**
- Write exitcode to log when termscp terminates
- Bugfix:
- [Issue 104](https://github.com/veeso/termscp/issues/104): Fixed termscp panics when displaying long non-ascii filenames
## 0.8.1
Released on 22/03/2022
- **Added support for S3 compatible backends**
- Changed `AWS S3` to `S3` in ui
- Added new `endpoint` and `new-path-style` to s3 connection parameters
- Bugfix:
- [Issue 92](https://github.com/veeso/termscp/issues/92): updated ssh2-config to 0.1.3, which solves this issue.
- [Issue 99](https://github.com/veeso/termscp/issues/99): Fixed AltGr characters not allowed in auth form
- Dependencies:
- Updated `keyring` to `1.1.2`
- Updated `notify-rust` to `4.5.6`
- Updated `open` to `2.0.3`
- Updated `rand` to `0.8.5`
- Updated `regex` to `1.5.5`
- Updated `remotefs-rs-aws-s3` to `0.2.0`
- Updated `tui-realm` to `1.5.0`
- Updated `tui-realm-stdlib` to `1.1.6`
## 0.8.0
Released on 06/01/2022

View File

@@ -95,8 +95,6 @@ Said so, follow these steps:
- Open an issue using the `feature request` template describing with accuracy your suggestion
- Wait for the maintainer feedback on your idea
If you want to implement the feature by yourself and your suggestion gets approved, start writing the code. Remember that on [docs.rs](https://docs.rs/termscp) there is the documentation for the project. Open a PR related to your issue. See [Pull request process for more details](#pull-request-process)
It is very important to follow these steps, since it will prevent you from working on a feature that will be rejected and trust me, none of us wants to deal with this situation.
Always mind that your suggestion, may be rejected: I'll always provide a feedback on the reasons that brought me to reject your feature, just try not to get mad about that.

2083
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,16 @@
[package]
authors = ["Christian Visintin"]
authors = ["Christian Visintin <christian.visintin1997@gmail.com>"]
categories = ["command-line-utilities"]
description = "termscp is a feature rich terminal file transfer and explorer with support for SCP/SFTP/FTP/S3"
documentation = "https://docs.rs/termscp"
edition = "2021"
homepage = "https://veeso.github.io/termscp/"
homepage = "https://termscp.veeso.dev"
include = ["src/**/*", "LICENSE", "README.md", "CHANGELOG.md"]
keywords = ["scp-client", "sftp-client", "ftp-client", "winscp", "command-line-utility"]
license = "MIT"
name = "termscp"
readme = "README.md"
repository = "https://github.com/veeso/termscp"
version = "0.8.0"
version = "0.11.0"
[package.metadata.rpm]
package = "termscp"
@@ -32,51 +31,63 @@ name = "termscp"
path = "src/main.rs"
[dependencies]
argh = "0.1.7"
bitflags = "1.3.2"
bytesize = "1.1.0"
chrono = "0.4.19"
content_inspector = "0.2.4"
dirs = "4.0.0"
edit = "0.1.3"
hostname = "0.3.1"
keyring = { version = "1.0.0", optional = true }
lazy_static = "1.4.0"
log = "0.4.14"
magic-crypt = "3.1.9"
notify-rust = { version = "4.5.5", default-features = false, features = [ "d" ] }
open = "2.0.2"
rand = "0.8.4"
regex = "1.5.4"
argh = "^0.1"
bitflags = "^1.3"
bytesize = "^1.1"
chrono = "^0.4"
content_inspector = "^0.2"
dirs = "^4.0"
edit = "^0.1"
filetime = "^0.2"
hostname = "^0.3"
keyring = { version = "^1.2", optional = true }
lazy-regex = "^2.4"
lazy_static = "^1.4"
log = "^0.4"
magic-crypt = "^3.1"
notify = "^4.0"
notify-rust = { version = "^4.5", default-features = false, features = [ "d" ] }
open = "^3.0"
rand = "^0.8.5"
remotefs = "^0.2.0"
remotefs-aws-s3 = "^0.1.0"
remotefs-ftp = { version = "^0.1.0", features = [ "secure" ] }
remotefs-ssh = "^0.1.0"
rpassword = "5.0.1"
self_update = { version = "0.28.0", features = [ "archive-tar", "archive-zip", "compression-flate2", "compression-zip-deflate" ] }
serde = { version = "^1.0.0", features = [ "derive" ] }
simplelog = "0.11.1"
tempfile = "3.2.0"
thiserror = "^1.0.0"
toml = "0.5.8"
tui-realm-stdlib = "1.1.5"
tuirealm = "1.4.2"
unicode-width = "0.1.8"
whoami = "1.2.1"
wildmatch = "2.1.0"
remotefs-aws-s3 = { version = "^0.2.1", default-features = false, features = [ "find", "rustls" ] }
rpassword = "^7.0"
self_update = { version = "^0.35", default-features = false, features = [ "rustls", "archive-tar", "archive-zip", "compression-flate2", "compression-zip-deflate" ] }
serde = { version = "^1", features = [ "derive" ] }
simplelog = "^0.12"
ssh2-config = "^0.1.4"
tempfile = "^3.2"
thiserror = "^1"
toml = "^0.7"
tui-realm-stdlib = "^1.2"
tuirealm = "^1.8.0"
unicode-width = "^0.1"
version-compare = "^0.1"
whoami = "^1.2"
wildmatch = "^2.1"
[dev-dependencies]
pretty_assertions = "0.7.2"
serial_test = "^0.5.1"
pretty_assertions = "^1.3"
serial_test = "^0.9"
[features]
default = [ "with-keyring" ]
github-actions = [ ]
with-keyring = [ "keyring" ]
[target."cfg(target_family = \"windows\")"]
[target."cfg(target_family = \"windows\")".dependencies]
remotefs-ftp = { version = "^0.1.2", features = [ "native-tls" ] }
remotefs-ssh = "^0.1.3"
[target."cfg(target_family = \"unix\")"]
[target."cfg(target_family = \"unix\")".dependencies]
remotefs-ftp = { version = "^0.1.2", features = [ "vendored", "native-tls" ] }
remotefs-ssh = { version = "^0.1.3", features = [ "ssh2-vendored" ] }
users = "0.11.0"
[profile.dev]
incremental = true
[profile.release]
strip = true

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 Christian Visintin
Copyright (c) 2020-2022 Christian Visintin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -63,7 +63,7 @@
</p>
<p align="center">Developed by <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
<p align="center">Current version: 0.8.0 (06/01/2022)</p>
<p align="center">Current version: 0.11.0 (20/02/2023)</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT"
@@ -108,28 +108,18 @@
src="https://github.com/veeso/termscp/workflows/Windows/badge.svg"
alt="Windows CI"
/></a>
<a href="https://github.com/veeso/termscp/actions"
><img
src="https://github.com/veeso/termscp/workflows/FreeBSD/badge.svg"
alt="FreeBSD CI"
/></a>
<a href="https://coveralls.io/github/veeso/termscp"
><img
src="https://coveralls.io/repos/github/veeso/termscp/badge.svg"
alt="Coveralls"
/></a>
<a href="https://docs.rs/termscp"
><img
src="https://docs.rs/termscp/badge.svg"
alt="Docs"
/></a>
</p>
---
## About termscp 🖥
Termscp is a feature rich terminal file transfer and explorer, with support for SCP/SFTP/FTP/S3. So basically is a terminal utility with an TUI to connect to a remote server to retrieve and upload files and to interact with the local file system. It is **Linux**, **MacOS**, **FreeBSD** and **Windows** compatible.
Termscp is a feature rich terminal file transfer and explorer, with support for SCP/SFTP/FTP/S3. So basically is a terminal utility with an TUI to connect to a remote server to retrieve and upload files and to interact with the local file system. It is **Linux**, **MacOS**, **FreeBSD**, **NetBSD** and **Windows** compatible.
![Explorer](assets/images/explorer.gif)
@@ -141,13 +131,13 @@ Termscp is a feature rich terminal file transfer and explorer, with support for
- **SFTP**
- **SCP**
- **FTP** and **FTPS**
- **Aws S3**
- **S3**
- 🖥 Explore and operate on the remote and on the local machine file system with a handy UI
- Create, remove, rename, search, view and edit files
- ⭐ Connect to your favourite hosts through built-in bookmarks and recent connections
- 📝 View and edit files with your favourite applications
- 💁 SFTP/SCP authentication with SSH keys and username/password
- 🐧 Compatible with Windows, Linux, FreeBSD and MacOS
- 🐧 Compatible with Windows, Linux, FreeBSD, NetBSD and MacOS
- 🎨 Make it yours!
- Themes
- Custom file explorer format
@@ -155,6 +145,7 @@ Termscp is a feature rich terminal file transfer and explorer, with support for
- Customizable file sorting
- and many other parameters...
- 📫 Get notified via Desktop Notifications when a large file has been transferred
- 🔭 Keep file changes synchronized with the remote host
- 🔐 Save your password in your operating system key vault
- 🦀 Rust-powered
- 👀 Developed keeping an eye on performance
@@ -173,12 +164,20 @@ If you are a Linux, a FreeBSD or a MacOS user this simple shell script will inst
curl --proto '=https' --tlsv1.2 -sSLf "https://git.io/JBhDb" | sh
```
> ❗ MacOs installation requires [Homebrew](https://brew.sh/), otherwise the Rust compiler will be installed
while if you're a Windows user, you can install termscp with [Chocolatey](https://chocolatey.org/):
```sh
```ps
choco install termscp
```
NetBSD users can install termscp from the official repositories.
```sh
pkgin install termscp
```
For more information or other platforms, please visit [veeso.github.io](https://veeso.github.io/termscp/#get-started) to view all installation methods.
⚠️ If you're looking on how to update termscp just run termscp from CLI with: `(sudo) termscp --update` ⚠️
@@ -186,11 +185,9 @@ For more information or other platforms, please visit [veeso.github.io](https://
### Requirements ❗
- **Linux** users:
- libssh
- libdbus-1
- pkg-config
- **FreeBSD** users:
- libssh
- **FreeBSD** or, **NetBSD** users:
- dbus
- pkgconf
@@ -220,35 +217,19 @@ You can make a donation with one of these platforms:
[![ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/veeso)
[![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://www.paypal.me/chrisintin)
[![bitcoin](https://img.shields.io/badge/Bitcoin-ff9416?style=for-the-badge&logo=bitcoin&logoColor=white)](https://btc.com/bc1qvlmykjn7htz0vuprmjrlkwtv9m9pan6kylsr8w)
---
## User manual and Documentation 📚
## User manual 📚
The user manual can be found on the [termscp's website](https://veeso.github.io/termscp/#user-manual) or on [Github](docs/man.md).
The developer documentation can be found on Rust Docs at <https://docs.rs/termscp>
---
## Upcoming Features 🧪
For **2022** there will be two major updates during the year.
Planned for *🍓 Spring update 2022 🌹*:
- **File system watcher 🔭**: The feature consists in the possibility to track some files in order to automatically sync them with remote host. For the implementation [notify](https://github.com/notify-rs/notify) will be used.
Planned for *future updates ⏲️*:
- **Translations 🌐**: The feature consists in the possibility for the user to install the language pack for the language he prefers in order to replace the default English interface. The following language will be provided along to English:
- 🇨🇳 Chinese
- 🇫🇷 French
- 🇩🇪 German
- 🇮🇹 Italian
- 🇳🇱 Dutch
- 🇪🇸 Spanish
- **Configuration profile for bookmarks 📚**: Basically this feature adds the possibility to have a specific setup for a certain host, instead of having only one global configuration. (Maybe will be postponed to spring 2022).
For **2023** there will be two major updates during the year.
Along to new features, termscp developments is now focused on UX and performance improvements, so if you have any suggestion, feel free to open an issue.

30
dist/build/aarch64_centos7/Dockerfile vendored Normal file
View File

@@ -0,0 +1,30 @@
FROM centos:centos7 as builder
ARG branch
ENV branch=$branch
WORKDIR /usr/src/
# Install dependencies
RUN yum -y install \
git \
gcc \
pkgconfig \
gcc \
make \
dbus-devel \
bash \
rpm-build
# Install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \
chmod +x /tmp/rust.sh && \
/tmp/rust.sh -y
# Clone repository
RUN git clone --branch $branch https://github.com/veeso/termscp.git
# Set workdir to termscp
WORKDIR /usr/src/termscp/
# Build for x86_64
RUN source $HOME/.cargo/env && cargo build --release
# Install cargo rpm
RUN source $HOME/.cargo/env && cargo install cargo-rpm
# Build pkgs
RUN source $HOME/.cargo/env && cargo rpm init && cargo rpm build
CMD ["sh"]

31
dist/build/aarch64_debian9/Dockerfile vendored Normal file
View File

@@ -0,0 +1,31 @@
FROM debian:stretch
ARG branch
ENV branch=$branch
WORKDIR /usr/src/
# Install dependencies
RUN apt update && apt install -y \
git \
gcc \
pkg-config \
libdbus-1-dev \
build-essential \
bash \
curl
# Install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \
chmod +x /tmp/rust.sh && \
/tmp/rust.sh -y
# Clone repository
RUN git clone --branch $branch https://github.com/veeso/termscp.git
# Set workdir to termscp
WORKDIR /usr/src/termscp/
# Install cargo deb
RUN . $HOME/.cargo/env && cargo install cargo-deb
# Build for x86_64
RUN . $HOME/.cargo/env && cargo build --release
# Build pkgs
RUN . $HOME/.cargo/env && cargo deb
CMD ["bash"]

39
dist/build/linux-aarch64.sh vendored Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <version>"
exit 1
fi
VERSION=$1
set -e # Don't fail
# Create pkgs directory
cd ..
PKGS_DIR=$(pwd)/pkgs
cd -
mkdir -p ${PKGS_DIR}/
# Build aarch64_deb
cd aarch64_debian9/
docker buildx build --platform linux/arm64 --build-arg branch=${VERSION} --tag termscp-${VERSION}-aarch64_debian9 .
cd -
mkdir -p ${PKGS_DIR}/deb/
mkdir -p ${PKGS_DIR}/aarch64-unknown-linux-gnu/
CONTAINER_NAME=$(docker create termscp-${VERSION}-aarch64_debian9 /bin/bash)
docker cp ${CONTAINER_NAME}:/usr/src/termscp/target/debian/termscp_${VERSION}_arm64.deb ${PKGS_DIR}/deb/
docker cp ${CONTAINER_NAME}:/usr/src/termscp/target/release/termscp ${PKGS_DIR}/aarch64-unknown-linux-gnu/
# Make tar.gz
cd ${PKGS_DIR}/aarch64-unknown-linux-gnu/
tar cvzf termscp-v${VERSION}-aarch64-unknown-linux-gnu.tar.gz termscp
rm termscp
cd -
# Build aarch64_centos7
cd aarch64_centos7/
docker buildx build --platform linux/arm64 --build-arg branch=${VERSION} --tag termscp-${VERSION}-aarch64_centos7 .
cd -
mkdir -p ${PKGS_DIR}/rpm/
CONTAINER_NAME=$(docker create termscp-${VERSION}-aarch64_centos7 /bin/bash)
docker cp ${CONTAINER_NAME}:/usr/src/termscp/target/release/rpmbuild/RPMS/aarch64/termscp-${VERSION}-1.el7.aarch64.rpm ${PKGS_DIR}/rpm/termscp-${VERSION}-1.aarch64.rpm
exit $?

View File

@@ -1,7 +1,7 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: docker.sh <version>"
echo "Usage: $0 <version>"
exit 1
fi

39
dist/build/macos.sh vendored
View File

@@ -1,11 +1,30 @@
#!/bin/sh
make_pkg() {
ARCH=$1
VERSION=$2
TARGET_DIR="$3"
if [ -z "$TARGET_DIR" ]; then
TARGET_DIR=target/release/
fi
ROOT_DIR=$(pwd)
cd $TARGET_DIR
PKG="termscp-v${VERSION}-${ARCH}-apple-darwin.tar.gz"
tar czf $PKG termscp
HASH=$(sha256sum $PKG)
mkdir -p ${ROOT_DIR}/dist/pkgs/macos/
mv $PKG ${ROOT_DIR}/dist/pkgs/macos/$PKG
cd -
echo "$HASH"
}
if [ -z "$1" ]; then
echo "Usage: macos.sh <version>"
exit 1
fi
VERSION=$1
export BUILD_ROOT=$(pwd)/../../
set -e # Don't fail
@@ -17,14 +36,18 @@ if [ ! -f Cargo.toml ]; then
exit 1
fi
# Build release
cargo build --release && cargo strip
# Build release (x86_64)
cargo build --release
# Make pkg
cd target/release/
PKG="termscp-v${VERSION}-x86_64-apple-darwin.tar.gz"
tar czf $PKG termscp
sha256sum $PKG
mkdir -p ../../dist/pkgs/macos/
mv $PKG ../../dist/pkgs/macos/$PKG
X86_64_HASH=$(make_pkg "x86_64" $VERSION)
cd $BUILD_ROOT
# Build ARM64 pkg
cargo build --release --target aarch64-apple-darwin
# Make pkg
ARM64_HASH=$(make_pkg "arm64" $VERSION "target/aarch64-apple-darwin/release/")
echo "x86_64 hash: $X86_64_HASH"
echo "arm64 hash: $ARM64_HASH"
exit $?

View File

@@ -14,7 +14,7 @@ cargo build --release
# Make zip
$zipName = "termscp-v$version-x86_64-pc-windows-msvc.zip"
Set-Location .\target\release\
Compress-Archive termscp.exe $zipName
Compress-Archive -Force termscp.exe $zipName
# Get checksum
checksum.exe -t sha256 $zipName
Get-FileHash $zipName
Move-Item $zipName .\..\..\dist\pkgs\windows\$zipName

View File

@@ -8,8 +8,6 @@ RUN apt update && apt install -y \
git \
gcc \
pkg-config \
libssl-dev \
libssh2-1-dev \
libdbus-1-dev \
curl
# Clone repository

View File

@@ -7,11 +7,12 @@ WORKDIR /usr/src/
RUN yum -y install \
git \
gcc \
openssl \
pkgconfig \
gcc \
make \
dbus-devel \
openssl-devel \
bash
bash \
rpm-build
# Install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh && \
chmod +x /tmp/rust.sh && \
@@ -20,10 +21,10 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > /tmp/rust.sh &&
RUN git clone --branch $branch https://github.com/veeso/termscp.git
# Set workdir to termscp
WORKDIR /usr/src/termscp/
# Install cargo arxch
RUN source $HOME/.cargo/env && cargo install cargo-rpm cargo-strip
# Build for x86_64
RUN source $HOME/.cargo/env && cargo build --release && cargo strip
RUN source $HOME/.cargo/env && cargo build --release
# Install cargo rpm
RUN source $HOME/.cargo/env && cargo install cargo-rpm
# Build pkgs
RUN source $HOME/.cargo/env && yum -y install rpm-build && cargo rpm init && cargo rpm build
RUN source $HOME/.cargo/env && cargo rpm init && cargo rpm build
CMD ["sh"]

View File

@@ -6,8 +6,6 @@ RUN apt update && apt install -y \
git \
gcc \
pkg-config \
libssl-dev \
libssh2-1-dev \
libdbus-1-dev \
curl
@@ -20,9 +18,9 @@ RUN git clone https://github.com/veeso/termscp.git
# Set workdir to termscp
WORKDIR /usr/src/termscp/
# Install cargo deb
RUN . $HOME/.cargo/env && cargo install cargo-deb cargo-strip
RUN . $HOME/.cargo/env && cargo install cargo-deb
# Build for x86_64
RUN . $HOME/.cargo/env && cargo build --release && cargo strip
RUN . $HOME/.cargo/env && cargo build --release
# Build pkgs
RUN . $HOME/.cargo/env && cargo deb

View File

@@ -8,9 +8,8 @@ RUN apt update && apt install -y \
git \
gcc \
pkg-config \
libssl-dev \
libssh2-1-dev \
libdbus-1-dev \
build-essential \
bash \
curl
@@ -23,9 +22,9 @@ RUN git clone --branch $branch https://github.com/veeso/termscp.git
# Set workdir to termscp
WORKDIR /usr/src/termscp/
# Install cargo deb
RUN . $HOME/.cargo/env && cargo install cargo-deb cargo-strip
RUN . $HOME/.cargo/env && cargo install cargo-deb
# Build for x86_64
RUN . $HOME/.cargo/env && cargo build --release && cargo strip
RUN . $HOME/.cargo/env && cargo build --release
# Build pkgs
RUN . $HOME/.cargo/env && cargo deb

View File

@@ -63,7 +63,7 @@
</p>
<p align="center">Entwickelt von <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
<p align="center">Aktuelle Version: 0.8.0 (06/01/2022)</p>
<p align="center">Aktuelle Version: 0.11.0 (20/02/2023)</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT"
@@ -118,11 +118,6 @@
src="https://coveralls.io/repos/github/veeso/termscp/badge.svg"
alt="Coveralls"
/></a>
<a href="https://docs.rs/termscp"
><img
src="https://docs.rs/termscp/badge.svg"
alt="Docs"
/></a>
</p>
---
@@ -141,7 +136,7 @@ Termscp ist ein funktionsreicher Terminal-Dateitransfer und Explorer mit Unterst
- **SFTP**
- **SCP**
- **FTP** und **FTPS**
- **Aws S3**
- **S3**
- 🖥 Erkunden und bedienen Sie das Dateisystem der Fernbedienung und des lokalen Computers mit einer praktischen Benutzeroberfläche
- Erstellen, Entfernen, Umbenennen, Suchen, Anzeigen und Bearbeiten von Dateien
- ⭐ Verbinden Sie sich über integrierte Lesezeichen und aktuelle Verbindungen mit Ihren Lieblingshosts
@@ -155,6 +150,7 @@ Termscp ist ein funktionsreicher Terminal-Dateitransfer und Explorer mit Unterst
- Anpassbare Dateisortierung
- und viele andere Parameter...
- 📫 Lassen Sie sich benachrichtigen, wenn eine große Datei übertragen wurde
- 🔭 Halten Sie Dateiänderungen mit dem Remote-Host synchron
- 🔐 Speichern Sie Ihr Passwort in Ihrem Betriebssystem-Schlüsseltresor
- 🦀 Rust-powered
- 👀 Entwickelt, um die Leistung im Auge zu behalten
@@ -223,12 +219,10 @@ Sie können mit einer dieser Plattformen spenden:
---
## User manual and Documentation 📚
## User manual 📚
Das Benutzerhandbuch finden Sie auf der [termscp-Website](https://veeso.github.io/termscp/#user-manual) oder auf [Github](man.md).
Die Entwicklerdokumentation finden Sie in Rust Docs unter <https://docs.rs/termscp>
---
## Contributing and issues 🤝🏻

View File

@@ -5,7 +5,8 @@
- [Address argument 🌎](#address-argument-)
- [AWS S3 address argument](#aws-s3-address-argument)
- [How Password can be provided 🔐](#how-password-can-be-provided-)
- [Aws S3 credentials 🦊](#aws-s3-credentials-)
- [S3 connection parameters](#s3-connection-parameters)
- [S3 credentials 🦊](#s3-credentials-)
- [File explorer 📂](#file-explorer-)
- [Keybindings ⌨](#keybindings-)
- [Work on multiple files 🥷](#work-on-multiple-files-)
@@ -27,6 +28,7 @@
- [Text Editor ✏](#text-editor-)
- [Logging 🩺](#logging-)
- [Notifications 📫](#notifications-)
- [File watcher 🔭](#file-watcher-)
> ❗ I need a help to translate this manual into German. If you want to contribute to the translations, please open a PR 🙏
@@ -36,7 +38,12 @@ termscp can be started with the following options:
`termscp [options]... [protocol://user@address:port:wrkdir] [local-wrkdir]`
OR
`termscp [options]... -b [bookmark-name] [local-wrkdir]`
- `-P, --password <password>` if address is provided, password will be this argument
- `-b, --address-as-bookmark` resolve address argument as a bookmark name
- `-c, --config` Open termscp starting from the configuration page
- `-q, --quiet` Disable logging
- `-t, --theme <path>` Import specified theme
@@ -44,11 +51,11 @@ termscp can be started with the following options:
- `-v, --version` Print version info
- `-h, --help` Print help page
termscp can be started in two different mode, if no extra arguments is provided, termscp will show the authentication form, where the user will be able to provide the parameters required to connect to the remote peer.
termscp can be started in three different modes, if no extra arguments is provided, termscp will show the authentication form, where the user will be able to provide the parameters required to connect to the remote peer.
Alternatively, the user can provide an address as argument to skip the authentication form and starting directly the connection to the remote server.
If address argument is provided you can also provide the start working directory for local host
If address argument or bookmark name is provided you can also provide the start working directory for local host
### Address argument 🌎
@@ -109,7 +116,27 @@ Password can be basically provided through 3 ways when address argument is provi
---
## Aws S3 credentials 🦊
## S3 connection parameters
These parameters are required to connect to aws s3 and other s3 compatible servers:
- AWS S3:
- **bucket name**
- **region**
- *profile* (if not provided: "default")
- *access key* (unless if public)
- *secret access key* (unless if public)
- *security token* (if required)
- *session token* (if required)
- new path style: **NO**
- Other S3 endpoints:
- **bucket name**
- **endpoint**
- *access key* (unless if public)
- *secret access key* (unless if public)
- new path style: **YES**
### S3 credentials 🦊
In order to connect to an Aws S3 bucket you must obviously provide some credentials.
There are basically three ways to achieve this.
@@ -177,9 +204,11 @@ In order to change panel you need to type `<LEFT>` to move the remote explorer p
| `<M>` | Select a file | Mark |
| `<N>` | Create new file with provided name | New |
| `<O|F4>` | Edit file; see Text editor | Open |
| `<P>` | Open log panel | Panel |
| `<Q|F10>` | Quit termscp | Quit |
| `<R|F6>` | Rename file | Rename |
| `<S|F2>` | Save file as... | Save |
| `<T>` | Synchronize changes to selected path to remote | Track |
| `<U>` | Go to parent directory | Upper |
| `<V|F3>` | Open file with default program for filetype | View |
| `<W>` | Open file with provided program | With |
@@ -187,6 +216,7 @@ In order to change panel you need to type `<LEFT>` to move the remote explorer p
| `<Y>` | Toggle synchronized browsing | sYnc |
| `<CTRL+A>` | Select all files | |
| `<CTRL+C>` | Abort file transfer process | |
| `<CTRL+T>` | Show all synchronized paths | Track |
### Work on multiple files 🥷
@@ -486,3 +516,26 @@ Termscp will send Desktop notifications for these kind of events:
❗ If you prefer to keep notifications turned off, you can just enter setup and set `Enable notifications?` to `No` 😉.
❗ If you want to change the minimum transfer size to display notifications, you can change the value in the configuration with key `Notifications: minimum transfer size` and set it to whatever suits better for you 🙂.
## File watcher 🔭
The file watcher allows you to setup a list of paths to synchronize with the remote hosts.
This means that whenever a change on the local file system will be detected on the synchronized path, the change will be automatically reported to the configured remote host path, within 5 seconds.
You can set as many paths to synchronize as you prefer:
1. Put the cursor on the local explorer on the directory/file you want to keep synchronized
2. Go to the directory you want the changes to be reported to on the remote host
3. Press `<T>`
4. Answer `<YES>` to the radio popup
To unwatch, just press `<T>` on the local synchronized path (or to any of its subfolders)
OR you can just press `<CTRL+T>` and press `<ENTER>` to the synchronized path you want to unwatch.
These changes will be reported to the remote host:
- New files, file changes
- File moved/renamed
- File removed/unlinked
> ❗ The watcher works only in one direction (local > remote). It is NOT possible to synchronize automatically the changes from remote to local.

View File

@@ -63,7 +63,7 @@
</p>
<p align="center">Desarrollado por <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
<p align="center">Versión actual: 0.8.0 (06/01/2022)</p>
<p align="center">Versión actual: 0.11.0 (20/02/2023)</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT"
@@ -118,11 +118,6 @@
src="https://coveralls.io/repos/github/veeso/termscp/badge.svg"
alt="Coveralls"
/></a>
<a href="https://docs.rs/termscp"
><img
src="https://docs.rs/termscp/badge.svg"
alt="Docs"
/></a>
</p>
---
@@ -141,7 +136,7 @@ Termscp es un explorador y transferencia de archivos de terminal rico en funcion
- **SFTP**
- **SCP**
- **FTP** y **FTPS**
- **Aws S3**
- **S3**
- 🖥 Explore y opere en el sistema de archivos de la máquina local y remota con una interfaz de usuario práctica
- Cree, elimine, cambie el nombre, busque, vea y edite archivos
- ⭐ Conéctese a sus hosts favoritos y conexiones recientes
@@ -155,6 +150,7 @@ Termscp es un explorador y transferencia de archivos de terminal rico en funcion
- Clasificación de archivos personalizable
- y muchos otros parámetros ...
- 📫 Reciba una notificación cuando se haya transferido un archivo grande
- 🔭 Mantenga los cambios de archivos sincronizados con el host remoto
- 🔐 Guarde su contraseña en el almacén de claves de su sistema operativo
- 🦀 Rust-powered
- 👀 Desarrollado sin perder de vista el rendimiento
@@ -227,8 +223,6 @@ Puedes hacer una donación con una de estas plataformas:
El manual del usuario se puede encontrar en el [sitio web de termscp](https://veeso.github.io/termscp/#user-manual) o en [Github](man.md).
La documentación para desarrolladores se puede encontrar en Rust Docs en <https://docs.rs/termscp>
---
## Contribuir y problemas 🤝🏻

View File

@@ -5,7 +5,8 @@
- [Argumento dirección 🌎](#argumento-dirección-)
- [Argumento dirección por AWS S3](#argumento-dirección-por-aws-s3)
- [Cómo se puede proporcionar la contraseña 🔐](#cómo-se-puede-proporcionar-la-contraseña-)
- [Credenciales de AWS S3 🦊](#credenciales-de-aws-s3-)
- [S3 parámetros de conexión](#s3-parámetros-de-conexión)
- [Credenciales de S3 🦊](#credenciales-de-s3-)
- [Explorador de archivos 📂](#explorador-de-archivos-)
- [Keybindings ⌨](#keybindings-)
- [Trabaja en varios archivos 🥷](#trabaja-en-varios-archivos-)
@@ -27,6 +28,7 @@
- [Text Editor ✏](#text-editor-)
- [Logging 🩺](#logging-)
- [Notificaciones 📫](#notificaciones-)
- [Observador de archivos 🔭](#observador-de-archivos-)
> ❗ Este documento ha sido traducido con Google Translator (y luego lo he revisado a grandes rasgos, pero no puedo hablar el idioma muy bien). Si habla l'idioma, abra un [issue](https://github.com/veeso/termscp/issues/new/choose) utilizando la label COPY o abra un PR 🙏
@@ -36,7 +38,12 @@ termscp se puede iniciar con las siguientes opciones:
`termscp [options]... [protocol://user@address:port:wrkdir] [local-wrkdir]`
OR
`termscp [options]... -b [bookmark-name] [local-wrkdir]`
- `-P, --password <password>` si se proporciona la dirección, la contraseña será este argumento
- `-b, --address-as-bookmark` resuelve el argumento de la dirección como un nombre de marcador
- `-c, --config` Abrir termscp comenzando desde la página de configuración
- `-q, --quiet` Deshabilitar el registro
- `-t, --theme <path>` Importar tema especificado
@@ -109,7 +116,27 @@ La contraseña se puede proporcionar básicamente a través de 3 formas cuando s
---
## Credenciales de AWS S3 🦊
## S3 parámetros de conexión
Estos parámetros son necesarios para conectarse a aws s3 y otros servidores compatibles con s3:
- AWS S3:
- **bucket name**
- **region**
- *profile* (si no se proporciona: "default")
- *access key* (A menos que sea pública)
- *secret access key* (A menos que sea pública)
- *security token* (si es requerido)
- *session token* (si es requerido)
- new path style: **NO**
- Otros puntos finales de S3:
- **bucket name**
- **endpoint**
- *access key* (A menos que sea pública)
- *secret access key* (A menos que sea pública)
- new path style: **YES**
### Credenciales de S3 🦊
Para conectarse a un bucket de Aws S3, obviamente debe proporcionar algunas credenciales.
Básicamente, hay tres formas de lograr esto.
@@ -177,9 +204,11 @@ Para cambiar de panel, debe escribir `<LEFT>` para mover el panel del explorador
| `<M>` | Seleccione un archivo | Mark |
| `<N>` | Crear un nuevo archivo con el nombre proporcionado | New |
| `<O|F4>` | Editar archivo | Open |
| `<P>` | Open log panel | Panel |
| `<Q|F10>` | Salir de termscp | Quit |
| `<R|F6>` | Renombrar archivo | Rename |
| `<S|F2>` | Guardar archivo como... | Save |
| `<T>` | Sincronizar los cambios en la ruta seleccionada con el control remoto | Track |
| `<U>` | Ir al directorio principal | Upper |
| `<V|F3>` | Abrir archivo con el programa predeterminado | View |
| `<W>` | Abrir archivo con el programa proporcionado | With |
@@ -187,6 +216,7 @@ Para cambiar de panel, debe escribir `<LEFT>` para mover el panel del explorador
| `<Y>` | Alternar navegación sincronizada | sYnc |
| `<CTRL+A>` | Seleccionar todos los archivos | |
| `<CTRL+C>` | Abortar el proceso de transferencia de archivos | |
| `<CTRL+T>` | Mostrar todas las rutas sincronizadas | Track |
### Trabaja en varios archivos 🥷
@@ -485,3 +515,26 @@ Termscp enviará notificaciones de escritorio para este tipo de eventos:
❗ Si prefiere mantener las notificaciones desactivadas, puede simplemente ingresar a la configuración y configurar `Enable notifications?` En `No` 😉.
❗ Si desea cambiar el tamaño mínimo de transferencia para mostrar notificaciones, puede cambiar el valor en la configuración con la tecla `Notifications: minimum transfer size` y configurarlo como mejor le convenga 🙂.
## Observador de archivos 🔭
El observador de archivos le permite configurar una lista de rutas para sincronizar con los hosts remotos.
Esto significa que siempre que se detecte un cambio en el sistema de archivos local en la ruta sincronizada, el cambio se informará automáticamente a la ruta del host remoto configurado, dentro de los 5 segundos.
Puede establecer tantas rutas para sincronizar como prefiera:
1. Coloque el cursor en el explorador local en el directorio/archivo que desea mantener sincronizado
2. Vaya al directorio en el que desea que se informen los cambios en el host remoto
3. Presione `<T>`
4. Responda `<YES>` a la ventana emergente de radio
Para dejar de mirar, simplemente presione `<T>` en la ruta sincronizada local (o en cualquiera de sus subcarpetas)
O simplemente puede presionar `<CTRL + T>` y presionar `<ENTER>` en la ruta sincronizada que desea dejar de ver.
Estos cambios se informarán al host remoto:
- Nuevos archivos, cambios de archivos
- Archivo movido / renombrado
- Archivo eliminado/desvinculado
> ❗ El vigilante trabaja solo en una dirección (local > remota). NO es posible sincronizar automáticamente los cambios de remoto a local.

View File

@@ -63,7 +63,7 @@
</p>
<p align="center">Développé par <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
<p align="center">Version actuelle: 0.8.0 (06/01/2022)</p>
<p align="center">Version actuelle: 0.11.0 (20/02/2023)</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT"
@@ -118,11 +118,6 @@
src="https://coveralls.io/repos/github/veeso/termscp/badge.svg"
alt="Coveralls"
/></a>
<a href="https://docs.rs/termscp"
><img
src="https://docs.rs/termscp/badge.svg"
alt="Docs"
/></a>
</p>
---
@@ -141,7 +136,7 @@ Termscp est un file transfer et explorateur de fichiers de terminal riche en fon
- **SFTP**
- **SCP**
- **FTP** et **FTPS**
- **Aws S3**
- **S3**
- 🖥 Explorer et opérer sur le système de fichiers distant et local avec une interface utilisateur pratique.
- Créer, supprimer, renommer, rechercher, afficher et modifier des fichiers
- ⭐ Connectez-vous à vos hôtes préférés via des signets et des connexions récentes.
@@ -155,6 +150,7 @@ Termscp est un file transfer et explorateur de fichiers de terminal riche en fon
- tri de fichiers personallisable
- et bien d'autres paramètres...
- 📫 Recevez une notification quande un gros fichier est télécharger.
- 🔭 Gardez les modifications de fichiers synchronisées avec l'hôte distant
- 🔐 Enregistre tes mots de passe dans le key vault du systeme.
- 🦀 Rust-powered
- 👀 Développé en gardant un œil sur les performances

View File

@@ -5,7 +5,8 @@
- [Argument d'adresse 🌎](#argument-dadresse-)
- [Argument d'adresse AWS S3](#argument-dadresse-aws-s3)
- [Comment le mot de passe peut être fourni 🔐](#comment-le-mot-de-passe-peut-être-fourni-)
- [Identifiants AWS S3 🦊](#identifiants-aws-s3-)
- [S3 paramètres de connexion](#s3-paramètres-de-connexion)
- [Identifiants S3 🦊](#identifiants-s3-)
- [Explorateur de fichiers 📂](#explorateur-de-fichiers-)
- [Raccourcis clavier ⌨](#raccourcis-clavier-)
- [Travailler sur plusieurs fichiers 🥷](#travailler-sur-plusieurs-fichiers-)
@@ -27,6 +28,7 @@
- [Éditeur de texte ✏](#éditeur-de-texte-)
- [Fichier Journal 🩺](#fichier-journal-)
- [Notifications 📫](#notifications-)
- [Observateur de fichiers 🔭](#observateur-de-fichiers-)
## Usage ❓
@@ -34,7 +36,12 @@ termscp peut être démarré avec les options suivantes :
`termscp [options]... [protocol://user@address:port:wrkdir] [local-wrkdir]`
ou
`termscp [options]... -b [bookmark-name] [local-wrkdir]`
- `-P, --password <password>` si l'adresse est fournie, le mot de passe sera cet argument
- `-b, --address-as-bookmark` résoudre l'argument d'adresse en tant que nom de signet
- `-c, --config` Ouvrir termscp à partir de la page de configuration
- `-q, --quiet` Désactiver la journalisation
- `-t, --theme <path>` Importer le thème spécifié
@@ -107,7 +114,27 @@ Le mot de passe peut être fourni de 3 manières lorsque l'argument d'adresse es
---
## Identifiants AWS S3 🦊
## S3 paramètres de connexion
Ces paramètres sont requis pour se connecter à aws s3 et à d'autres serveurs compatibles s3 :
- AWS S3:
- **bucket name**
- **region**
- *profile* (si non fourni : "par défaut")
- *access key* (sauf si public)
- *secret access key* (sauf si public)
- *security token* (si nécessaire)
- *session token* (si nécessaire)
- new path style: **NO**
- Autres points de terminaison S3:
- **bucket name**
- **endpoint**
- *access key* (sauf si public)
- *secret access key* (sauf si public)
- new path style: **YES**
### Identifiants S3 🦊
Afin de vous connecter à un compartiment Aws S3, vous devez évidemment fournir des informations d'identification.
Il existe essentiellement trois manières d'y parvenir.
@@ -175,9 +202,11 @@ Pour changer de panneau, vous devez taper `<LEFT>` pour déplacer le panneau de
| `<M>` | Sélectionner un fichier | Mark |
| `<N>` | Créer un nouveau fichier avec le nom fourni | New |
| `<O|F4>` | Modifier le fichier | Open |
| `<P>` | Ouvre le panel de journals | Panel |
| `<Q|F10>` | Quitter termscp | Quit |
| `<R|F6>` | Renommer le fichier | Rename |
| `<S|F2>` | Enregistrer le fichier sous... | Save |
| `<T>` | Synchroniser les modifications apportées au chemin sélectionné | Track |
| `<U>` | Aller dans le répertoire parent | Upper |
| `<V|F3>` | Ouvrir le fichier avec le programme défaut pour le type de fichier | View |
| `<W>` | Ouvrir le fichier avec le programme spécifié | With |
@@ -185,6 +214,7 @@ Pour changer de panneau, vous devez taper `<LEFT>` pour déplacer le panneau de
| `<Y>` | Basculer la navigation synchronisée | sYnc |
| `<CTRL+A>` | Sélectionner tous les fichiers | |
| `<CTRL+C>` | Abandonner le processus de transfert de fichiers | |
| `<CTRL+T>` | Afficher tous les chemins synchronisés | Track |
### Travailler sur plusieurs fichiers 🥷
@@ -484,3 +514,26 @@ Termscp enverra des notifications de bureau pour ce type d'événements :
❗ Si vous préférez désactiver les notifications, vous pouvez simplement accéder à la configuration et définir `Enable notifications?` sur `No` 😉.
❗ Si vous souhaitez modifier la taille de transfert minimale pour afficher les notifications, vous pouvez modifier la valeur dans la configuration avec la touche `Notifications: minimum transfer size` et la définir sur ce qui vous convient le mieux 🙂.
## Observateur de fichiers 🔭
L'observateur de fichiers vous permet de configurer une liste de chemins à synchroniser avec les hôtes distants.
Cela signifie que chaque fois qu'un changement sur le système de fichiers local sera détecté sur le chemin synchronisé, le changement sera automatiquement signalé au chemin de l'hôte distant configuré, dans les 5 secondes.
Vous pouvez définir autant de chemins à synchroniser que vous préférez :
1. Placez le curseur de l'explorateur local sur le répertoire/fichier que vous souhaitez conserver synchronisé
2. Accédez au répertoire dans lequel vous souhaitez que les modifications soient signalées sur l'hôte distant
3. Appuyez sur `<T>`
4. Répondez `<YES>` à la fenêtre contextuelle de la radio
Pour annuler la surveillance, appuyez simplement sur `<T>` sur le chemin synchronisé local (ou sur l'un de ses sous-dossiers)
OU vous pouvez simplement appuyer sur `<CTRL + T>` et appuyer sur `<ENTER>` jusqu'au chemin synchronisé que vous souhaitez désactiver.
Ces modifications seront signalées à l'hôte distant :
- Nouveaux fichiers, modifications de fichiers
- Fichier déplacé / renommé
- Fichier supprimé / dissocié
> ❗ Le watcher ne fonctionne que dans un sens (local > distant). Il n'est PAS possible de synchroniser automatiquement les changements de distant à local.

View File

@@ -63,7 +63,7 @@
</p>
<p align="center">Sviluppato da <a href="https://veeso.github.io/" target="_blank">@veeso</a></p>
<p align="center">Versione corrente: 0.8.0 (06/01/2022)</p>
<p align="center">Versione corrente: 0.11.0 (20/02/2023)</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT"
@@ -118,11 +118,6 @@
src="https://coveralls.io/repos/github/veeso/termscp/badge.svg"
alt="Coveralls"
/></a>
<a href="https://docs.rs/termscp"
><img
src="https://docs.rs/termscp/badge.svg"
alt="Docs"
/></a>
</p>
---
@@ -141,7 +136,7 @@ Termscp è un file transfer ed explorer ricco di funzionalità, con supporto a S
- **SFTP**
- **SCP**
- **FTP** and **FTPS**
- **Aws S3**
- **S3**
- 🖥 Esplora e opera sia sul file system locale che su quello remoto con una UI di facile utilizzo.
- Crea, rimuove, rinomina, cerca, visualizza e modifica file
- ⭐ Connettiti ai tuoi host preferiti tramite la funzionalità integrata dei segnalibri e delle connessioni recenti.
@@ -155,6 +150,7 @@ Termscp è un file transfer ed explorer ricco di funzionalità, con supporto a S
- Imposta l'ordinamento di file e cartelle
- e tanto altro...
- 📫 Ricevi notifiche desktop quando un file di cospicue dimensioni è stato trasferito
- 🔭 Mantieni sincronizzate le modifiche con l'host remoto
- 🔐 Salva le password degli host remoti nel keyring predefinito dal tuo sistema operativo
- 🦀 Rust-powered
- 👀 Progettato tenendo conto delle performance
@@ -223,12 +219,10 @@ Puoi fare una donazione tramite una di queste piattaforme:
---
## Manuale e documentazione 📚
## Manuale utente 📚
Il manuale utente lo puoi trovare sul [sito di termscp](https://veeso.github.io/termscp/#user-manual) o su [Github](man.md).
La documentazione per sviluppatori la puoi trovare su Rust Docs <https://docs.rs/termscp>.
---
## Contributi e issues 🤝🏻

View File

@@ -5,7 +5,8 @@
- [Argomento indirizzo 🌎](#argomento-indirizzo-)
- [Argomento indirizzo per AWS S3](#argomento-indirizzo-per-aws-s3)
- [Come fornire la password 🔐](#come-fornire-la-password-)
- [Credenziali Aws S3 🦊](#credenziali-aws-s3-)
- [Parametri di connessione S3](#parametri-di-connessione-s3)
- [Credenziali S3 🦊](#credenziali-s3-)
- [File explorer 📂](#file-explorer-)
- [Abbinamento tasti ⌨](#abbinamento-tasti-)
- [Lavora su più file 🥷](#lavora-su-più-file-)
@@ -27,6 +28,7 @@
- [Editor di testo ✏](#editor-di-testo-)
- [Logging 🩺](#logging-)
- [Notifiche 📫](#notifiche-)
- [File watcher 🔭](#file-watcher-)
## Argomenti da linea di comando ❓
@@ -34,7 +36,12 @@ termscp può essere lanciato con questi argomenti:
`termscp [options]... [protocol://user@address:port:wrkdir] [local-wrkdir]`
O
`termscp [options]... -b [bookmark-name] [local-wrkdir]`
- `-P, --password <password>` Se viene fornito l'argomento indirizzo, questa sarà la password utilizzata per autenticarsi
- `-b, --address-as-bookmark` risolve l'argomento indirizzo come nome di un segnalibro
- `-c, --config` Apri la configurazione di termscp
- `-q, --quiet` Disabilita i log
- `-t, --theme <path>` Importa il tema al percorso fornito
@@ -104,7 +111,27 @@ Quando si usa l'argomento indirizzo non è possibile fornire la password diretta
---
## Credenziali Aws S3 🦊
## Parametri di connessione S3
Questi parametri sono necessari per connettersi ad un bucket Aws s3 o ad uno storage compatibile:
- AWS S3:
- **bucket name**
- **region**
- *profile* (se non fornito: "default")
- *access key* (a meno che non sia pubblico)
- *secret access key* (a meno che non sia pubblico)
- *security token* (se necessario)
- *session token* (se necessario)
- new path style: **NO**
- Other S3 endpoints:
- **bucket name**
- **endpoint**
- *access key* (a meno che non sia pubblico)
- *secret access key* (a meno che non sia pubblico)
- new path style: **YES**
### Credenziali S3 🦊
Per connettersi ad un bucket S3 devi come già saprai fornire le credenziali fornite da AWS.
Ci sono tre modi per passare queste credenziali a termscp.
@@ -171,9 +198,11 @@ Per cambiare pannello ti puoi muovere con le frecce, `<LEFT>` per andare sul pan
| `<M>` | Seleziona file | Mark |
| `<N>` | Crea nuovo file con il nome fornito | New |
| `<O|F4>` | Modifica file; Vedi text editor | Open |
| `<P>` | Apri pannello log | Panel |
| `<Q|F10>` | Termina termscp | Quit |
| `<R|F6>` | Rinomina file | Rename |
| `<S|F2>` | Salva file con nome | Save |
| `<T>` | Sincronizza il percorso locale con l'host remoto | Track |
| `<U>` | Vai alla directory padre | Upper |
| `<V|F3>` | Apri il file con il programma definito dal sistema | View |
| `<W>` | Apri il file con il programma specificato | With |
@@ -181,6 +210,7 @@ Per cambiare pannello ti puoi muovere con le frecce, `<LEFT>` per andare sul pan
| `<Y>` | Abilita/disabilita Sync-Browsing | sYnc |
| `<CTRL+A>` | Seleziona tutti i file | |
| `<CTRL+C>` | Annulla trasferimento file | |
| `<CTRL+T>` | Visualizza tutti i percorsi sincronizzati | Track |
### Lavora su più file 🥷
@@ -482,3 +512,26 @@ termscp invierà notifiche destkop per i seguenti eventi:
❗ Se vuoi disabilitare le notifiche, è sufficiente andare in configurazione ed impostare `Enable notifications?` a `No` 😉.
❗ Se vuoi modificare la soglia minima per le notifiche dei trasferimenti, puoi impostare il valore di `Notifications: minimum transfer size` in configurazione 🙂.
## File watcher 🔭
Il file watcher ti permette di impostare una lista di percorsi da sincronizzare con l'host remoto.
Ciò implica che ogni volta che una modifica verrà rilevata al percorso sincronizzato, la modifica verrà automaticamente sincronizzata con l'host remoto, entro 5 secondi.
Puoi impostare quanti percorsi preferisci da sincronizzare:
1. Porta il cursore dell'explorer sulla cartella/file che vuoi sincronizzare
2. Vai alla directory sull'explorer remoto dove vuoi riportare le modifiche
3. Premi `<T>`
4. Rispondi `<YES>` alla domanda se vuoi sincronizzare il percorso
Per terminare la sincronizzazione, premi `<T>`, al percorso locale sincronizzato (od in qualsiasi sua sottocartella)
OPPURE, puoi semplicemente premere `<CTRL+T>` e premi `<ENTER>` sul percorso che vuoi desincronizzare.
Queste modifiche verranno applicate sull'host remoto:
- Nuovi file, modifiche
- File spostati o rinominati
- File rimossi
> ❗ Il watcher funziona solo in maniera unidirezionale locale > remoto. NON è possibile tracciare le modifiche da remoto a locale.

View File

@@ -5,7 +5,8 @@
- [Address argument 🌎](#address-argument-)
- [AWS S3 address argument](#aws-s3-address-argument)
- [How Password can be provided 🔐](#how-password-can-be-provided-)
- [Aws S3 credentials 🦊](#aws-s3-credentials-)
- [S3 connection parameters](#s3-connection-parameters)
- [S3 credentials 🦊](#s3-credentials-)
- [File explorer 📂](#file-explorer-)
- [Keybindings ⌨](#keybindings-)
- [Work on multiple files 🥷](#work-on-multiple-files-)
@@ -27,6 +28,7 @@
- [Text Editor ✏](#text-editor-)
- [Logging 🩺](#logging-)
- [Notifications 📫](#notifications-)
- [File watcher 🔭](#file-watcher-)
## Usage ❓
@@ -34,7 +36,12 @@ termscp can be started with the following options:
`termscp [options]... [protocol://user@address:port:wrkdir] [local-wrkdir]`
OR
`termscp [options]... -b [bookmark-name] [local-wrkdir]`
- `-P, --password <password>` if address is provided, password will be this argument
- `-b, --address-as-bookmark` resolve address argument as a bookmark name
- `-c, --config` Open termscp starting from the configuration page
- `-q, --quiet` Disable logging
- `-t, --theme <path>` Import specified theme
@@ -42,11 +49,11 @@ termscp can be started with the following options:
- `-v, --version` Print version info
- `-h, --help` Print help page
termscp can be started in two different mode, if no extra arguments is provided, termscp will show the authentication form, where the user will be able to provide the parameters required to connect to the remote peer.
termscp can be started in three different modes, if no extra arguments is provided, termscp will show the authentication form, where the user will be able to provide the parameters required to connect to the remote peer.
Alternatively, the user can provide an address as argument to skip the authentication form and starting directly the connection to the remote server.
If address argument is provided you can also provide the start working directory for local host
If address argument or bookmark name is provided you can also provide the start working directory for local host
### Address argument 🌎
@@ -107,7 +114,27 @@ Password can be basically provided through 3 ways when address argument is provi
---
## Aws S3 credentials 🦊
## S3 connection parameters
These parameters are required to connect to aws s3 and other s3 compatible servers:
- AWS S3:
- **bucket name**
- **region**
- *profile* (if not provided: "default")
- *access key* (unless if public)
- *secret access key* (unless if public)
- *security token* (if required)
- *session token* (if required)
- new path style: **NO**
- Other S3 endpoints:
- **bucket name**
- **endpoint**
- *access key* (unless if public)
- *secret access key* (unless if public)
- new path style: **YES**
### S3 credentials 🦊
In order to connect to an Aws S3 bucket you must obviously provide some credentials.
There are basically three ways to achieve this:
@@ -175,9 +202,11 @@ In order to change panel you need to type `<LEFT>` to move the remote explorer p
| `<M>` | Select a file | Mark |
| `<N>` | Create new file with provided name | New |
| `<O|F4>` | Edit file; see Text editor | Open |
| `<P>` | Open log panel | Panel |
| `<Q|F10>` | Quit termscp | Quit |
| `<R|F6>` | Rename file | Rename |
| `<S|F2>` | Save file as... | Save |
| `<T>` | Synchronize changes to selected path to remote | Track |
| `<U>` | Go to parent directory | Up |
| `<V|F3>` | Open file with default program for filetype | View |
| `<W>` | Open file with provided program | With |
@@ -185,6 +214,7 @@ In order to change panel you need to type `<LEFT>` to move the remote explorer p
| `<Y>` | Toggle synchronized browsing | sYnc |
| `<CTRL+A>` | Select all files | |
| `<CTRL+C>` | Abort file transfer process | |
| `<CTRL+T>` | Show all synchronized paths | Track |
### Work on multiple files 🥷
@@ -484,3 +514,28 @@ Termscp will send Desktop notifications for these kind of events:
❗ If you prefer to keep notifications turned off, you can just enter setup and set `Enable notifications?` to `No` 😉.
❗ If you want to change the minimum transfer size to display notifications, you can change the value in the configuration with key `Notifications: minimum transfer size` and set it to whatever suits better for you 🙂.
---
## File watcher 🔭
The file watcher allows you to setup a list of paths to synchronize with the remote hosts.
This means that whenever a change on the local file system will be detected on the synchronized path, the change will be automatically reported to the configured remote host path, within 5 seconds.
You can set as many paths to synchronize as you prefer:
1. Put the cursor on the local explorer on the directory/file you want to keep synchronized
2. Go to the directory you want the changes to be reported to on the remote host
3. Press `<T>`
4. Answer `<YES>` to the radio popup
To unwatch, just press `<T>` on the local synchronized path (or to any of its subfolders)
OR you can just press `<CTRL+T>` and press `<ENTER>` to the synchronized path you want to unwatch.
These changes will be reported to the remote host:
- New files, file changes
- File moved/renamed
- File removed/unlinked
> ❗ The watcher works only in one direction (local > remote). It is NOT possible to synchronize automatically the changes from remote to local.

View File

@@ -8,7 +8,7 @@ Features:
- SFTP
- SCP
- FTP and FTPS
- Aws S3
- S3
- 🖥 Explore and operate on the remote and on the local machine file system with a handy UI
- Create, remove, rename, search, view and edit files
- ⭐ Connect to your favourite hosts through built-in bookmarks and recent connections

View File

@@ -4,7 +4,7 @@
<img src="/assets/images/termscp.svg" width="256" height="256" />
</p>
<p align="center">~ 功能丰富的终端文件传输 ~</p>
<p align="center">~ 功能丰富的终端文件传输工具 ~</p>
<p align="center">
<a href="https://veeso.github.io/termscp/" target="_blank">网站</a>
·
@@ -63,7 +63,7 @@
</p>
<p align="center"><a href="https://veeso.github.io/" target="_blank">@veeso</a> 开发</p>
<p align="center">当前版本: 0.8.0 (06/01/2022)</p>
<p align="center">当前版本: 0.11.0 (20/02/2023)</p>
<p align="center">
<a href="https://opensource.org/licenses/MIT"
@@ -118,57 +118,55 @@
src="https://coveralls.io/repos/github/veeso/termscp/badge.svg"
alt="Coveralls"
/></a>
<a href="https://docs.rs/termscp"
><img
src="https://docs.rs/termscp/badge.svg"
alt="Docs"
/></a>
</p>
---
## 关于 termscp 🖥
termscp 是一个功能丰富的终端文件传输和浏览器,支持 SCP/SFTP/FTP/S3。 所以基本上是一个带有 TUI 的终端实用程序,用于连接到远程服务器检索和上传文件并与本地文件系统进行交互。
它与 **Linux**、**MacOS**、**FreeBSD** 和 **Windows** 兼容。
termscp 是一个功能丰富的终端文件浏览和传输工具,支持 SCP/SFTP/FTP/S3。 作为一个带有 TUI 的命令行工具,它可以连接到远程服务器进行文件检索和上传,并能够与本地文件系统进行交互。
兼容 **Linux**、**MacOS**、**FreeBSD** 和 **Windows** 操作系统。
![Explorer](/assets/images/explorer.gif)
---
## 特 🎁
## 特 🎁
- 📁 不同的通讯协议
- 📁 支持多种通信协议
- **SFTP**
- **SCP**
- **FTP** and **FTPS**
- **Aws S3**
- 🖥 使用便的 UI 在远程和本地机器文件系统上探索和操作
- **S3**
- 🖥 使用便的 UI 在远程和本地文件系统上浏览和操作
- 创建、删除、重命名、搜索、查看和编辑文件
- ⭐ 通过内置书签最近连接连接到您最喜欢的主机
- ⭐ 通过内置书签”和“最近连接”快速连接到您的主机
- 📝 使用您喜欢的应用程序查看和编辑文件
- 💁 使用 SSH 密钥和用户名/密码进行 SFTP/SCP 身份验证
- 🐧 Windows、Linux、FreeBSD 和 MacOS 兼容
- 🎨 让它成为你的
- 🐧 兼容 Windows、Linux、FreeBSD 和 MacOS 操作系统
- 🎨 丰富的个性化设置
- 主题
- 自定义文件浏览器格式
-定制的文本编辑器
-定制的文件排序
- 和许多其他参数...
- 📫 传输大文件时通过桌面通知获得通知
-选择的文本编辑器
-选择的文件排序
- 探索更多功能...
- 📫 传输大文件时通过桌面通知获得提醒
- 🔭 与远程主机文件更改保持同步
- 🔐 将密码保存在操作系统密钥保管库中
- 🦀 Rust 动力
- 👀 开发时注意性能
- 🦄 频繁的精彩更新
- 🦀 Rust 提供强力支持
- 👀 开发时更注重性能
- 🦄 快速且精彩迭代
---
## 开始 🚀
如果您正在考虑安装termscp,我要感谢您💜! 希望你会喜欢termscp
非常荣幸您能考虑安装termscp💜 希望你会喜欢termscp
如果您想为此项目做出贡献,请不要忘记查看我们的贡献指南。 [阅读更多](../../CONTRIBUTING.md)
如果您是 Linux、FreeBSD 或 MacOS 用户,这个简单的 shell 脚本将使用单个命令在您的系统上安装 termscp
如果您是 Linux、FreeBSD 或 MacOS 用户,使用以下简单的 shell 脚本通过单行指令在您的系统上安装 termscp
```sh
curl --proto '=https' --tlsv1.2 -sSLf "https://git.io/JBhDb" | sh
@@ -180,11 +178,11 @@ curl --proto '=https' --tlsv1.2 -sSLf "https://git.io/JBhDb" | sh
choco install termscp
```
如需更多信息或其他平台,请访问 [veeso.github.io](https://veeso.github.io/termscp/#get-started) 查看所有安装方法。
如需更多信息或其他平台支持,请访问 [veeso.github.io](https://veeso.github.io/termscp/#get-started) 查看所有安装方法。
⚠️ 如果您正在寻找如何更新 termscp 只需从 CLI 运行 termscp `(sudo) termscp --update` ⚠️
### 要求
### 依赖
- **Linux** 用户:
- libssh
@@ -195,9 +193,9 @@ choco install termscp
- dbus
- pkgconf
### 可选要求 ✔️
### 可选 ✔️
这些要求不是运行 termscp 的强制要求,而是要享受它的所有功能
通过执行以下操作以享受软件的完整功能,但不做强制要求
- **Linux/FreeBSD** 用户:
-`V` **打开** 文件(至少其中之一)
@@ -215,11 +213,11 @@ choco install termscp
## 支持我 ☕
如果您喜欢 termscp 并且希望看到该项目不断发展和改进,请考虑在 **Buy me a coffee**捐款以支持我🥳
如果您喜欢 termscp 并且希望看到该项目不断发展和改进,请考虑在 **Buy me a coffee**赞赏以支持我🥳
[![ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/veeso)
或者,如果您愿意,您也可以在 PayPal 上捐款
或者,如果您愿意,您也可以在 PayPal 上赞赏我
[![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://www.paypal.me/chrisintin)
@@ -227,28 +225,27 @@ choco install termscp
## 用户手册和文档 📚
用户手册可以在[termscp的网站](https://veeso.github.io/termscp/#user-manual)上找到 或者在[Github](man.md)上。
开发者文档可以在 <https://docs.rs/termscp> 的 Rust Docs 上找到。
用户手册可以在[termscp的网站](https://veeso.github.io/termscp/#user-manual)或者在[Github](man.md)上找到
---
## 贡献和问题 🤝🏻
欢迎贡献、错误报告、新功能和问题! 😉
如果您有任何问题或疑虑或者您想建议新功能或者您只想改进termscp请随时打开问题或 PR。
欢迎贡献、bug报告、新功能和问题! 😉
如果您有任何问题或困惑或者您想建议新功能或者您只是想改进termscp请随时打开 issue 或 PR。
请遵循 [我们的贡献指南](../../CONTRIBUTING.md)
---
## 更日志 ⏳
## 更日志 ⏳
查看termscp的更新日志 [这里](../../CHANGELOG.md)
查看termscp的 [更新日志](../../CHANGELOG.md)
---
## 供电 💪
## 支持 💪
termscp 由这些很棒的项目提供支持:
@@ -269,9 +266,9 @@ termscp 由这些很棒的项目提供支持:
---
## 画廊 🎬
## 演示 🎬
>
> 首页
![Auth](/assets/images/auth.gif)
@@ -289,8 +286,8 @@ termscp 由这些很棒的项目提供支持:
---
## 执照 📃
## 许可协议 📃
“termscp” MIT 许可下获得许可。
“termscp”使用 MIT 许可。
您可以阅读整个许可证 [这里](../../LICENSE)
您可以阅读整个 [许可证](../../LICENSE)

View File

@@ -5,7 +5,8 @@
- [地址参数](#地址参数)
- [AWS S3 地址参数](#aws-s3-地址参数)
- [如何输入密码](#如何输入密码)
- [Aws S3 凭证](#aws-s3-凭证)
- [S3 连接参数](#s3-连接参数)
- [Aws S3 凭证](#aws-s3-凭证)
- [文件浏览](#文件浏览)
- [快捷键](#快捷键)
- [处理多个文件](#处理多个文件)
@@ -27,6 +28,7 @@
- [文本编辑器](#文本编辑器)
- [日志](#日志)
- [通知](#通知)
- [文件观察者🔭](#文件观察者)
## 用法
@@ -34,7 +36,12 @@ termscp启动时可以使用以下选项:
`termscp [options]... [protocol://user@address:port:wrkdir] [local-wrkdir]`
或作为
`termscp [options]... -b [bookmark-name] [local-wrkdir]`
- `-P, --password <password>` 登陆密码
- `-b, --address-as-bookmark` 将地址参数解析为书签名称
- `-c, --config` 打开termscp时打开配置页面
- `-q, --quiet` 禁用日志
- `-t, --theme <path>` 导入自定义主题
@@ -105,7 +112,27 @@ s3://buckethead@eu-central-1:default:/assets
---
## Aws S3 凭证
## S3 连接参数
这些参数是连接到 aws s3 和其他 s3 兼容服务器所必需的:
- AWS S3:
- **bucket name**
- **region**
- *profile* (如果未提供“default”)
- *access key* (除非公开)
- *secret access key* (除非公开)
- *security token* (如果需要的话)
- *session token* (如果需要的话)
- new path style: **NO**
- 其他 S3 端点:
- **bucket name**
- **endpoint**
- *access key* (如果需要的话)
- *secret access key* (如果需要的话)
- new path style: **YES**
### Aws S3 凭证
为了连接到 Aws S3 存储桶,您显然必须提供一些凭据。
因此,您可以通过以下方式为 s3 提供凭据:
@@ -172,9 +199,11 @@ termscp中的文件资源管理器是指你与远程建立连接后可以看到
| `<M>` | 选中文件 | Mark |
| `<N>` | 使用键入的名称新建文件 | New |
| `<O|F4>` | 编辑文件;参考文本编辑器文档 | Open |
| `<P>` | 打开日志面板 | Panel |
| `<Q|F10>` | 退出termscp | Quit |
| `<R|F7>` | 重命名文件 | Rename |
| `<S|F2>` | 另存为... | Save |
| `<T>` | 显示所有同步路径 | Track |
| `<U>` | 进入上层目录 | Upper |
| `<V|F3>` | 使用默认方式打开文件 | View |
| `<W>` | 使用指定程序打开文件 | With |
@@ -182,6 +211,7 @@ termscp中的文件资源管理器是指你与远程建立连接后可以看到
| `<Y>` | 是否开启同步浏览 | sYnc |
| `<CTRL+A>` | 选中所有文件 | |
| `<CTRL+C>` | 终止文件传输 | |
| `<CTRL+T>` | 显示所有同步路径 | Track |
### 处理多个文件
@@ -476,3 +506,26 @@ termscp 将针对这些类型的事件发送桌面通知:
❗ 如果您希望保持关闭通知,您只需进入设置并将 `Enable notifications?` 设置为 `No`😉。
❗ 如果您想更改最小传输大小以显示通知,您可以使用键 `Notifications: minimum transfer size` 更改配置中的值,并将其设置为更适合您的任何值🙂。
## 文件观察者🔭
文件观察器允许您设置与远程主机同步的路径列表。
这意味着每当在同步路径上检测到本地文件系统的更改时,该更改将在 5 秒内自动报告给配置的远程主机路径。
您可以根据需要设置尽可能多的同步路径:
1.将光标放在本地资源管理器上要保持同步的目录/文件上
2. 转到远程主机上要向其报告更改的目录
3. 按`<T>`
4. 对无线电弹出窗口回答 `<YES>`
要取消观看,只需在本地同步路径(或其任何子文件夹)上按 `<T>`
或者,您可以按 `<CTRL + T>` 并按 `<ENTER>` 进入要取消观看的同步路径。
这些更改将报告给远程主机:
- 新文件,文件更改
- 文件移动/重命名
- 文件删除/取消链接
> ❗ 观察者只在一个方向工作(本地>远程)。不可能自动同步远程到本地的更改。

View File

@@ -8,10 +8,14 @@
# -f, -y, --force, --yes
# Skip the confirmation prompt during installation
TERMSCP_VERSION="0.8.0"
TERMSCP_VERSION="0.11.0"
GITHUB_URL="https://github.com/veeso/termscp/releases/download/v${TERMSCP_VERSION}"
DEB_URL="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb"
RPM_URL="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.x86_64.rpm"
DEB_URL_AMD64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb"
DEB_URL_AARCH64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_arm64.deb"
RPM_URL_AMD64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.x86_64.rpm"
RPM_URL_AARCH64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.aarch64.rpm"
PATH="$PATH:/usr/sbin"
set -eu
printf "\n"
@@ -28,6 +32,15 @@ NO_COLOR="$(tput sgr0 2>/dev/null || printf '')"
# Functions
set_termscp_version() {
TERMSCP_VERSION="$1"
GITHUB_URL="https://github.com/veeso/termscp/releases/download/v${TERMSCP_VERSION}"
DEB_URL_AMD64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_amd64.deb"
DEB_URL_AARCH64="${GITHUB_URL}/termscp_${TERMSCP_VERSION}_arm64.deb"
RPM_URL_AMD64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.x86_64.rpm"
RPM_URL_AARCH64="${GITHUB_URL}/termscp-${TERMSCP_VERSION}-1.aarch64.rpm"
}
info() {
printf '%s\n' "${BOLD}${GREY}>${NO_COLOR} $*"
}
@@ -92,16 +105,20 @@ test_writeable() {
}
elevate_priv() {
if ! has sudo; then
error 'Could not find the command "sudo", needed to install termscp on your system.'
info "If you are on Windows, please run your shell as an administrator, then"
info "rerun this script. Otherwise, please run this script as root, or install"
info "sudo."
exit 1
fi
if ! sudo -v; then
if has sudo; then
if ! sudo -v; then
error "Superuser not granted, aborting installation"
exit 1
fi
sudo="sudo"
elif has doas; then
sudo="doas"
else
error 'Could not find the commands "sudo" or "doas", needed to install termscp on your system.'
info "If you are on Windows, please run your shell as an administrator, then"
info "rerun this script. Otherwise, please run this script as root, or install"
info "sudo or doas."
exit 1
fi
}
@@ -110,9 +127,7 @@ elevate_priv_ex() {
if test_writeable "$check_dir"; then
sudo=""
else
warn "Root permissions are required to install dependecies"
elevate_priv
sudo="sudo"
fi
echo $sudo
}
@@ -153,11 +168,6 @@ detect_arch() {
arch="arm"
fi
if [ "${arch}" != "x86_64" ]; then
error "Unsupported arch ${arch}"
return 1
fi
printf '%s' "${arch}"
}
@@ -182,7 +192,7 @@ confirm() {
# Installers
install_on_bsd() {
try_with_cargo "packages for freeBSD are distribuited no more. Only cargo installations are supported."
try_with_cargo "packages for freeBSD are distribuited no more. Only cargo installations are supported." "freebsd"
}
install_on_arch_linux() {
@@ -216,66 +226,77 @@ install_on_linux() {
elif has pikaur; then
install_on_arch_linux pikaur
elif has dpkg; then
if [ "${ARCH}" != "x86_64" ]; then # It's okay on AUR; not on other distros
try_with_cargo "we don't distribute packages for ${ARCH} at the moment"
case "${ARCH}" in
x86_64) DEB_URL="$DEB_URL_AMD64" ;;
aarch64) DEB_URL="$DEB_URL_AARCH64" ;;
*) try_with_cargo "we don't distribute packages for ${ARCH} at the moment" && return $? ;;
esac
info "Detected dpkg on your system"
info "Installing ${GREEN}termscp${NO_COLOR} via Debian package"
archive=$(get_tmpfile "deb")
download "${archive}" "${DEB_URL}"
info "Downloaded debian package to ${archive}"
if test_writeable "/usr/bin"; then
sudo=""
msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…"
else
info "Detected dpkg on your system"
info "Installing ${GREEN}termscp${NO_COLOR} via Debian package"
archive=$(get_tmpfile "deb")
download "${archive}" "${DEB_URL}"
info "Downloaded debian package to ${archive}"
if test_writeable "/usr/bin"; then
sudo=""
msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…"
else
warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}"
elevate_priv
sudo="sudo"
msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…"
fi
info "$msg"
$sudo dpkg -i "${archive}"
rm -f ${archive}
warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}"
elevate_priv
sudo="sudo"
msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…"
fi
info "$msg"
$sudo dpkg -i "${archive}"
rm -f ${archive}
elif has rpm; then
if [ "${ARCH}" != "x86_64" ]; then # It's okay on AUR; not on other distros
try_with_cargo "we don't distribute packages for ${ARCH} at the moment"
case "${ARCH}" in
x86_64) RPM_URL="$RPM_URL_AMD64" ;;
aarch64) RPM_URL="$RPM_URL_AARCH64" ;;
*) try_with_cargo "we don't distribute packages for ${ARCH} at the moment" && return $? ;;
esac
info "Detected rpm on your system"
info "Installing ${GREEN}termscp${NO_COLOR} via RPM package"
archive=$(get_tmpfile "rpm")
download "${archive}" "${RPM_URL}"
info "Downloaded rpm package to ${archive}"
if test_writeable "/usr/bin"; then
sudo=""
msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…"
else
info "Detected rpm on your system"
info "Installing ${GREEN}termscp${NO_COLOR} via RPM package"
archive=$(get_tmpfile "rpm")
download "${archive}" "${RPM_URL}"
info "Downloaded rpm package to ${archive}"
if test_writeable "/usr/bin"; then
sudo=""
msg="Installing ${GREEN}termscp${NO_COLOR}, please wait…"
else
warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}"
elevate_priv
sudo="sudo"
msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…"
fi
info "$msg"
$sudo rpm -U "${archive}"
rm -f ${archive}
warn "Root permissions are required to install ${GREEN}termscp${NO_COLOR}"
elevate_priv
sudo="sudo"
msg="Installing ${GREEN}termscp${NO_COLOR} as root, please wait…"
fi
info "$msg"
$sudo rpm -U "${archive}"
rm -f ${archive}
else
try_with_cargo "No suitable installation method found for your Linux distribution; if you're running on Arch linux, please install an AUR package manager (such as yay). Currently only Arch, Debian based and Red Hat based distros are supported"
try_with_cargo "No suitable installation method found for your Linux distribution; if you're running on Arch linux, please install an AUR package manager (such as yay). Currently only Arch, Debian based and Red Hat based distros are supported" "linux"
fi
}
install_on_macos() {
if has brew; then
# get homebrew formula name
if [ "${ARCH}" == "x86_64" ]; then
FORMULA="termscp"
elif [ "$ARCH" == "aarch64" ]; then
FORMULA="termscp-m1"
else
error "unsupported arch: $ARCH"
exit 1
fi
if has termscp; then
info "Upgrading ${GREEN}termscp${NO_COLOR}"
# The OR is used since someone could have installed via cargo previously
brew update && brew upgrade termscp || brew install veeso/termscp/termscp
brew update && brew upgrade ${FORMULA} || brew install veeso/termscp/${FORMULA}
else
info "Installing ${GREEN}termscp${NO_COLOR}"
brew install veeso/termscp/termscp
brew install veeso/termscp/${FORMULA}
fi
else
try_with_cargo "brew is missing on your system; please install it from <https://brew.sh/>"
try_with_cargo "brew is missing on your system; please install it from <https://brew.sh/>" "macos"
fi
}
@@ -290,7 +311,7 @@ install_bsd_cargo_deps() {
}
install_linux_cargo_deps() {
local debian_deps="gcc pkg-config libssl-dev libssh2-1-dev libdbus-1-dev"
local debian_deps="gcc pkg-config libdbus-1-dev"
local rpm_deps="gcc openssl pkgconfig libdbus-devel openssl-devel"
local arch_deps="gcc openssl pkg-config dbus"
local deps_cmd=""
@@ -346,11 +367,12 @@ install_cargo() {
try_with_cargo() {
err="$1"
platform="$2"
# Install cargo
install_cargo
if has cargo; then
info "Installing ${GREEN}termscp${NO_COLOR} via Cargo…"
case $PLATFORM in
case $platform in
"freebsd")
install_bsd_cargo_deps
cargo install --locked --no-default-features termscp
@@ -392,6 +414,7 @@ fi
# parse argv variables
while [ "$#" -gt 0 ]; do
echo $1
case "$1" in
-V | --verbose)
@@ -410,7 +433,10 @@ while [ "$#" -gt 0 ]; do
FORCE="${1#*=}"
shift 1
;;
-v=* | --version=*)
set_termscp_version "${1#*=}"
shift 1
;;
*)
error "Unknown option: $1"
exit 1
@@ -456,7 +482,7 @@ info "If you're a new user, you might be interested in reading the user manual <
info "While if you've just updated your termscp version, you can find the changelog at this link <https://veeso.github.io/termscp/#changelog>"
info "Remember that if you encounter any issue, you can report them on Github <https://github.com/veeso/termscp/issues/new>"
info "Feel free to open an issue also if you have an idea which could improve the project"
info "If you want to support the project, please, consider a little donation <https://www.buymeacoffee.com/veeso>"
info "If you want to support the project, please, consider a little donation <https://ko-fi.com/veeso>"
info "I hope you'll enjoy using termscp :D"
exit 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

45
site/css/get-started.css Normal file
View File

@@ -0,0 +1,45 @@
.start h1 {
font-size: 2.5em;
}
.start h2 {
font-size: 2em;
}
.start h3 {
font-size: 1.6em;
}
.start h2 i,
h3 i {
color: #606060;
}
.start .sub-system {
padding: 0px 2em;
}
.start .sub-system .installation {
padding: 0px 2em;
width: 80%;
}
.start .installation {
padding: 2px 4em;
width: 80%;
}
.start .installation p {
font-size: 1.3em;
font-weight: 300;
}
.start .installation li {
font-size: 1.1em;
font-weight: 300;
}
.start .installation a {
text-decoration: none;
color: dodgerblue;
}

121
site/css/intro.css Normal file
View File

@@ -0,0 +1,121 @@
/** Intro */
.intro {
text-align: center;
}
.intro .title {
font-size: 5em;
}
.intro .logo {
border-radius: 25%;
height: auto;
width: 256px;
}
.intro .caption {
font-size: 2em;
font-weight: 300;
width: 100%;
}
.intro .get-started {
background-color: #404040;
border-radius: 0.5em;
color: snow;
font-size: 1.5em;
}
.intro .get-started a {
color: snow;
text-decoration: none;
}
.intro .features {
align-content: stretch;
align-items: flex-start;
border-top: 1px solid #eee;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-top: 2.5rem;
padding: 1.2rem 0;
}
.intro .feature {
flex: auto;
}
@media (min-width: 600px) {
.intro .feature {
flex-grow: 1;
flex-basis: 30%;
max-width: 30%;
}
}
.intro .feature h3 {
color: #101010;
font-size: 1.5em;
font-weight: 400;
}
.intro .feature p {
color: #303030;
}
.intro .preview {
border-radius: 5px;
padding: 5% 10%;
width: 80%;
}
.intro .preview video {
height: auto;
width: 100%;
}
.intro .discover {
align-content: stretch;
align-items: flex-start;
border-top: 1px solid #eee;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin-left: 0;
margin-top: 2.5rem;
padding: 1.2rem 0;
width: 100%;
}
@media (min-width: 600px) {
.intro .discover {
margin-left: 20%;
width: 60%;
}
}
.intro .discover .hook {
flex-grow: 1;
flex-basis: 30%;
font-size: 1.5em;
max-width: 30%;
}
.intro .discover .hook a {
text-decoration: none;
color: #404040;
}
.intro .discover .hook a i {
font-size: 0.8em;
}
.intro .discover .hook a {
transition: all 0.4s ease-in;
}
.intro .discover .hook a:hover {
color: dodgerblue;
}

179
site/css/main.css Normal file
View File

@@ -0,0 +1,179 @@
html {
scroll-behavior: smooth;
}
body {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
pre {
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
color: #d0d0d0;
background-color: #222629;
border-radius: 3px;
word-wrap: normal;
border-radius: 0.5em;
}
pre .function {
color: #f08d49;
}
pre .string {
color: #7ec699;
}
h1,
h2,
h3,
h4,
h5 {
font-weight: 300;
}
header {
margin: 0 2em 0 0;
}
.img-circle {
border-radius: 50%;
}
.pull-left {
float: left;
}
.pull-right {
float: right;
}
section.page {
width: 100%;
height: auto;
border-top: 1px solid #aaa;
display: inline-block;
padding-bottom: 2em;
}
section.page hr {
margin: 1em 0 1em 0;
}
.container {
width: 90%;
height: auto;
margin-left: auto;
margin-right: auto;
overflow: auto;
}
.container header a {
color: inherit;
text-decoration: none;
border-bottom: dotted 1px #80808080;
cursor: text;
}
.container header a i {
color: #606060;
}
/** Footer */
footer {
text-align: center;
background-color: #eee;
padding: 1em;
}
footer .contacts {
list-style: none;
cursor: default;
margin-block-start: 0;
padding-inline-start: 0;
}
footer .contacts li {
display: inline-block;
}
footer .contacts a {
border: 0;
font-size: 3em;
color: #606060;
display: inline-block;
width: 2em;
height: 2em;
line-height: 2em;
text-align: center;
text-decoration: none;
}
footer .contacts a i {
transition: all 0.4s ease-in;
}
footer .contacts li a:hover i {
color: dodgerblue !important;
}
footer p.copyright {
color: #404040;
font-weight: 300;
text-align: center;
}
.alert {
border: 1px solid transparent;
border-radius: 0.25rem;
margin-top: 1rem;
margin-bottom: 1rem;
padding: 0.5rem;
position: relative;
}
.alert-center {
margin-left: auto;
margin-right: auto;
width: 50%;
}
.alert-warning {
background-color: #fff3cd;
border-color: #ffeeba;
color: #856404;
}
.alert-danger {
background-color: #f8d7da;
border-color: #f5c6cb;
color: #721c24;
}
.alert-success {
background-color: #d4edda;
border-color: #c3e6cb;
color: #155724;
}
.alert-primary {
background-color: #cce5ff;
border-color: #b8daff;
color: #004085;
}
/* ko-fi */
.floatingchat-container-wrap {
left: auto !important;
right: 16px !important;
}
.floating-chat-kofi-popup-iframe {
left: auto !important;
right: 16px !important;
}

97
site/css/markdown.css Normal file
View File

@@ -0,0 +1,97 @@
.markdown {
font-family: Arial, Helvetica, sans-serif;
}
.markdown a {
color: dodgerblue;
text-decoration: none;
}
.markdown a:hover {
text-decoration: underline;
}
.markdown p {
color: #202020;
font-size: 1.1em;
}
.markdown h1 {
font-size: 2em;
}
.markdown h2 {
font-size: 1.6em;
}
.markdown h3 {
font-size: 1.4em;
}
.markdown h4 {
font-size: 1.2em;
}
.markdown img {
display: none;
}
@media (min-width: 600px) {
.markdown img {
display: block;
width: 60%;
margin-left: 20%;
}
}
.markdown blockquote {
border-left: 0.25em solid #ccc;
color: #606060;
font-size: 90%;
padding: 0.1em;
padding-left: 0.5em;
}
.markdown blockquote p {
color: #606060;
}
.markdown pre code {
background-color: inherit;
font-size: 100%;
}
.markdown code {
background-color: #eee;
border-radius: 6px;
font-size: 85%;
padding: 0.2em 0.4em;
}
.markdown table {
border-collapse: collapse;
border-spacing: 0;
display: block;
height: fit-content;
max-width: 100%;
overflow: auto;
width: max-content;
}
.markdown table tr {
border-top: 1px solid #c6cbd1;
}
.markdown table tr {
background-color: white;
}
.markdown table tr:nth-child(even) {
background-color: #dfe2e5;
}
.markdown table td,
.markdown table th {
border: 1px solid #c6cbd1;
padding: 6px 13px;
}

268
site/css/menu.css Normal file
View File

@@ -0,0 +1,268 @@
/** Menu */
#menu {
margin-left: -20vw; /* "#menu" width */
width: 20vw;
position: fixed;
top: 0;
left: 0;
bottom: 0;
z-index: 1000; /* so the menu or its navicon stays above all content */
background: #f0f0f0;
overflow-y: auto;
}
/*
All anchors inside the menu should be styled like this.
*/
#menu a {
color: #606060;
border: none;
padding: 0.6em 0 0.6em 0.6em;
font-size: 1.4em;
}
/*
Remove all background/borders, since we are applying them to #menu.
*/
#menu .pure-menu,
#menu .pure-menu ul {
border: none;
background: transparent;
}
/*
Add that light border to separate items into groups.
*/
#menu .pure-menu ul,
#menu .pure-menu .menu-item-divided {
border-top: 1px solid #808080;
}
#menu .pure-menu i {
margin-right: 1ch;
}
#menu .pure-menu-item i {
font-size: 0.6em;
}
/*
Change color of the anchor links on hover/focus.
*/
#menu .pure-menu li a:hover,
#menu .pure-menu li a:focus {
background: #ccc;
}
/*
This styles the selected menu item `<li>`.
*/
#menu .pure-menu-selected {
background: #ddd;
}
#menu .pure-menu-selected i {
color: dodgerblue;
}
/*
This styles a link within a selected menu item `<li>`.
*/
#menu .pure-menu-selected a {
color: dodgerblue;
font-weight: 500;
}
/*
This styles the menu heading.
*/
#menu .pure-menu-heading {
color: #202020;
margin: 0;
margin: 10% 5% 10% 5%;
position: relative;
font-weight: 700;
}
#menu .pure-menu-heading .avatar {
width: 30%;
border-radius: 0.5em;
}
#menu .pure-menu-heading h1 {
font-size: 1.4em;
text-transform: none;
}
#menu .pure-menu-heading p {
color: #404040;
font-size: 1.1em;
font-weight: 300;
text-transform: none;
white-space: normal;
}
#menu .pure-menu-bottom {
bottom: 0;
display: none;
left: 0;
position: absolute;
text-align: center;
width: 100%;
}
@media (min-width: 640px) {
#menu .pure-menu-bottom {
display: block;
}
}
#menu .pure-menu-bottom a {
font-size: 1.5em;
color: #606060;
display: inline-block;
text-align: center;
border: 0;
text-decoration: none;
text-align: center;
white-space: normal;
}
#menu .pure-menu-bottom a:hover {
color: #404040;
}
#menu .pure-menu-bottom ul {
list-style: none;
cursor: default;
margin-block-start: 0;
padding-inline-start: 0;
}
#menu .pure-menu-bottom ul li {
display: inline-block;
text-align: center;
}
/* -- Dynamic Button For Responsive Menu -------------------------------------*/
/*
The button to open/close the Menu is custom-made and not part of Pure. Here's
how it works:
*/
/*
`.menu-link` represents the responsive menu toggle that shows/hides on
small screens.
*/
.menu-link {
position: fixed;
display: block; /* show this only on small screens */
top: 0;
left: 0; /* "#menu width" */
background: #eee;
background: rgba(0, 0, 0, 0.7);
font-size: 10px; /* change this value to increase/decrease button size */
z-index: 10;
width: 2em;
height: auto;
padding: 2.1em 1.6em;
}
.menu-link:hover,
.menu-link:focus {
background: #202020;
}
.menu-link span {
position: relative;
display: block;
}
.menu-link span,
.menu-link span:before,
.menu-link span:after {
background-color: #fff;
pointer-events: none;
width: 100%;
height: 0.2em;
}
.menu-link span:before,
.menu-link span:after {
position: absolute;
margin-top: -0.6em;
content: " ";
}
.menu-link span:after {
margin-top: 0.6em;
}
/* -- Responsive Styles (Media Queries) ------------------------------------- */
#layout,
#menu,
.menu-link {
-webkit-transition: all 0.2s ease-out;
-moz-transition: all 0.2s ease-out;
-ms-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
#layout {
position: relative;
left: 0;
padding-left: 0;
}
#layout.active #menu {
left: 20vw;
width: 240px;
}
#layout.active .menu-link {
left: 240px;
}
/*
Hides the menu at `640px`, but modify this based on your app's needs.
*/
@media (min-width: 640px) {
.header {
padding-left: 2em;
padding-right: 2em;
}
#layout {
padding-left: 20vw; /* left col width "#menu" */
left: 0;
}
#menu {
left: 20vw;
}
.menu-link {
position: fixed;
left: 20vw;
display: none;
}
#layout.active .menu-link {
left: 20vw;
}
}
@media (max-width: 640px) {
/* Only apply this when the window is small. Otherwise, the following
case results in extra padding on the left:
* Make the window small.
* Tap the menu to trigger the active state.
* Make the window large again.
*/
#main.active {
position: relative;
left: 20vw;
}
}

38
site/css/updates.css Normal file
View File

@@ -0,0 +1,38 @@
.updates h1 {
font-size: 2.5em;
}
.updates h2 {
font-size: 2em;
}
.updates h3 {
font-size: 1.6em;
}
.updates h2 i,
h3 i {
color: #606060;
}
.updates .desc {
font-size: 1.1em;
text-align: justify;
}
.updates ol {
font-size: 1.2em;
}
.wall-of-text {
color: #444;
line-height: 1.8em;
margin: 0 auto;
text-align: justify;
width: 90%;
}
.tl-dr {
font-size: 1.2em;
font-weight: bold;
}

215
site/html/get-started.html Normal file
View File

@@ -0,0 +1,215 @@
<head>
<link rel="stylesheet" href="css/get-started.css" />
</head>
<body>
<section id="start" class="container start">
<h1 translate="getStarted.title">Get started</h1>
<section>
<h2>
<i class="fa fa-rocket"></i>&nbsp;<span
translate="getStarted.quickSetup"
>Quick setup</span
>
</h2>
<div class="installation">
<div class="alert alert-primary">
<p>
<i class="fas fa-info-circle"></i>
<span translate="getStarted.suggested"
>We strongly suggest this method to install termscp</span
>
</p>
</div>
<p translate="getStarted.posixUsers">
If you are a Linux, a FreeBSD or a MacOS user, you can install termscp
via this simple command , which will use a shell script installer:
</p>
<pre><span class="function">curl</span> --proto <span class="string">'=https'</span> --tlsv1.2 -sSLf <span class="string">"https://git.io/JBhDb"</span> | sh</pre>
</div>
</section>
<section>
<h2>
<i class="devicon-windows8-plain"></i>&nbsp;<span
translate="getStarted.windows.title"
>Windows users</span
>
</h2>
<div class="installation">
<p>
<span translate="getStarted.windows.intro"
>You can install termscp on Windows via</span
>
<a
href="https://community.chocolatey.org/packages/termscp"
target="_blank"
>Chocolatey</a
>
</p>
<pre><span class="function">choco</span> install <span class="string">termscp</span></pre>
<p>
<span translate="getStarted.windows.moderation"
>Consider that Chocolatey moderation can take up to a few weeks
since last release, so if the latest version is not available yet,
you can install it downloading the ZIP file from</span
>
<a
href="https://github.com/veeso/termscp/releases/latest/download/termscp.0.11.0.nupkg"
target="_blank"
>Github</a
>
<span translate="getStarted.windows.then"
>and then, from the ZIP directory, install it via</span
>
</p>
<pre><span class="function">choco</span> install <span class="string">termscp</span> -s .</pre>
</div>
</section>
<section>
<h2>
<i class="devicon-linux-plain"></i>&nbsp;<span
translate="getStarted.linuxUsers"
>Linux users</span
>
</h2>
<div class="sub-system">
<div class="alert alert-warning">
<p>
<i class="fas fa-exclamation-triangle"></i>
<span translate="getStarted.notConfident"
>Opt for these methods instead if you don't feel confident using
the shell script</span
>
</p>
</div>
<h3>
<i class="devicon-linux-plain"></i>&nbsp;<span
translate="getStarted.arch.title"
>Arch derived users</span
>
</h3>
<div class="installation">
<p>
<span translate="getStarted.arch.intro"
>On Arch Linux based distros, you can install termscp using an AUR
package manager such as</span
>
<a href="https://github.com/Jguer/yay" target="_blank">yay</a>
<span translate="getStarted.arch.then">then run:</span>
</p>
<pre><span class="function">yay</span> -S <span class="string">termscp</span></pre>
</div>
<h3>
<i class="devicon-debian-plain"></i>&nbsp;<span
translate="getStarted.debian.title"
>Debian derived users</span
>
</h3>
<div class="installation">
<p translate="getStarted.debian.body">
On Debian based distros, you can install termscp using the Deb
package via:
</p>
<pre><span class="function">wget</span> -O termscp.deb <span class="string">https://github.com/veeso/termscp/releases/latest/download/termscp_0.11.0_amd64.deb</span>
sudo <span class="function">dpkg</span> -i <span class="string">termscp.deb</span></pre>
</div>
<h3>
<i class="devicon-redhat-plain"></i>&nbsp;<span
translate="getStarted.redhat.title"
>Redhat derived users</span
>
</h3>
<div class="installation">
<p translate="getStarted.redhat.body">
On RedHat based distros, you can install termscp using the RPM
package via:
</p>
<pre><span class="function">wget</span> -O termscp.rpm <span class="string">https://github.com/veeso/termscp/releases/latest/download/termscp-0.11.0-1.x86_64.rpm</span>
sudo <span class="function">rpm</span> -U <span class="string">termscp.rpm</span></pre>
</div>
</div>
</section>
<section>
<h2>
<i class="devicon-apple-plain"></i>&nbsp;<span
translate="getStarted.macos.title"
>MacOS users</span
>
</h2>
<div class="installation">
<div class="alert alert-warning">
<p>
<i class="fas fa-exclamation-triangle"></i>
<span translate="getStarted.notConfident"
>Opt for this method instead if you don't feel confident using the
shell script</span
>
</p>
</div>
<p>
<span translate="getStarted.macos.install">Install termscp via</span
>&nbsp;
<a href="https://brew.sh/" target="_blank">Brew</a>
</p>
<pre><span class="function">brew</span> install <span class="string">veeso/termscp/termscp</span></pre>
</div>
</section>
<section>
<h2>
<i class="devicon-rust-plain"></i>&nbsp;<span
translate="getStarted.cargo.title"
>Install with Cargo</span
>
</h2>
<div class="installation">
<div class="alert alert-warning">
<p>
<i class="fas fa-exclamation-triangle"></i>
<span translate="getStarted.noBinary"
>Opt for this method instead if binaries for your platform are not
available</span
>
</p>
</div>
<p>
<span translate="getStarted.cargo.body"
>If a package is not available for your system, you can opt to
install termscp via</span
>&nbsp;
<a href="https://www.rust-lang.org/tools/install" target="_blank"
>Cargo</a
>.
<span translate="getStarted.cargo.requirements"
>To install termscp via Cargo, these requirements must be
satisfied:</span
>
</p>
<ul>
<li>
Linux:
<ul>
<li>pkg-config</li>
<li>libssh2</li>
<li>openssl-dev</li>
</ul>
</li>
<li>
FreeBSD:
<ul>
<li>libssh</li>
<li>dbus</li>
<li>pkg-conf</li>
<li>gcc</li>
</ul>
</li>
</ul>
<p translate="getStarted.cargo.install">Then you can install it via</p>
<pre><span class="function">cargo</span> install --locked <span class="string">termscp</span></pre>
<p translate="getStarted.cargo.noKeyring">
Or if you don't want to have support for keyring or you're building on
*BSD:
</p>
<pre><span class="function">cargo</span> install --locked --no-default-features <span class="string">termscp</span></pre>
</div>
</section>
</section>
</body>

96
site/html/intro.html Normal file
View File

@@ -0,0 +1,96 @@
<head>
<link rel="stylesheet" href="css/intro.css" />
</head>
<body>
<section id="intro" class="container intro">
<h1 class="title">termscp</h1>
<img class="logo" alt="logo" src="assets/images/termscp.webp" />
<h2 class="caption" translate="intro.caption">
A feature rich terminal UI file transfer and explorer with support for
SCP/SFTP/FTP/S3
</h2>
<button class="pure-button get-started">
<a href="#get-started" translate="intro.getStarted">Get started →</a>
</button>
<div class="alert alert-center alert-success">
<p>
<span translate="intro.versionAlert"
>termscp 0.11.0 is NOW out! Download it from</span
>&nbsp;
<a href="#get-started" translate="intro.here">here!</a>
</p>
</div>
<div class="features">
<div class="feature">
<h3 translate="intro.features.handy.title">Handy UI</h3>
<p translate="intro.features.handy.body">
Explore and operate on the remote and on the local machine file system
with a handy UI.
</p>
</div>
<div class="feature">
<h3 translate="intro.features.crossPlatform.title">Cross platform</h3>
<p translate="intro.features.crossPlatform.body">
Runs on Windows, MacOS, Linux and BSD
</p>
</div>
<div class="feature">
<h3 translate="intro.features.customizable.title">Customizable</h3>
<p translate="intro.features.customizable.body">
Customize the file explorer, the text editor to use and default
options
</p>
</div>
<div class="feature">
<h3 translate="intro.features.bookmarks.title">Bookmarks</h3>
<p translate="intro.features.bookmarks.body">
Connect to your favourite hosts through built-in bookmarks and recent
connections support
</p>
</div>
<div class="feature">
<h3 translate="intro.features.security.title">Security first</h3>
<p translate="intro.features.security.body">
Save your password into your operating system key vault
</p>
</div>
<div class="feature">
<h3 translate="intro.features.performance.title">Eye on performance</h3>
<p translate="intro.features.performance.body">
termscp has been developed keeping an eye on performance to prevent
cpu usage
</p>
</div>
</div>
<div class="preview">
<video autoplay muted loop>
<source
src="assets/videos/explorer.mp4"
type="video/mp4"
resolve-video-fallback="assets/images/explorer.gif"
/>
</video>
</div>
<div class="discover">
<div class="hook">
<h3>
<a href="#get-started" translate="intro.footer.getStarted"
>Get started</a
>
</h3>
</div>
<div class="hook">
<h3>
<a href="#user-manual" translate="intro.footer.manual">User manual</a>
</h3>
</div>
<div class="hook">
<h3>
<a href="#updates" translate="intro.footer.updates"
>Install updates</a
>
</h3>
</div>
</div>
</section>
</body>

106
site/html/updates.html Normal file
View File

@@ -0,0 +1,106 @@
<head>
<link rel="stylesheet" href="css/updates.css" />
</head>
<body>
<section id="updates" class="container updates">
<h1 translate="updates.title">Keeping termscp up to date</h1>
<div class="alert alert-warning">
<p>
<i class="fas fa-exclamation-triangle"></i>
<span translate="updates.disclaimer">
Updating termscp with this method is only available for 0.7.x versions
or higher. If you have an older version, you have to install updates
using the</span>&nbsp;<a href="#get-started">install.sh script</a>
</p>
</div>
<!-- Reasons -->
<section>
<h2>
<i class="fa fa-question-circle"></i>&nbsp;<span translate="updates.reasons.title">Why should you install
updates</span>
</h2>
<div class="wall-of-text">
<p translate="updates.reasons.wallOfText">
Termscp is an application that is still in its early stage of
development, the first version has been released in december in 2020
and practically there's only one
<a href="https://veeso.github.io/" target="_blank">guy</a> working on
it and there's still a lot of work to do in order to improve it and
make it fast and reliable. Along to this, you should also consider
that since it's an application which works with network protocols and
is intended to manipulate secrets and credentials there may always be
a security issue. I can't guarantee there's no security issues in the
versions I've released in these months, and if there are they might
not be even my fault, but they might be contained in the libraries
termscp relies on. Because of this, it's always VERY important to keep
termscp up to date. To prove how much I care about it, just consider
that I've implemented something that many other open source
applications won't do: the update check. Whenever you start termscp
(unless if deactivated in configuration) termscp will always check if
there's a new version available and will notify you immediately. In
addition to security concerns, each major update will bring many
awesome features 🦄 you can't miss and the application is getting more
reliable and stable after each update 😄
</p>
<p class="tl-dr">
<span>TL;DR</span>
<span translate="updates.reasons.tldr"></span>
</p>
</div>
</section>
<!-- Gui method -->
<section>
<h2><i class="fa fa-desktop"></i>&nbsp;<span translate="updates.gui.title">GUI method</span></h2>
<div class="installation">
<p translate="updates.gui.body" class="description">
The GUI method just consists in starting termscp with no options, you
then should be in front of the authentication form. If there's an
update available a message like "termscp x.y.z is OUT! Update and read
release notes with CTRL+R". All you have to do at this point to update
termscp, is:
</p>
<ol>
<li translate="updates.gui.steps.st">press CTRL+R. The release notes should now be displayed.</li>
<li translate="updates.gui.steps.nd">Select "YES" in the "Install update?" radio input</li>
<li translate="updates.gui.steps.rd">Press "ENTER"</li>
</ol>
<p translate="updates.gui.then" class="description">
If everything worked correctly a green message "termscp x.y.z has been
installed!" will be displayed. Just restart termscp and enjoy the
update 😄
</p>
<div class="alert alert-warning">
<p>
<i class="fas fa-exclamation-triangle"></i>
<span translate="updates.gui.pex">
If you have previously installed termscp via Deb/RPM package, you
may need to use the CLI method running termscp with sudo
</span>
</p>
</div>
</div>
</section>
<!-- CLI method -->
<section>
<h2><i class="fa fa-glasses"></i>&nbsp;<span translate="updates.cli.title">CLI method</span></h2>
<div class="installation">
<p translate="updates.cli.body" class="description">
If you prefer, you can install a new update just using the dedicated
CLI option:
</p>
<pre><span class="function">termscp</span> --update</pre>
<div class="alert alert-warning">
<p>
<i class="fas fa-exclamation-triangle"></i>
<span translate="updates.cli.pex">Run with sudo if necessary (Debian/FreeBSD/RedHat users)</span>
</p>
</div>
<p translate="updates.cli.then" class="description">
Once started, you will be prompted whether to install or not the
update. Confirm the installation and ta-dah, the new version of
termscp should now be available on your machine
</p>
</div>
</section>
</section>
</body>

221
site/index.html Normal file
View File

@@ -0,0 +1,221 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="minimum-scale=1, initial-scale=1, width=device-width"
/>
<meta
property="og:image"
content="https://termscp.veeso.dev/assets/images/og_preview.jpg"
/>
<meta property="og:image:type" content="image/jpg" />
<meta property="og:image:width" content="1024" />
<meta property="og:image:height" content="820" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://termscp.veeso.dev" />
<meta property="og:title" content="termscp" />
<meta property="og:description" content="terminal UI file transfer" />
<!-- Pure.css -->
<link
rel="stylesheet"
href="https://unpkg.com/purecss@2.0.5/build/pure-min.css"
/>
<!-- Icons -->
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/devicons/devicon@v2.11.0/devicon.min.css"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/fontawesome.min.css"
integrity="sha512-OdEXQYCOldjqUEsuMKsZRj93Ht23QRlhIb8E/X0sbwZhme8eUw6g8q7AdxGJKakcBbv7+/PX0Gc2btf7Ru8cZA=="
crossorigin="anonymous"
/>
<!-- Main -->
<link rel="stylesheet" href="css/markdown.css" />
<link rel="stylesheet" href="css/menu.css" />
<link rel="stylesheet" href="css/main.css" />
<!-- Favicons -->
<link
rel="icon"
type="image/png"
sizes="96x96"
href="assets/images/favicon-96x96.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="assets/images/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="assets/images/favicon-16x16.png"
/>
<title>termscp: terminal UI file transfer</title>
</head>
<body>
<div id="layout">
<!-- Menu toggle -->
<a href="#menu" id="menu-burger" class="menu-link">
<!-- Hamburger icon -->
<span></span>
</a>
<!-- Menu -->
<header id="menu">
<div class="pure-menu">
<div class="pure-menu-heading">
<div class="pic-box">
<img class="avatar" alt="logo" src="assets/images/termscp.webp" />
</div>
<h1>termscp</h1>
<p translate="menu.desc">A feature rich terminal UI file transfer</p>
<a href="https://github.com/veeso/termscp/stargazers/">
<img
src="https://img.shields.io/github/stars/veeso/termscp.svg?style=social&label=Star&maxAge=2592000"
/>
</a>
</div>
<ul class="pure-menu-list">
<li class="pure-menu-item pure-menu-selected">
<a href="#intro" class="pure-menu-link" translate="menu.intro">Intro</a>
</li>
<li class="pure-menu-item">
<a href="#get-started" class="pure-menu-link" translate="menu.getStarted">Get started</a>
</li>
<li class="pure-menu-item">
<a href="#updates" class="pure-menu-link" translate="menu.updates">Install updates</a>
</li>
<li class="pure-menu-item">
<a href="#user-manual" class="pure-menu-link" translate="menu.manual">User manual</a>
</li>
<li class="pure-menu-item">
<a href="#changelog" class="pure-menu-link" translate="menu.changelog">Release history</a>
</li>
<li class="pure-menu-item">
<a
href="https://github.com/veeso/termscp"
class="pure-menu-link"
target="_blank"
>Github&nbsp;<i class="fas fa-external-link-alt"></i
></a>
</li>
<li class="pure-menu-item">
<a
href="https://veeso.dev/"
class="pure-menu-link"
target="_blank"
><span translate="menu.author">About the author</span>&nbsp;<i class="fas fa-external-link-alt"></i
></a>
</li>
<li class="pure-menu-item">
<a
href="https://ko-fi.com/veeso"
class="pure-menu-link"
target="_blank"
><span translate="menu.support">Support me</span>&nbsp;<i class="fas fa-external-link-alt"></i
></a>
</li>
</ul>
<div class="pure-menu-bottom">
<ul>
<li>
<a href="https://github.com/veeso/termscp" target="_blank"
><i class="devicon-github-original"></i
></a>
</li>
<li>
<a href="https://crates.io/crates/termscp" target="_blank"
><i class="devicon-rust-plain"></i
></a>
</li>
<li>
<a
href="https://community.chocolatey.org/packages/termscp"
target="_blank"
><i class="devicon-windows8-plain"></i
></a>
</li>
<li>
<a href="https://ko-fi.com/veeso" target="_blank"
><i class="fa fa-coffee"></i
></a>
</li>
</ul>
</div>
</div>
</header>
<main>
<div id="main"></div>
</main>
<footer>
<div class="container">
<ul class="contacts">
<li>
<a href="https://github.com/veeso/termscp" target="_blank"
><i class="devicon-github-original"></i
></a>
</li>
<li>
<a href="https://crates.io/crates/termscp" target="_blank"
><i class="devicon-rust-plain"></i
></a>
</li>
<li>
<a
href="https://community.chocolatey.org/packages/termscp"
target="_blank"
><i class="devicon-windows8-plain"></i
></a>
</li>
<li>
<a href="https://ko-fi.com/veeso" target="_blank"
><i class="fa fa-coffee"></i
></a>
</li>
</ul>
<!-- Copyright -->
<p class="copyright">
<span>Christian Visintin © All Rights Reserved | </span
><span resolve-copyright></span>
</p>
</div>
</footer>
</div>
<!-- Scripts -->
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<!-- Showdown JS-->
<script
src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.1/showdown.min.js"
integrity="sha512-L03kznCrNOfVxOUovR6ESfCz9Gfny7gihUX/huVbQB9zjODtYpxaVtIaAkpetoiyV2eqWbvxMH9fiSv5enX7bw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<!-- Local -->
<script src="js/lang.min.js"></script>
<script src="js/core.js"></script>
<script src="js/events.js"></script>
<script src="js/resolvers.js"></script>
<!-- ko-fi -->
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
<script>
kofiWidgetOverlay.draw('veeso', {
'type': 'floating-chat',
'floating-chat.donateButton.text': 'Support me',
'floating-chat.donateButton.background-color': '#323842',
'floating-chat.donateButton.text-color': '#fff'
});
</script>
</body>
</html>

35
site/js/core.js Normal file
View File

@@ -0,0 +1,35 @@
/**
* @description return navigator language. If language is not supported default will be returned
* @returns {string}
*/
function getNavigatorLanguage() {
let lang = navigator.language;
// Complete lang
if (languageSupported(lang)) {
return lang;
}
// Reduced lang
lang = lang.split(/[-_]/)[0] || "en";
if (!languageSupported(lang)) {
return "en";
}
return lang;
}
/**
* @description check whether provided language is supported by the website
* @param {string} lang
* @returns {boolean}
*/
function languageSupported(lang) {
return ["en", "zh-CN", "it", "fr", "es"].includes(lang);
}
/**
* @description update website language
* @param {string} lang
*/
function setSiteLanguage(lang) {
setLanguage(lang);
}

133
site/js/events.js Normal file
View File

@@ -0,0 +1,133 @@
const hashBlacklist = ["#menu"];
const converter = new showdown.Converter({ tables: true });
/**
* @description handle hash change
*/
function onHashChange() {
const hash = location.hash;
if (!hashBlacklist.includes(hash) && hash.length > 0) {
selectMenuEntry(location.hash);
loadPage(hash);
} else if (hash.length === 0 || hash === "#") {
loadPage("#intro");
}
}
/**
* @description select menu entry
* @param {*} hash
*/
function selectMenuEntry(hash) {
// Remove current entry
$(".pure-menu-selected").removeClass("pure-menu-selected");
$('a[href$="' + hash + '"]')
.parent()
.addClass("pure-menu-selected");
}
/**
* @description load page associated to hash
* @param {string} hash
*/
function loadPage(hash) {
switch (hash) {
case "#intro":
loadHtml("intro.html");
break;
case "#get-started":
loadHtml("get-started.html");
break;
case "#user-manual":
loadUserManual();
break;
case "#updates":
loadHtml("updates.html");
break;
case "#changelog":
loadMarkdown(
"https://raw.githubusercontent.com/veeso/termscp/main/CHANGELOG.md"
);
break;
}
window.scrollTo(0, 0);
}
function loadHtml(page) {
const url = "html/" + page;
$("#main").load(url, function () {
onPageLoaded();
});
}
function loadMarkdown(page) {
getMarkdown(page, function (md) {
const div = jQuery("<div/>", {
id: page,
class: "container markdown",
});
div.html(converter.makeHtml(md));
$("#main").empty();
$("#main").append(div);
onPageLoaded();
});
}
/**
* @description get markdown and pass result to onLoaded
* @param {string} url
* @param {function} onLoaded
*/
function getMarkdown(url, onLoaded) {
$.ajax({
url,
type: "GET",
dataType: "text",
success: onLoaded,
});
}
function onMenuBurgerClick() {
const active = $("#menu").hasClass("active");
if (active) {
$("#layout").removeClass("active");
$("#menu").removeClass("active");
} else {
$("#layout").addClass("active");
$("#menu").addClass("active");
}
}
function loadUserManual() {
// Load language
const lang = getNavigatorLanguage();
if (lang === "en") {
loadMarkdown(
`https://raw.githubusercontent.com/veeso/termscp/main/docs/man.md`
);
} else {
loadMarkdown(
`https://raw.githubusercontent.com/veeso/termscp/main/docs/${lang}/man.md`
);
}
}
function onPageLoaded() {
reloadTranslations();
}
// Register
window.onhashchange = onHashChange;
// Startup
$(function () {
onHashChange();
// Init language
setSiteLanguage(getNavigatorLanguage());
// Burger event listener
$("#menu-burger").on("click", onMenuBurgerClick);
$(".pure-menu-heading").on("click", function () {
location.hash = "#";
onHashChange();
});
});

1
site/js/lang.min.js vendored Normal file
View File

@@ -0,0 +1 @@
var currentLanguage=null;var languagePath="lang/";var currentLanguageDict=null;function setLanguage(lang){currentLanguage=lang;const jsonFile=languagePath+currentLanguage+".json";$.getJSON(jsonFile,function(langData){currentLanguageDict=flatDict(langData);reloadTranslations()})}function reloadTranslations(){$("[translate]").each(function(){const translationAttr=$(this).attr("translate");$(this).text(getInstantTranslation(translationAttr))})}function getInstantTranslation(key){if(currentLanguageDict!==null&&key in currentLanguageDict){return currentLanguageDict[key]}else{return"{{ "+key+" }}"}}function flatDict(dict){const iterNode=(flatten,path,node)=>{for(const key of Object.keys(node)){const child=node[key];const childKey=path?path+"."+key:key;if(typeof child==="object"){flatten=iterNode(flatten,childKey,child)}else{flatten[childKey]=child}}return flatten};return iterNode({},null,dict)}

32
site/js/resolvers.js Normal file
View File

@@ -0,0 +1,32 @@
/**
* @description resolve copyright year
*/
function resolveCopyright() {
const year = new Date().getFullYear();
$("[resolve-copyright]").each(function () {
$(this).text(year);
});
}
/**
* @description resolve video fallback source in case fails. Uses an image instead
*/
function resolveVideoFallback() {
$("[resolve-video-fallback]").each(function () {
const fallback = $(this).attr("resolve-video-fallback");
// Add listener
$(this).on("error", function () {
const image = document.createElement("img");
image.src = fallback;
image.classList = ["preview"];
$(this).parent().replaceWith(image);
});
});
}
// init
$(function () {
resolveCopyright();
resolveVideoFallback();
});

114
site/lang/en.json Normal file
View File

@@ -0,0 +1,114 @@
{
"menu": {
"desc": "A feature rich terminal UI file transfer",
"intro": "Intro",
"getStarted": "Get started",
"updates": "Install updates",
"manual": "User manual",
"changelog": "Release history",
"author": "About the author",
"support": "Support me"
},
"intro": {
"caption": "A feature rich terminal UI file transfer and explorer with support for SCP/SFTP/FTP/S3",
"getStarted": "Get started →",
"versionAlert": "termscp 0.11.0 is NOW out! Download it from",
"here": "here",
"features": {
"handy": {
"title": "Handy UI",
"body": "Explore and operate on the remote and on the local machine file system with a handy UI."
},
"crossPlatform": {
"title": "Cross platform",
"body": "Runs on Windows, MacOS, Linux and FreeBSD"
},
"customizable": {
"title": "Customizable",
"body": "Customize the file explorer, the UI and many other parameters..."
},
"bookmarks": {
"title": "Bookmarks",
"body": "Connect to your favourite hosts through built-in bookmarks and recent connections"
},
"security": {
"title": "Security first",
"body": "Save your passwords into your operating system key vault"
},
"performance": {
"title": "Eye on performance",
"body": "termscp has been developed keeping an eye on performance to prevent high cpu usage"
}
},
"footer": {
"getStarted": "Get started",
"manual": "User manual",
"updates": "Install updates"
}
},
"getStarted": {
"title": "Get started",
"quickSetup": "Quick setup",
"suggested": "We strongly suggest this method to install termscp",
"posixUsers": "If you are a Linux, a FreeBSD or a MacOS user, you can install termscp via this simple command , which will use a shell script installer:",
"windows": {
"title": "Windows users",
"intro": "You can install termscp on Windows via",
"moderation": "Consider that Chocolatey moderation can take up to a few weeks since last release, so if the latest version is not available yet, you can install it downloading the ZIP file from",
"then": "and then, from the ZIP directory, install it via"
},
"linuxUsers": "Linux users",
"notConfident": "Opt for these methods instead if you don't feel confident using the shell script",
"noBinary": "Opt for this method instead if binaries for your platform are not available",
"arch": {
"title": "Arch derived users",
"intro": "On Arch Linux based distros, you can install termscp using an AUR package manager such as",
"then": "then run"
},
"debian": {
"title": "Debian derived users",
"body": "On Debian based distros, you can install termscp using the Deb package via:"
},
"redhat": {
"title": "Redhat derived users",
"body": "On RedHat based distros, you can install termscp using the RPM package via:"
},
"macos": {
"title": "MacOS users",
"install": "Install termscp via"
},
"cargo": {
"title": "Install with Cargo",
"body": "If a package is not available for your system, you can opt to install termscp via",
"requirements": "To install termscp via Cargo, these requirements must be satisfied",
"install": "Then you can install termscp via",
"noKeyring": "Or if you don't want to have support for keyring or you're building on *BSD:"
}
},
"updates": {
"title": "Keeping termscp up to date",
"disclaimer": " Updating termscp with this method is only available for 0.7.x versions or higher. If you have an older version, you have to install updates using the",
"reasons": {
"title": "Why you should install updates",
"wallOfText": "Termscp is an application that is still in its early stage of development, the first version has been released in december in 2020 and practically there's only one guy working on it and there's still a lot of work to do in order to improve it and make it fast and reliable. Along to this, you should also consider that since it's an application which works with network protocols and is intended to manipulate secrets and credentials there may always be a security issue. I can't guarantee there's no security issues in the versions I've released in these months, and if there are they might not be even my fault, but they might be contained in the libraries termscp relies on. Because of this, it's always VERY important to keep termscp up to date. To prove how much I care about it, just consider that I've implemented something that many other open source applications won't do: the update check. Whenever you start termscp (unless if deactivated in configuration) termscp will always check if there's a new version available and will notify you immediately. In addition to security concerns, each major update will bring many awesome features 🦄 you can't miss and the application is getting more reliable and stable after each update 😄",
"tldr": "Possible security issues; new awesome features; performance and stability; Bugfixes"
},
"gui": {
"title": "GUI method",
"body": "The GUI method just consists in starting termscp with no options, you then should be in front of the authentication form. If there's an update available a message like \"termscp x.y.z is OUT! Update and read release notes with CTRL+R\". All you have to do at this point to update termscp, is:",
"steps": {
"st": "press CTRL+R. The release notes should now be displayed",
"nd": "Select \"YES\" in the \"Install update?\" radio input",
"rd": "Press \"Enter\""
},
"then": "If everything worked correctly a green message \"termscp x.y.z has been installed!\" will be displayed. Just restart termscp and enjoy the update 😄",
"pex": " If you have previously installed termscp via Deb/RPM package, you may need to use the CLI method running termscp with sudo"
},
"cli": {
"title": "CLI method",
"body": "If you prefer, you can install a new update just using the dedicated CLI option:",
"pex": "Run with sudo if necessary (installed with RPM/DEB)",
"then": "Once started, you will be prompted whether to install or not the update. Confirm the installation and ta-dah, the new version of termscp should now be available on your machine"
}
}
}

114
site/lang/es.json Normal file
View File

@@ -0,0 +1,114 @@
{
"menu": {
"desc": "Una transferencia de archivos de terminal rica en funciones",
"intro": "Sobre termscp",
"getStarted": "Para iniciar",
"updates": "Actualizaciones",
"manual": "Manual de usuario",
"changelog": "Historial de versiones",
"author": "Sobre el autor",
"support": "Apoyame"
},
"intro": {
"caption": "Un explorador y transferencia de archivos de terminal rico en funciones, con apoyo para SCP/SFTP/FTP/S3",
"getStarted": "Para iniciar →",
"versionAlert": "termscp 0.11.0 ya está disponible! Descárgalo desde",
"here": "aquì",
"features": {
"handy": {
"title": "Interfaz de usuario práctica",
"body": "Explore y opere en el sistema de archivos de la máquina local y remota con una interfaz de usuario práctica."
},
"crossPlatform": {
"title": "Multiplataforma",
"body": "Funciona en Windows, MacOS, Linux y FreeBSD"
},
"customizable": {
"title": "Personalizable",
"body": "Personalice el explorador de archivos, la interfaz de usuario y muchos otros parámetros ..."
},
"bookmarks": {
"title": "Marcadores",
"body": "Conéctese a sus hosts favoritos a través de marcadores integrados y conexiones recientes"
},
"security": {
"title": "Seguridad primero",
"body": "Guarde sus contraseñas en la bóveda de claves de su sistema operativo"
},
"performance": {
"title": "Ojo en el rendimiento",
"body": "termscp se ha desarrollado teniendo en cuenta el rendimiento para evitar un uso elevado de la CPU"
}
},
"footer": {
"getStarted": "Para iniciar",
"manual": "Manual de usuario",
"updates": "Actualizaciones"
}
},
"getStarted": {
"title": "Para iniciar",
"quickSetup": "Configuración rápida",
"suggested": "Recomendamos encarecidamente este método para instalar termscp",
"posixUsers": "Si es un usuario de Linux, FreeBSD o MacOS, puede instalar termscp a través de este sencillo comando, que utilizará un instalador de scripts de shell:",
"windows": {
"title": "Usuarios Windows",
"intro": "Puede instalar termscp en Windows a través de",
"moderation": "Tenga en cuenta que la moderación de Chocolatey puede tardar hasta algunas semanas desde la última versión, por lo que si la última versión aún no está disponible, puede instalarla descargando el archivo ZIP de",
"then": "y luego, desde el directorio ZIP, instálelo a través de"
},
"linuxUsers": "Usuarios Linux",
"notConfident": "En su lugar, opte por estos métodos si no se siente seguro al usar el script de shell",
"noBinary": "Opte por este método en su lugar si los binarios para su plataforma no están disponibles",
"arch": {
"title": "Usuarios derivadas Arch",
"intro": "En las distribuciones basadas en Arch Linux, puede instalar termscp usando un administrador de paquetes AUR como",
"then": "then run"
},
"debian": {
"title": "Usuarios derivadas Debian",
"body": "En las distribuciones basadas en Debian, puede instalar termscp usando el paquete Deb a través de:"
},
"redhat": {
"title": "Usuarios derivadas RedHat",
"body": "En las distribuciones basadas en RedHat, puede instalar termscp usando el paquete RPM a través de:"
},
"macos": {
"title": "Usuarios MacOS",
"install": "Instalar termscp a través de"
},
"cargo": {
"title": "Instalar con Cargo",
"body": "Si un paquete no está disponible para su sistema, puede optar por instalar termscp a través de",
"requirements": "Para instalar termscp a través de Cargo, se deben cumplir estos requisitos",
"install": "Entonces puedes instalar termscp a través de",
"noKeyring": "O si no desea tener soporte para llavero o está construyendo sobre *BSD:"
}
},
"updates": {
"title": "Mantener termscp actualizado",
"disclaimer": " La actualización de termscp con este método solo está disponible para las versiones 0.7.xo superiores. Si tiene una versión anterior, debe instalar actualizaciones utilizando el",
"reasons": {
"title": "Why you should install updates",
"wallOfText": "Termscp es una aplicación que aún se encuentra en su etapa inicial de desarrollo, la primera versión se lanzó en diciembre de 2020 y prácticamente solo hay un chico trabajando en ella y aún hay mucho trabajo por hacer para mejorarla y hacerla. rápido y confiable. Junto con esto, también debe considerar que, dado que es una aplicación que funciona con protocolos de red y está destinada a manipular secretos y credenciales, siempre puede haber un problema de seguridad. No puedo garantizar que no haya problemas de seguridad en las versiones que lancé en estos meses, y si los hay, puede que ni siquiera sea mi culpa, pero pueden estar contenidos en las bibliotecas en las que se basa termscp. Debido a esto, siempre es MUY importante mantener el termcp actualizado. Para demostrar cuánto me importa, solo considere que he implementado algo que muchas otras aplicaciones de código abierto no harán: la verificación de actualizaciones. Siempre que inicie termscp (a menos que esté desactivado en la configuración), termscp siempre comprobará si hay una nueva versión disponible y le notificará inmediatamente. Además de las preocupaciones de seguridad, cada actualización importante traerá muchas características increíbles 🦄 no puede perderse y la aplicación se vuelve más confiable y estable después de cada actualización 😄",
"tldr": "Posibles problemas de seguridad; nuevas funciones asombrosas; rendimiento y estabilidad; Corrección de errores"
},
"gui": {
"title": "Método GUI",
"body": "El método GUI solo consiste en iniciar termscp sin opciones, luego debe estar frente al formulario de autenticación. Si hay una actualización disponible, aparecerá un mensaje como \"termscp x.y.z is OUT! Install update and read release notes with <CTRL + R>\". Todo lo que tiene que hacer en este punto para actualizar termscp es:",
"steps": {
"st": "presione CTRL + R. Las notas de la versión deberían mostrarse ahora",
"nd": "Seleccione \"Yes\" en la entrada de radio \"Install update? \"",
"rd": "presione \"Enter\""
},
"then": "If everything worked correctly a green message \"termscp x.y.z has been installed!\" will be displayed. Just restart termscp and enjoy the update 😄",
"pex": " Si ha instalado previamente termscp a través del paquete Deb / RPM, es posible que deba utilizar el método CLI ejecutando termscp con sudo"
},
"cli": {
"title": "Método CLI",
"body": "Si lo prefiere, puede instalar una nueva actualización simplemente usando la opción CLI dedicada:",
"pex": "Ejecute con sudo si es necesario (instalado con RPM / DEB)",
"then": "Una vez iniciado, se le preguntará si desea instalar o no la actualización. Confirme la instalación y ta-dah, la nueva versión de termscp ahora debería estar disponible en su máquina"
}
}
}

114
site/lang/fr.json Normal file
View File

@@ -0,0 +1,114 @@
{
"menu": {
"desc": "Un file transfer de terminal riche en fonctionnalités",
"intro": "Intro",
"getStarted": "Pour commencer",
"updates": "Mise à jours",
"manual": "Manuel utilisateur",
"changelog": "Changelog",
"author": "A propos de l'auteur",
"support": "Me soutenir"
},
"intro": {
"caption": "Un file transfer et navigateur de terminal riche en fonctionnalités avec support pour SCP/SFTP/FTP/S3",
"getStarted": "Pour commencer →",
"versionAlert": "termscp 0.11.0 est maintenant sorti! Télécharge-le depuis",
"here": "ici",
"features": {
"handy": {
"title": "Interface utilisateur pratique",
"body": "Explorez et utilisez le système de fichiers distant et local avec une interface utilisateur pratique."
},
"crossPlatform": {
"title": "Multi-plateforme",
"body": "Fonctionne sur Windows, MacOS, Linux et FreeBSD"
},
"customizable": {
"title": "Personnalisable",
"body": "Personnalisez l'explorateur de fichiers, l'interface utilisateur et bien d'autres paramètres..."
},
"bookmarks": {
"title": "Signets",
"body": "Connectez-vous à vos hôtes préférés via des signets intégrés et des connexions récentes"
},
"security": {
"title": "Sécurité avant tout",
"body": "Enregistrez vos mots de passe dans le coffre-fort de votre système"
},
"performance": {
"title": "Regard sur les performances",
"body": "termscp a été développé en gardant un œil sur les performances pour éviter une utilisation élevée du processeur"
}
},
"footer": {
"getStarted": "Pour commencer",
"manual": "Manuel d'utilisateur",
"updates": "Mise à jour"
}
},
"getStarted": {
"title": "Pour commencer",
"quickSetup": "Installation rapide",
"suggested": "Nous suggérons fortement cette méthode pour installer termscp",
"posixUsers": "Si vous êtes un utilisateur Linux, FreeBSD ou MacOS, vous pouvez installer termscp via cette simple commande , qui utilisera un installateur de script shell :",
"windows": {
"title": "Utilisateurs Windows",
"intro": "Vous pouvez installer termscp sur Windows via",
"moderation": "Considérez que la modération Chocolatey peut prendre jusqu'à quelques semaines depuis la dernière version, donc si la dernière version n'est pas encore disponible, vous pouvez l'installer en téléchargeant le fichier ZIP depuis",
"then": "puis, depuis le répertoire ZIP, installez-le via"
},
"linuxUsers": "Utilisateurs Linux",
"notConfident": "Optez plutôt pour ces méthodes si vous ne vous sentez pas à l'aise avec le script shell",
"noBinary": "Optez plutôt pour cette méthode si les binaires pour votre plate-forme ne sont pas disponibles",
"arch": {
"title": "Utilisateurs dérivés Arch",
"intro": "Sur les distributions basées sur Arch Linux, vous pouvez installer termscp à l'aide d'un gestionnaire de packages AUR tel que",
"then": "puis, installez-le via"
},
"debian": {
"title": "Utilisateurs dérivés Debian",
"body": "Sur les distributions basées sur Debian, vous pouvez installer termscp en utilisant le paquet Deb via :"
},
"redhat": {
"title": "Utilisateurs dérivés RedHat",
"body": "Sur les distributions basées sur RedHat, vous pouvez installer termscp à l'aide du package RPM via :"
},
"macos": {
"title": "Utilisateurs MacOS",
"install": "Installez termscp via"
},
"cargo": {
"title": "Installer avec Cargo",
"body": "Si un package n'est pas disponible pour votre système, vous pouvez choisir d'installer Termscp via",
"requirements": "Pour installer termscp via Cargo, ces conditions doivent être remplies",
"install": "Ensuite, vous pouvez installer termscp via",
"noKeyring": "Ou si vous ne voulez pas avoir de support pour le trousseau de clés ou si vous construisez sur *BSD :"
}
},
"updates": {
"title": "Tenir à jour termscp",
"disclaimer": " La mise à jour de termscp avec cette méthode n'est disponible que pour les versions 0.7.x ou supérieures. Si vous avez une ancienne version, vous devez installer les mises à jour en utilisant le",
"reasons": {
"title": "Pourquoi devriez-vous installer les mises à jour",
"wallOfText": "termscp est une application qui est encore à ses débuts de développement, la première version est sortie en décembre 2020 et pratiquement il n'y a qu'un seul gars qui travaille dessus et il y a encore beaucoup de travail à faire pour l'améliorer et le faire rapide et fiable. Parallèlement à cela, vous devez également considérer que, puisqu'il s'agit d'une application qui fonctionne avec des protocoles réseau et est destinée à manipuler des secrets et des informations d'identification, il peut toujours y avoir un problème de sécurité. Je ne peux pas garantir qu'il n'y ait pas de problèmes de sécurité dans les versions que j'ai publiées au cours de ces mois, et s'il y en a, ce n'est peut-être même pas de ma faute, mais ils pourraient être contenus dans les bibliothèques sur lesquelles s'appuie Termscp. Pour cette raison, il est toujours TRÈS important de maintenir termscp à jour. Pour prouver à quel point j'y tiens, considérez simplement que j'ai implémenté quelque chose que de nombreuses autres applications open source ne feront pas : la vérification des mises à jour. Chaque fois que vous démarrez termscp (sauf s'il est désactivé dans la configuration), termscp vérifiera toujours si une nouvelle version est disponible et vous en informera immédiatement. En plus des problèmes de sécurité, chaque mise à jour majeure apportera de nombreuses fonctionnalités impressionnantes 🦄 vous ne pouvez pas manquer et l'application devient plus fiable et stable après chaque mise à jour 😄",
"tldr": "Problèmes de sécurité possibles ; de nouvelles fonctionnalités impressionnantes ; performances et stabilité; Corrections de bugs"
},
"gui": {
"title": "Méthode GUI",
"body": "La méthode GUI consiste simplement à démarrer termscp sans options, vous devriez alors être devant le formulaire d'authentification. S'il y a une mise à jour disponible, un message comme \"termscp x.y.z is now OUT ! Install updated and read the release notes with CTRL+R\". Tout ce que vous avez à faire à ce stade pour mettre à jour termscp, c'est :",
"steps": {
"st": "appuyez sur CTRL+R. Les notes de version devraient maintenant être affichées",
"nd": "Sélectionnez \"YES\" dans l'entrée radio \"Install update?\"",
"rd": "appuyez \"Enter\""
},
"then": "Si tout a fonctionné correctement, un message vert \"termscp x.y.z has been installed!\" s'affichera. Redémarrez simplement Termscp et profitez de la mise à jour",
"pex": " Si vous avez déjà installé termscp via le package Deb/RPM, vous devrez peut-être utiliser la méthode CLI exécutant termscp avec sudo"
},
"cli": {
"title": "Méthode CLI",
"body": "Si vous préférez, vous pouvez installer le mise à jour avec l'option CLI dédié :",
"pex": "Exécuter avec sudo si nécessaire (installé avec RPM/DEB)",
"then": "Une fois démarré, vous serez invité à installer ou non la mise à jour. Confirmez l'installation et ta-dah, la nouvelle version de termscp devrait maintenant être disponible sur votre machine"
}
}
}

114
site/lang/it.json Normal file
View File

@@ -0,0 +1,114 @@
{
"menu": {
"desc": "Un file transfer ricco di funzionalità",
"intro": "Intro",
"getStarted": "Per iniziare",
"updates": "Aggiornamenti",
"manual": "Manuale",
"changelog": "Rilasci",
"author": "Sull'autore",
"support": "Supportami"
},
"intro": {
"caption": "Un file transfer ed explorer ricco di funzionalità con supporto per SFTP/SCP/FTP/S3",
"getStarted": "Installa termscp →",
"versionAlert": "termscp 0.11.0 è ORA disponbile! Scaricalo da",
"here": "qui",
"features": {
"handy": {
"title": "UI ergonomica",
"body": "Naviga e lavora sulla macchina remote e locale attraverso una UI di facile utilizzo"
},
"crossPlatform": {
"title": "Multi piattaforma",
"body": "Gira su Windows, MacOS, Linux e FreeBSD"
},
"customizable": {
"title": "Personalizzabile",
"body": "Personalizza l'explorer, l'interfaccia e molto altro..."
},
"bookmarks": {
"title": "Preferiti",
"body": "Connetitit ai tuoi host preferiti e accedi in velocemente alle tue ultime sessioni"
},
"security": {
"title": "Sicurezza in prima classe",
"body": "Salva le tue password nel vault del tuo sistema operativo"
},
"performance": {
"title": "Focus sulle performance",
"body": "termscp è stato sviluppato tenendo conto delle performance, per garantirti il minor consumo di risore possibile"
}
},
"footer": {
"getStarted": "Per iniziare",
"manual": "Manuale utente",
"updates": "Aggiornamenti"
}
},
"getStarted": {
"title": "Installazione",
"quickSetup": "Installazione veloce",
"suggested": "Suggeriamo questo metodo per installare termscp",
"posixUsers": "Se sei un utente Linux, MacOS o *BSD puoi installare termscp con questo semplice comando, che utilizzerà un semplice script per installare l'applicazione;",
"windows": {
"title": "Utenti Windows",
"intro": "Puoi installare termscp su Windows tramite",
"moderation": "Attenzione che i moderatori di chocolatey potrebbero metterci qualche settimana ad approvare l'ultima versione, quindi se l'ultima versione non fosse ancora disponibile, puoi installarla tramite il file ZIP da",
"then": "e poi, dalla directory dello ZIP, lo installi con"
},
"linuxUsers": "Utenti Linux",
"notConfident": "Opta per questi metodi nel caso non ti fidi dello script install.sh",
"noBinary": "Opta per questo metodo nel caso non fosse disponibile un binario per la tua piattaforma",
"arch": {
"title": "Utenti derivate Arch",
"intro": "Sulle distro derivate da Arch puoi installare termscp tramite un package manager AUR come",
"then": "e poi lanciare"
},
"debian": {
"title": "Utenti derivate Debian",
"body": "Sulle distro derivate Debian puoi installare termscp tramite il pacchetto Deb, con:"
},
"redhat": {
"title": "Utenti derivate RedHat",
"body": "Sulle distro derivate RedHat puoi installare termscp tramite il pacchetto RPM, con:"
},
"macos": {
"title": "Utenti MacOS",
"install": "Installa termscp con"
},
"cargo": {
"title": "Installa con Cargo",
"body": "Se un pacchetto non è disponibile per il tuo sistema, puoi installare termscp con cargo con",
"requirements": "Per installare con Cargo, questi requisiti di sistema devono essere soddisfatti",
"install": "Infine puoi installare termscp con",
"noKeyring": "O se non hai il supporto a DBUS o sei un utente *BSD:"
}
},
"updates": {
"title": "Mantenere termscp all'ultima versione",
"disclaimer": "L'aggiornamento di termscp con il metodo descritto è disponibile solo per le versioni suaccessive o uguali alla 0.7.x. Nel caso tu abbia una versione precedente, puoi aggiornare termscp tramite il",
"reasons": {
"title": "Perché dovresti aggiornare termscp",
"wallOfText": "Termscp è un'applicazione che è ancora all'inizio del suo ciclo di vita, la prima versione è infatti risalente a dicembre 2020 e praticamente c'è solo una persona che ci lavora. C'è ancora molto da fare prima di renderlo veloce, sicuro al 100% ed affidabile. Oltre a questo devi considerare che lavorando con protocolli di rete che utilizzano autenticazione ci potrebbero sempre essere delle falle di sicurezza nelle librerie su cui ci appoggiamo e non ho modo ad oggi di garantire che non ce ne siano. Per questo motivo è sempre importante mantenere termscp all'ultima versione e leggere i changelog del progetto. Tanto per capirci su quanto ci tenga a mantenere le versioni all'ultima versione, questo è uno dei pochi progetti CLI ad avere la possibilità di installarlo direttamente dall'applicazione Comunque oltre a possibili falle di sicurezza e bug, ad ogni aggiornamento introdurrò nuove fantastiche funzionalità 🦄 da non perdere 😄",
"tldr": "Possibili problemi di sicurezza; nuove features; performance e stabilità; bug fix"
},
"gui": {
"title": "Metodo da interfaccia grafica",
"body": "Il metodo da interfaccia grafica richiede di lanciare termscp senza argomenti, a questo punto nella pagina dell'autenticazione dovresti essere notificato di una nuova versione disponibile, tramite un messaggio tipo \"termscp x.y.z is OUT! Update and read release notes with CTRL+R\". A questo punto ti basterà:",
"steps": {
"st": "Premere CTRL+R. Le note di rilascio saranno visualizzate in un popup",
"nd": "Seleziona \"YES\" nel dialogo radio \"Install update?\"",
"rd": "Premi \"Invio\""
},
"then": "Se tutto è andato a buon fine un messaggio con scritto \"termscp x.y.z has been installed!\" sarà visualizzato. A questo punto riavvia termscp e goditi le novità 😄",
"pex": " Se in precedenza hai installato termscp con pacchetto Deb/RPM, dovresti aver bisogno di lanciare termscp da utente sudo. Nel caso ti consiglio il metodo CLI."
},
"cli": {
"title": "Metodo da linea di comando",
"body": "Se preferisci o devi installare con sudo, puoi installare termscp lanciandolo con l'opzione da linea di comando:",
"pex": "Lancialo con sudo se necessario (tipo se l'hai installato con pacchetto RPM/DEB)",
"then": "Una volta lanciato, se c'è un aggiornamento disponibile ti chiederà se procedere. Conferma e a questo punto dovrebbe installarlo. Se tutto è andato a buon fine, riavviando termscp dovrebbe essere l'ultima versione."
}
}
}

114
site/lang/zh-CN.json Normal file
View File

@@ -0,0 +1,114 @@
{
"menu": {
"desc": "功能丰富的终端文件传输",
"intro": "介绍",
"getStarted": "开始",
"updates": "安装更新",
"manual": "用户手册",
"changelog": "发布历史",
"author": "关于作者",
"support": "支持我"
},
"intro": {
"caption": "功能丰富的终端 UI 文件传输和浏览器,支持 SCP/SFTP/FTP/S3",
"getStarted": "开始 →",
"versionAlert": "termscp 0.11.0 现已发布! 从下载",
"here": "这里",
"features": {
"handy": {
"title": "方便的用户界面",
"body": "使用方便的 UI 在远程和本地机器文件系统上探索和操作。"
},
"crossPlatform": {
"title": "跨平台",
"body": "在 Windows、MacOS、Linux 和 FreeBSD 上运行"
},
"customizable": {
"title": "可定制",
"body": "自定义文件浏览器、UI 和许多其他参数..."
},
"bookmarks": {
"title": "书签",
"body": "通过内置书签和最近的连接连接到您最喜欢的主机"
},
"security": {
"title": "安全第一",
"body": "将您的密码保存到您的操作系统密钥保管库中"
},
"performance": {
"title": "关注性能",
"body": "已经开发了 termscp 关注性能以防止高 CPU 使用率"
}
},
"footer": {
"getStarted": "开始",
"manual": "用户手册",
"updates": "安装更新"
}
},
"getStarted": {
"title": "开始",
"quickSetup": "快速设置",
"suggested": "我们强烈建议使用这种方法来安装termscp",
"posixUsers": "如果您是 Linux、FreeBSD 或 MacOS 用户,您可以通过这个简单的命令安装 termscp它将使用 shell 脚本安装程序:",
"windows": {
"title": "Windows 用户",
"intro": "安装",
"moderation": "考虑到 Chocolatey 审核自上次发布以来可能需要长达数周的时间,因此如果最新版本尚不可用,您可以从以下位置下载 ZIP 文件进行安装",
"then": "然后,从 ZIP 目录,安装它"
},
"linuxUsers": "Linux 用户",
"notConfident": "如果您对使用 shell 脚本没有信心,请选择这些方法",
"noBinary": "如果您的平台的二进制文件不可用,请改用此方法",
"arch": {
"title": "Arch派生用户",
"intro": "在基于 Arch Linux 的发行版上,您可以使用 AUR 包管理器安装 termscp例如",
"then": "然后运行"
},
"debian": {
"title": "Debian派生用户",
"body": "在基于 Debian 的发行版上,您可以通过以下方式使用 Deb 包安装 termscp"
},
"redhat": {
"title": "Redhat派生用户",
"body": "在基于 RedHat 的发行版上,您可以通过以下方式使用 RPM 包安装 termscp"
},
"macos": {
"title": "MacOS 用户",
"install": "通过以下方式安装termscp"
},
"cargo": {
"title": "使用“Cargo”安装",
"body": "如果您的系统没有可用的软件包,您可以选择通过以下方式安装 termscp",
"requirements": "要通过 Cargo 安装termscp必须满足这些要求",
"install": "然后你可以通过安装termscp",
"noKeyring": "或者,如果您不想支持密钥环,或者您正在构建 *BSD"
}
},
"updates": {
"title": "使termscp保持最新",
"disclaimer": " 使用此方法更新 termscp 仅适用于 0.7.x 版本或更高版本。 如果您有旧版本,则必须使用",
"reasons": {
"title": "为什么要安装更新",
"wallOfText": "termscp 是一个仍处于早期开发阶段的应用程序,第一个版本已于 2020 年 12 月发布,实际上只有一个人在开发它,为了改进它并使其成功,还有很多工作要做快速可靠。除此之外,您还应该考虑到,由于它是一个使用网络协议的应用程序,旨在操纵机密和凭据,因此可能始终存在安全问题。我不能保证我这几个月发布的版本没有安全问题,如果有,它们甚至可能不是我的错,但它们可能包含在 termscp 依赖的库中。因此保持termscp 最新总是非常重要的。为了证明我有多关心它请考虑一下我已经实现了许多其他开源应用程序不会做的事情更新检查。每当您启动termscp除非在配置中停用termscp 将始终检查是否有新版本可用并立即通知您。除了安全问题,每次重大更新都会带来许多很棒的功能🦄你不能错过,每次更新后应用程序都变得更加可靠和稳定😄",
"tldr": "可能的安全问题; 新的很棒的功能; 性能和稳定性; Bug修复"
},
"gui": {
"title": "图形用户界面方式",
"body": "GUI 方法只包括启动没有选项的 termscp然后您应该位于身份验证表单的前面。 如果有可用更新,则会显示类似\"termscp x.y.z is OUT! Update and read release notes with CTRL+R\"之类的消息。 此时更新termscp所需要做的就是",
"steps": {
"st": "按 CTRL+R。 现在应该显示发行说明",
"nd": "在 \"Install update?\" 单选输入中选择 \"YES\"",
"rd": "按 \"Enter\""
},
"then": "termscp x.y.z has been installed”。 只需重新启动termscp并享受更新😄",
"pex": " 如果您之前已经通过 Deb/RPM 包安装了 termscp您可能需要使用 CLI 方法通过 sudo 运行 termscp"
},
"cli": {
"title": "命令行方式",
"body": "如果您愿意,可以仅使用专用 CLI 选项安装新更新:",
"pex": "如有必要,使用 sudo 运行(使用 RPM/DEB 安装)",
"then": "启动后,系统将提示您是否安装更新。 确认安装和 ta-dah新版本的termscp 现在应该可以在你的机器上使用了"
}
}
}

View File

@@ -2,32 +2,10 @@
//!
//! `activity_manager` is the module which provides run methods and handling for activities
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Deps
use crate::filetransfer::FileTransferParams;
use crate::host::{HostError, Localhost};
use crate::system::bookmarks_client::BookmarksClient;
use crate::system::config_client::ConfigClient;
use crate::system::environment;
use crate::system::theme_provider::ThemeProvider;
@@ -36,6 +14,8 @@ use crate::ui::activities::{
ExitReason,
};
use crate::ui::context::Context;
use crate::utils::fmt;
use crate::utils::tty;
// Namespaces
use std::path::{Path, PathBuf};
@@ -64,7 +44,7 @@ impl ActivityManager {
pub fn new(local_dir: &Path, ticks: Duration) -> Result<ActivityManager, HostError> {
// Prepare Context
// Initialize configuration client
let (config_client, error): (ConfigClient, Option<String>) =
let (config_client, error_config): (ConfigClient, Option<String>) =
match Self::init_config_client() {
Ok(cli) => (cli, None),
Err(err) => {
@@ -72,8 +52,13 @@ impl ActivityManager {
(ConfigClient::degraded(), Some(err))
}
};
let (bookmarks_client, error_bookmark) = match Self::init_bookmarks_client() {
Ok(cli) => (cli, None),
Err(err) => (None, Some(err)),
};
let error = error_config.or(error_bookmark);
let theme_provider: ThemeProvider = Self::init_theme_provider();
let ctx: Context = Context::new(config_client, theme_provider, error);
let ctx: Context = Context::new(bookmarks_client, config_client, theme_provider, error);
Ok(ActivityManager {
context: Some(ctx),
local_dir: local_dir.to_path_buf(),
@@ -82,9 +67,53 @@ impl ActivityManager {
}
/// Set file transfer params
pub fn set_filetransfer_params(&mut self, params: FileTransferParams) {
pub fn set_filetransfer_params(
&mut self,
mut params: FileTransferParams,
password: Option<&str>,
) -> Result<(), String> {
// Set password if provided
if params.password_missing() {
if let Some(password) = password {
params.set_default_secret(password.to_string());
} else {
match tty::read_secret_from_tty("Password: ") {
Err(err) => return Err(format!("Could not read password: {err}")),
Ok(Some(secret)) => {
debug!(
"Read password from tty: {}",
fmt::shadow_password(secret.as_str())
);
params.set_default_secret(secret);
}
Ok(None) => {}
}
}
}
// Put params into the context
self.context.as_mut().unwrap().set_ftparams(params);
Ok(())
}
/// Resolve provided bookmark name and set it as file transfer params.
/// Returns error if bookmark is not found
pub fn resolve_bookmark_name(
&mut self,
bookmark_name: &str,
password: Option<&str>,
) -> Result<(), String> {
if let Some(bookmarks_client) = self.context.as_mut().unwrap().bookmarks_client_mut() {
match bookmarks_client.get_bookmark(bookmark_name) {
None => Err(format!(
r#"Could not resolve bookmark name: "{bookmark_name}" no such bookmark"#
)),
Some(params) => self.set_filetransfer_params(params, password),
}
} else {
Err(String::from(
"Could not resolve bookmark name: bookmarks client not initialized",
))
}
}
///
@@ -187,7 +216,7 @@ impl ActivityManager {
Err(err) => {
// Set error in context
error!("Failed to initialize localhost: {}", err);
ctx.set_error(format!("Could not initialize localhost: {}", err));
ctx.set_error(format!("Could not initialize localhost: {err}"));
return None;
}
};
@@ -256,6 +285,33 @@ impl ActivityManager {
// -- misc
fn init_bookmarks_client() -> Result<Option<BookmarksClient>, String> {
// Get config dir
match environment::init_config_dir() {
Ok(path) => {
// If some configure client, otherwise do nothing; don't bother users telling them that bookmarks are not supported on their system.
if let Some(config_dir_path) = path {
let bookmarks_file: PathBuf =
environment::get_bookmarks_paths(config_dir_path.as_path());
// Initialize client
BookmarksClient::new(bookmarks_file.as_path(), config_dir_path.as_path(), 16)
.map(Option::Some)
.map_err(|e| {
format!(
"Could not initialize bookmarks (at \"{}\", \"{}\"): {}",
bookmarks_file.display(),
config_dir_path.display(),
e
)
})
} else {
Ok(None)
}
}
Err(err) => Err(err),
}
}
/// Initialize configuration client
fn init_config_client() -> Result<ConfigClient, String> {
// Get config dir
@@ -268,7 +324,7 @@ impl ActivityManager {
environment::get_config_paths(config_dir.as_path());
match ConfigClient::new(config_path.as_path(), ssh_dir.as_path()) {
Ok(cli) => Ok(cli),
Err(err) => Err(format!("Could not read configuration: {}", err)),
Err(err) => Err(format!("Could not read configuration: {err}")),
}
}
None => Err(String::from(
@@ -277,8 +333,7 @@ impl ActivityManager {
}
}
Err(err) => Err(format!(
"Could not initialize configuration directory: {}",
err
"Could not initialize configuration directory: {err}"
)),
}
}

125
src/cli_opts.rs Normal file
View File

@@ -0,0 +1,125 @@
//! ## CLI opts
//!
//! defines the types for main.rs types
use argh::FromArgs;
use crate::activity_manager::NextActivity;
use crate::filetransfer::FileTransferParams;
use crate::system::logging::LogLevel;
use std::path::PathBuf;
use std::time::Duration;
pub enum Task {
Activity(NextActivity),
ImportTheme(PathBuf),
InstallUpdate,
}
#[derive(FromArgs)]
#[argh(description = "
where positional can be:
- [address] [local-wrkdir]
OR
- [bookmark-Name] [local-wrkdir]
Address syntax can be:
- `protocol://user@address:port:wrkdir` for protocols such as Sftp, Scp, Ftp
- `s3://bucket-name@region:profile:/wrkdir` for Aws S3 protocol
Please, report issues to <https://github.com/veeso/termscp>
Please, consider supporting the author <https://ko-fi.com/veeso>")]
pub struct Args {
#[argh(
switch,
short = 'b',
description = "resolve address argument as a bookmark name"
)]
pub address_as_bookmark: bool,
#[argh(switch, short = 'c', description = "open termscp configuration")]
pub config: bool,
#[argh(switch, short = 'D', description = "enable TRACE log level")]
pub debug: bool,
#[argh(option, short = 'P', description = "provide password from CLI")]
pub password: Option<String>,
#[argh(switch, short = 'q', description = "disable logging")]
pub quiet: bool,
#[argh(option, short = 't', description = "import specified theme")]
pub theme: Option<String>,
#[argh(
switch,
short = 'u',
description = "update termscp to the latest version"
)]
pub update: bool,
#[argh(
option,
short = 'T',
default = "10",
description = "set UI ticks; default 10ms"
)]
pub ticks: u64,
#[argh(switch, short = 'v', description = "print version")]
pub version: bool,
// -- positional
#[argh(
positional,
description = "protocol://user@address:port:wrkdir local-wrkdir"
)]
pub positional: Vec<String>,
}
pub struct RunOpts {
pub remote: Remote,
pub ticks: Duration,
pub log_level: LogLevel,
pub task: Task,
}
impl Default for RunOpts {
fn default() -> Self {
Self {
remote: Remote::None,
ticks: Duration::from_millis(10),
log_level: LogLevel::Info,
task: Task::Activity(NextActivity::Authentication),
}
}
}
#[allow(clippy::large_enum_variant)]
pub enum Remote {
Bookmark(BookmarkParams),
Host(HostParams),
None,
}
pub struct BookmarkParams {
pub name: String,
pub password: Option<String>,
}
pub struct HostParams {
pub params: FileTransferParams,
pub password: Option<String>,
}
impl BookmarkParams {
pub fn new<S: AsRef<str>>(name: S, password: Option<S>) -> Self {
Self {
name: name.as_ref().to_string(),
password: password.map(|x| x.as_ref().to_string()),
}
}
}
impl HostParams {
pub fn new<S: AsRef<str>>(params: FileTransferParams, password: Option<S>) -> Self {
Self {
params,
password: password.map(|x| x.as_ref().to_string()),
}
}
}

View File

@@ -2,34 +2,12 @@
//!
//! `bookmarks` is the module which provides data types and de/serializer for bookmarks
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams};
use crate::filetransfer::{FileTransferParams, FileTransferProtocol};
use serde::{de::Error as DeError, Deserialize, Deserializer, Serialize, Serializer};
use std::collections::HashMap;
use std::path::PathBuf;
use std::str::FromStr;
/// UserHosts contains all the hosts saved by the user in the data storage
@@ -41,7 +19,7 @@ pub struct UserHosts {
}
/// Bookmark describes a single bookmark entry in the user hosts storage
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq)]
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq)]
pub struct Bookmark {
#[serde(
deserialize_with = "deserialize_protocol",
@@ -56,25 +34,31 @@ pub struct Bookmark {
pub username: Option<String>,
/// Password is optional; base64, aes-128 encrypted password
pub password: Option<String>,
/// Remote folder to connect to
pub directory: Option<PathBuf>,
/// S3 params; optional. When used other fields are empty for sure
pub s3: Option<S3Params>,
}
/// Connection parameters for Aws s3 protocol
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Default)]
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq, Default)]
pub struct S3Params {
pub bucket: String,
pub region: String,
pub region: Option<String>,
pub endpoint: Option<String>,
pub profile: Option<String>,
pub access_key: Option<String>,
pub secret_access_key: Option<String>,
/// NOTE: there are no session token and security token since they are always temporary
pub new_path_style: Option<bool>,
}
// -- impls
impl From<FileTransferParams> for Bookmark {
fn from(params: FileTransferParams) -> Self {
let protocol: FileTransferProtocol = params.protocol;
let protocol = params.protocol;
let directory = params.entry_directory;
// Create generic or others
match params.params {
ProtocolParams::Generic(params) => Self {
@@ -83,6 +67,7 @@ impl From<FileTransferParams> for Bookmark {
port: Some(params.port),
username: params.username,
password: params.password,
directory,
s3: None,
},
ProtocolParams::AwsS3(params) => Self {
@@ -91,6 +76,7 @@ impl From<FileTransferParams> for Bookmark {
port: None,
username: None,
password: None,
directory,
s3: Some(S3Params::from(params)),
},
}
@@ -106,15 +92,18 @@ impl From<Bookmark> for FileTransferParams {
let params = AwsS3Params::from(params);
Self::new(FileTransferProtocol::AwsS3, ProtocolParams::AwsS3(params))
}
protocol => {
FileTransferProtocol::Ftp(_)
| FileTransferProtocol::Scp
| FileTransferProtocol::Sftp => {
let params = GenericProtocolParams::default()
.address(bookmark.address.unwrap_or_default())
.port(bookmark.port.unwrap_or(22))
.username(bookmark.username)
.password(bookmark.password);
Self::new(protocol, ProtocolParams::Generic(params))
Self::new(bookmark.protocol, ProtocolParams::Generic(params))
}
}
.entry_directory(bookmark.directory) // Set entry directory
}
}
@@ -123,9 +112,11 @@ impl From<AwsS3Params> for S3Params {
S3Params {
bucket: params.bucket_name,
region: params.region,
endpoint: params.endpoint,
profile: params.profile,
access_key: params.access_key,
secret_access_key: params.secret_access_key,
new_path_style: Some(params.new_path_style),
}
}
}
@@ -133,8 +124,10 @@ impl From<AwsS3Params> for S3Params {
impl From<S3Params> for AwsS3Params {
fn from(params: S3Params) -> Self {
AwsS3Params::new(params.bucket, params.region, params.profile)
.endpoint(params.endpoint)
.access_key(params.access_key)
.secret_access_key(params.secret_access_key)
.new_path_style(params.new_path_style.unwrap_or(false))
}
}
@@ -142,9 +135,9 @@ fn deserialize_protocol<'de, D>(deserializer: D) -> Result<FileTransferProtocol,
where
D: Deserializer<'de>,
{
let s: &str = Deserialize::deserialize(deserializer)?;
let s: String = Deserialize::deserialize(deserializer)?;
// Parse color
match FileTransferProtocol::from_str(s) {
match FileTransferProtocol::from_str(&s) {
Err(err) => Err(DeError::custom(err)),
Ok(protocol) => Ok(protocol),
}
@@ -180,6 +173,7 @@ mod tests {
protocol: FileTransferProtocol::Sftp,
username: Some(String::from("root")),
password: Some(String::from("password")),
directory: Some(PathBuf::from("/tmp")),
s3: None,
};
let recent: Bookmark = Bookmark {
@@ -188,6 +182,7 @@ mod tests {
protocol: FileTransferProtocol::Scp,
username: Some(String::from("admin")),
password: Some(String::from("password")),
directory: Some(PathBuf::from("/home")),
s3: None,
};
let mut bookmarks: HashMap<String, Bookmark> = HashMap::with_capacity(1);
@@ -202,6 +197,10 @@ mod tests {
assert_eq!(bookmark.protocol, FileTransferProtocol::Sftp);
assert_eq!(bookmark.username.as_deref().unwrap(), "root");
assert_eq!(bookmark.password.as_deref().unwrap(), "password");
assert_eq!(
bookmark.directory.as_deref().unwrap(),
std::path::Path::new("/tmp")
);
let bookmark: &Bookmark = hosts
.recents
.get(&String::from("ISO20201218T181432"))
@@ -211,6 +210,10 @@ mod tests {
assert_eq!(bookmark.protocol, FileTransferProtocol::Scp);
assert_eq!(bookmark.username.as_deref().unwrap(), "admin");
assert_eq!(bookmark.password.as_deref().unwrap(), "password");
assert_eq!(
bookmark.directory.as_deref().unwrap(),
std::path::Path::new("/home")
);
}
#[test]
@@ -221,20 +224,25 @@ mod tests {
username: Some(String::from("root")),
password: Some(String::from("omar")),
});
let params: FileTransferParams = FileTransferParams::new(FileTransferProtocol::Scp, params);
let params: FileTransferParams = FileTransferParams::new(FileTransferProtocol::Scp, params)
.entry_directory(Some(PathBuf::from("/home")));
let bookmark = Bookmark::from(params);
assert_eq!(bookmark.protocol, FileTransferProtocol::Scp);
assert_eq!(bookmark.address.as_deref().unwrap(), "127.0.0.1");
assert_eq!(bookmark.port.unwrap(), 10222);
assert_eq!(bookmark.username.as_deref().unwrap(), "root");
assert_eq!(bookmark.password.as_deref().unwrap(), "omar");
assert_eq!(
bookmark.directory.as_deref().unwrap(),
std::path::Path::new("/home")
);
assert!(bookmark.s3.is_none());
}
#[test]
fn bookmark_from_s3_ftparams() {
let params = ProtocolParams::AwsS3(
AwsS3Params::new("omar", "eu-west-1", Some("test"))
AwsS3Params::new("omar", Some("eu-west-1"), Some("test"))
.access_key(Some("pippo"))
.secret_access_key(Some("pluto")),
);
@@ -248,7 +256,7 @@ mod tests {
assert!(bookmark.password.is_none());
let s3: &S3Params = bookmark.s3.as_ref().unwrap();
assert_eq!(s3.bucket.as_str(), "omar");
assert_eq!(s3.region.as_str(), "eu-west-1");
assert_eq!(s3.region.as_deref().unwrap(), "eu-west-1");
assert_eq!(s3.profile.as_deref().unwrap(), "test");
assert_eq!(s3.access_key.as_deref().unwrap(), "pippo");
assert_eq!(s3.secret_access_key.as_deref().unwrap(), "pluto");
@@ -262,10 +270,15 @@ mod tests {
protocol: FileTransferProtocol::Sftp,
username: Some(String::from("root")),
password: Some(String::from("password")),
directory: Some(PathBuf::from("/tmp")),
s3: None,
};
let params = FileTransferParams::from(bookmark);
assert_eq!(params.protocol, FileTransferProtocol::Sftp);
assert_eq!(
params.entry_directory.as_deref().unwrap(),
std::path::Path::new("/tmp")
);
let gparams = params.params.generic_params().unwrap();
assert_eq!(gparams.address.as_str(), "192.168.1.1");
assert_eq!(gparams.port, 22);
@@ -281,21 +294,30 @@ mod tests {
port: None,
username: None,
password: None,
directory: Some(PathBuf::from("/tmp")),
s3: Some(S3Params {
bucket: String::from("veeso"),
region: String::from("eu-west-1"),
region: Some(String::from("eu-west-1")),
endpoint: Some(String::from("omar")),
profile: Some(String::from("default")),
access_key: Some(String::from("pippo")),
secret_access_key: Some(String::from("pluto")),
new_path_style: Some(true),
}),
};
let params = FileTransferParams::from(bookmark);
assert_eq!(params.protocol, FileTransferProtocol::AwsS3);
assert_eq!(
params.entry_directory.as_deref().unwrap(),
std::path::Path::new("/tmp")
);
let gparams = params.params.s3_params().unwrap();
assert_eq!(gparams.bucket_name.as_str(), "veeso");
assert_eq!(gparams.region.as_str(), "eu-west-1");
assert_eq!(gparams.region.as_deref().unwrap(), "eu-west-1");
assert_eq!(gparams.endpoint.as_deref().unwrap(), "omar");
assert_eq!(gparams.profile.as_deref().unwrap(), "default");
assert_eq!(gparams.access_key.as_deref().unwrap(), "pippo");
assert_eq!(gparams.secret_access_key.as_deref().unwrap(), "pluto");
assert_eq!(gparams.new_path_style, true);
}
}

View File

@@ -2,29 +2,6 @@
//!
//! `config` is the module which provides access to all the termscp configurations
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// export
pub use params::*;

View File

@@ -2,29 +2,6 @@
//!
//! `config` is the module which provides access to termscp configuration
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Locals
use crate::filetransfer::FileTransferProtocol;
@@ -59,7 +36,7 @@ pub struct UserInterfaceConfig {
pub notification_threshold: Option<u64>, // @! Since 0.7.0; Default 512MB
}
#[derive(Deserialize, Serialize, Debug, Default)]
#[derive(Deserialize, Serialize, Debug)]
/// Contains configuratio related to remote hosts
pub struct RemoteConfig {
/// Ssh configuration path. If NONE, won't be read
@@ -69,6 +46,19 @@ pub struct RemoteConfig {
pub ssh_keys: HashMap<String, PathBuf>,
}
impl Default for RemoteConfig {
fn default() -> Self {
let home_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("/root"));
let mut ssh_config_path = "~/.ssh/config".to_string();
ssh_config_path = ssh_config_path.replacen('~', &home_dir.to_string_lossy(), 1);
Self {
ssh_config: Some(ssh_config_path),
ssh_keys: HashMap::default(),
}
}
}
impl Default for UserInterfaceConfig {
fn default() -> Self {
UserInterfaceConfig {
@@ -129,7 +119,7 @@ mod tests {
assert_eq!(ui.file_fmt, Some(String::from("{NAME}")));
let cfg: UserConfig = UserConfig {
user_interface: ui,
remote: remote,
remote,
};
assert_eq!(
*cfg.remote

View File

@@ -2,29 +2,6 @@
//!
//! `serialization` provides serialization and deserialization for configurations
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use serde::{de::DeserializeOwned, Serialize};
use std::io::{Read, Write};
use thiserror::Error;
@@ -142,7 +119,7 @@ mod tests {
use pretty_assertions::assert_eq;
use std::collections::HashMap;
use std::io::{Seek, SeekFrom};
use std::io::Seek;
use std::path::PathBuf;
use tuirealm::tui::style::Color;
@@ -150,12 +127,12 @@ mod tests {
fn test_config_serialization_errors() {
let error: SerializerError = SerializerError::new(SerializerErrorKind::Syntax);
assert!(error.msg.is_none());
assert_eq!(format!("{}", error), String::from("Syntax error"));
assert_eq!(format!("{error}"), String::from("Syntax error"));
let error: SerializerError =
SerializerError::new_ex(SerializerErrorKind::Syntax, String::from("bad syntax"));
assert!(error.msg.is_some());
assert_eq!(
format!("{}", error),
format!("{error}"),
String::from("Syntax error (bad syntax)")
);
// Fmt
@@ -182,7 +159,7 @@ mod tests {
fn test_config_serialization_params_deserialize_ok() {
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks_params();
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
// Parse
let cfg = deserialize(Box::new(toml_file));
assert!(cfg.is_ok());
@@ -232,7 +209,7 @@ mod tests {
fn test_config_serialization_params_deserialize_ok_no_opts() {
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks_params_no_opts();
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
// Parse
let cfg = deserialize(Box::new(toml_file));
assert!(cfg.is_ok());
@@ -272,7 +249,7 @@ mod tests {
fn test_config_serialization_params_deserialize_nok() {
let toml_file: tempfile::NamedTempFile = create_bad_toml_bookmarks_params();
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
// Parse
assert!(deserialize::<UserConfig>(Box::new(toml_file)).is_err());
}
@@ -291,7 +268,7 @@ mod tests {
assert!(serialize(&cfg, writer).is_ok());
// Reload configuration and check if it's ok
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
assert!(deserialize::<UserConfig>(Box::new(toml_file)).is_ok());
}
@@ -376,7 +353,7 @@ mod tests {
fn test_config_serializer_bookmarks_serializer_deserialize_ok() {
let toml_file: tempfile::NamedTempFile = create_good_toml_bookmarks();
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
// Parse
let hosts = deserialize(Box::new(toml_file));
assert!(hosts.is_ok());
@@ -404,6 +381,10 @@ mod tests {
assert_eq!(host.protocol, FileTransferProtocol::Sftp);
assert_eq!(host.username.as_deref().unwrap(), "cvisintin");
assert_eq!(host.password.as_deref().unwrap(), "mysecret");
assert_eq!(
host.directory.as_deref().unwrap(),
std::path::Path::new("/tmp")
);
let host: &Bookmark = hosts.bookmarks.get("aws-server-prod1").unwrap();
assert_eq!(host.address.as_deref().unwrap(), "51.23.67.12");
assert_eq!(host.port.unwrap(), 21);
@@ -419,17 +400,19 @@ mod tests {
assert_eq!(host.protocol, FileTransferProtocol::AwsS3);
let s3 = host.s3.as_ref().unwrap();
assert_eq!(s3.bucket.as_str(), "veeso");
assert_eq!(s3.region.as_str(), "eu-west-1");
assert_eq!(s3.region.as_deref().unwrap(), "eu-west-1");
assert_eq!(s3.profile.as_deref().unwrap(), "default");
assert_eq!(s3.endpoint.as_deref().unwrap(), "http://localhost:9000");
assert_eq!(s3.access_key.as_deref().unwrap(), "pippo");
assert_eq!(s3.secret_access_key.as_deref().unwrap(), "pluto");
assert_eq!(s3.new_path_style.unwrap(), true);
}
#[test]
fn test_config_serializer_bookmarks_serializer_deserialize_nok() {
let toml_file: tempfile::NamedTempFile = create_bad_toml_bookmarks();
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
// Parse
assert!(deserialize::<UserHosts>(Box::new(toml_file)).is_err());
}
@@ -446,6 +429,7 @@ mod tests {
protocol: FileTransferProtocol::Sftp,
username: Some(String::from("root")),
password: None,
directory: None,
s3: None,
},
);
@@ -457,6 +441,7 @@ mod tests {
protocol: FileTransferProtocol::Sftp,
username: Some(String::from("cvisintin")),
password: Some(String::from("password")),
directory: Some(PathBuf::from("/tmp")),
s3: None,
},
);
@@ -468,12 +453,15 @@ mod tests {
protocol: FileTransferProtocol::AwsS3,
username: None,
password: None,
directory: None,
s3: Some(S3Params {
bucket: "veeso".to_string(),
region: "eu-west-1".to_string(),
region: Some("eu-west-1".to_string()),
endpoint: None,
profile: None,
access_key: None,
secret_access_key: None,
new_path_style: None,
}),
},
);
@@ -486,6 +474,7 @@ mod tests {
protocol: FileTransferProtocol::Scp,
username: Some(String::from("omar")),
password: Some(String::from("aaa")),
directory: Some(PathBuf::from("/tmp")),
s3: None,
},
);
@@ -511,11 +500,11 @@ mod tests {
fn test_config_serialization_theme_deserialize() {
let toml_file = create_good_toml_theme();
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
assert!(deserialize::<Theme>(Box::new(toml_file)).is_ok());
let toml_file = create_bad_toml_theme();
toml_file.as_file().sync_all().unwrap();
toml_file.as_file().seek(SeekFrom::Start(0)).unwrap();
toml_file.as_file().rewind().unwrap();
assert!(deserialize::<Theme>(Box::new(toml_file)).is_err());
}
@@ -525,7 +514,7 @@ mod tests {
let file_content: &str = r#"
[bookmarks]
raspberrypi2 = { address = "192.168.1.31", port = 22, protocol = "SFTP", username = "root", password = "mypassword" }
msi-estrem = { address = "192.168.1.30", port = 22, protocol = "SFTP", username = "cvisintin", password = "mysecret" }
msi-estrem = { address = "192.168.1.30", port = 22, protocol = "SFTP", username = "cvisintin", password = "mysecret", directory = "/tmp" }
aws-server-prod1 = { address = "51.23.67.12", port = 21, protocol = "FTPS", username = "aws001" }
[bookmarks.my-bucket]
@@ -534,9 +523,11 @@ mod tests {
[bookmarks.my-bucket.s3]
bucket = "veeso"
region = "eu-west-1"
endpoint = "http://localhost:9000"
profile = "default"
access_key = "pippo"
secret_access_key = "pluto"
new_path_style = true
[recents]
ISO20201215T094000Z = { address = "172.16.104.10", port = 22, protocol = "SCP", username = "root" }

View File

@@ -2,29 +2,6 @@
//!
//! `themes` is the module which provides the themes configurations and the serializers
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// locals
use crate::utils::fmt::fmt_color;
use crate::utils::parser::parse_color;
@@ -35,7 +12,7 @@ use tuirealm::tui::style::Color;
/// ### Theme
///
/// Theme contains all the colors lookup table for termscp
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
pub struct Theme {
// -- auth
#[serde(
@@ -217,9 +194,9 @@ fn deserialize_color<'de, D>(deserializer: D) -> Result<Color, D::Error>
where
D: Deserializer<'de>,
{
let s: &str = Deserialize::deserialize(deserializer)?;
let s: String = Deserialize::deserialize(deserializer)?;
// Parse color
match parse_color(s) {
match parse_color(&s) {
None => Err(DeError::custom("Invalid color")),
Some(color) => Ok(color),
}

View File

@@ -2,29 +2,6 @@
//!
//! `builder` is the module which provides a builder for FileExplorer
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Locals
use super::formatter::Formatter;
use super::{ExplorerOpts, FileExplorer, FileSorting, GroupDirs};

View File

@@ -2,38 +2,17 @@
//!
//! `formatter` is the module which provides formatting utilities for `FileExplorer`
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Locals
use crate::utils::fmt::{fmt_path_elide, fmt_pex, fmt_time};
use crate::utils::path::diff_paths;
use crate::utils::string::secure_substring;
// Ext
use bytesize::ByteSize;
use regex::Regex;
use lazy_regex::{Lazy, Regex};
use remotefs::File;
use std::path::PathBuf;
use std::time::UNIX_EPOCH;
use unicode_width::UnicodeWidthStr;
#[cfg(target_family = "unix")]
use users::{get_group_by_gid, get_user_by_uid};
// Types
@@ -53,17 +32,14 @@ const FMT_KEY_SYMLINK: &str = "SYMLINK";
const FMT_KEY_USER: &str = "USER";
// Default
const FMT_DEFAULT_STX: &str = "{NAME} {PEX} {USER} {SIZE} {MTIME}";
// Regex
lazy_static! {
/**
* Regex matches:
* - group 0: KEY NAME
* - group 1?: LENGTH
* - group 2?: EXTRA
*/
static ref FMT_KEY_REGEX: Regex = Regex::new(r"\{(.*?)\}").ok().unwrap();
static ref FMT_ATTR_REGEX: Regex = Regex::new(r"(?:([A-Z]+))(:?([0-9]+))?(:?(.+))?").ok().unwrap();
}
/**
* Regex matches:
* - group 0: KEY NAME
* - group 1?: LENGTH
* - group 2?: EXTRA
*/
static FMT_KEY_REGEX: Lazy<Regex> = lazy_regex!(r"\{(.*?)\}");
static FMT_ATTR_REGEX: Lazy<Regex> = lazy_regex!(r"(?:([A-Z]+))(:?([0-9]+))?(:?(.+))?");
/// Call Chain block is a block in a chain of functions which are called in order to format the File.
/// A callChain is instantiated starting from the Formatter syntax and the regex, once the groups are found
@@ -303,15 +279,15 @@ impl Formatter {
true => file_len - 2,
false => file_len - 1,
};
let mut name: String = match name.len() >= file_len {
let mut name: String = match name.width() >= file_len {
false => name,
true => format!("{}", &name[0..last_idx]),
true => format!("{}", secure_substring(&name, 0, last_idx)),
};
if fsentry.is_dir() {
name.push('/');
}
// Add to cur str, prefix and the key value
format!("{}{}{:0width$}", cur_str, prefix, name, width = file_len)
format!("{cur_str}{prefix}{name:0file_len$}")
}
/// Format path
@@ -371,7 +347,7 @@ impl Formatter {
),
}
// Add to cur str, prefix and the key value
format!("{}{}{:10}", cur_str, prefix, pex)
format!("{cur_str}{prefix}{pex:10}")
}
/// Format file size
@@ -387,7 +363,7 @@ impl Formatter {
// Get byte size
let size: ByteSize = ByteSize(fsentry.metadata().size);
// Add to cur str, prefix and the key value
format!("{}{}{:10}", cur_str, prefix, size.to_string())
format!("{cur_str}{prefix}{size:10}")
} else if fsentry.metadata().symlink.is_some() {
let size = ByteSize(
fsentry
@@ -398,10 +374,10 @@ impl Formatter {
.to_string_lossy()
.len() as u64,
);
format!("{}{}{:10}", cur_str, prefix, size.to_string())
format!("{cur_str}{prefix}{size:10}")
} else {
// Add to cur str, prefix and the key value
format!("{}{} ", cur_str, prefix)
format!("{cur_str}{prefix} ")
}
}
@@ -421,7 +397,7 @@ impl Formatter {
};
// Replace `FMT_KEY_NAME` with name
match fsentry.metadata().symlink.as_deref() {
None => format!("{}{} ", cur_str, prefix),
None => format!("{cur_str}{prefix} "),
Some(p) => format!(
"{}{}-> {:0width$}",
cur_str,
@@ -456,7 +432,7 @@ impl Formatter {
None => 0.to_string(),
};
// Add to cur str, prefix and the key value
format!("{}{}{:12}", cur_str, prefix, username)
format!("{cur_str}{prefix}{username:12}")
}
/// Fallback function in case the format key is unknown
@@ -470,7 +446,7 @@ impl Formatter {
_fmt_extra: Option<&String>,
) -> String {
// Add to cur str and prefix
format!("{}{}", cur_str, prefix)
format!("{cur_str}{prefix}")
}
// Static
@@ -916,6 +892,113 @@ mod tests {
assert_eq!(formatter.fmt(&entry).as_str(), "File path: c/bar.txt");
}
#[test]
#[cfg(target_family = "unix")]
fn should_fmt_utf8_path() {
let t: SystemTime = SystemTime::now();
let entry = File {
path: PathBuf::from("/tmp/a/b/c/россия"),
metadata: Metadata {
accessed: Some(t),
created: Some(t),
modified: Some(t),
file_type: FileType::Symlink,
size: 8192,
symlink: Some(PathBuf::from("project.info")),
uid: None,
gid: None,
mode: Some(UnixPex::from(0o644)),
},
};
let formatter: Formatter = Formatter::new("File path: {PATH}");
assert_eq!(
formatter.fmt(&entry).as_str(),
"File path: /tmp/a/b/c/россия"
);
let formatter: Formatter = Formatter::new("File path: {PATH:8}");
assert_eq!(formatter.fmt(&entry).as_str(), "File path: /tmp/…/c/россия");
}
#[test]
fn should_fmt_short_ascii_name() {
let entry = File {
path: PathBuf::from("/tmp/foo.txt"),
metadata: Metadata {
accessed: None,
created: None,
modified: None,
file_type: FileType::File,
size: 8192,
symlink: None,
uid: None,
gid: None,
mode: None,
},
};
let formatter: Formatter = Formatter::new("{NAME:8}");
assert_eq!(formatter.fmt(&entry).as_str(), "foo.txt ");
}
#[test]
fn should_fmt_exceeding_length_ascii_name() {
let entry = File {
path: PathBuf::from("/tmp/christian-visintin.txt"),
metadata: Metadata {
accessed: None,
created: None,
modified: None,
file_type: FileType::File,
size: 8192,
symlink: None,
uid: None,
gid: None,
mode: None,
},
};
let formatter: Formatter = Formatter::new("{NAME:8}");
assert_eq!(formatter.fmt(&entry).as_str(), "christi…");
}
#[test]
fn should_fmt_short_utf8_name() {
let entry = File {
path: PathBuf::from("/tmp/россия"),
metadata: Metadata {
accessed: None,
created: None,
modified: None,
file_type: FileType::File,
size: 8192,
symlink: None,
uid: None,
gid: None,
mode: None,
},
};
let formatter: Formatter = Formatter::new("{NAME:8}");
assert_eq!(formatter.fmt(&entry).as_str(), "россия ");
}
#[test]
fn should_fmt_long_utf8_name() {
let entry = File {
path: PathBuf::from("/tmp/喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵喵"),
metadata: Metadata {
accessed: None,
created: None,
modified: None,
file_type: FileType::File,
size: 8192,
symlink: None,
uid: None,
gid: None,
mode: None,
},
};
let formatter: Formatter = Formatter::new("{NAME:8}");
assert_eq!(formatter.fmt(&entry).as_str(), "喵喵喵喵喵喵喵…");
}
/// Dummy formatter, just yelds an 'A' at the end of the current string
fn dummy_fmt(
_fmt: &Formatter,
@@ -925,6 +1008,6 @@ mod tests {
_fmt_len: Option<&usize>,
_fmt_extra: Option<&String>,
) -> String {
format!("{}{}A", cur_str, prefix)
format!("{cur_str}{prefix}A")
}
}

View File

@@ -2,29 +2,6 @@
//!
//! `explorer` is the module which provides an Helper in handling Directory status through
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Mods
pub(crate) mod builder;
mod formatter;
@@ -48,7 +25,7 @@ bitflags! {
}
/// FileSorting defines the criteria for sorting files
#[derive(Copy, Clone, PartialEq, std::fmt::Debug)]
#[derive(Copy, Clone, PartialEq, Eq, std::fmt::Debug)]
pub enum FileSorting {
Name,
ModifyTime,
@@ -57,7 +34,7 @@ pub enum FileSorting {
}
/// GroupDirs defines how directories should be grouped in sorting files
#[derive(PartialEq, std::fmt::Debug)]
#[derive(PartialEq, Eq, std::fmt::Debug)]
pub enum GroupDirs {
First,
Last,
@@ -341,8 +318,8 @@ mod tests {
explorer.stack_size = 2;
explorer.dirstack = VecDeque::with_capacity(2);
// Push dir
explorer.pushd(&Path::new("/tmp"));
explorer.pushd(&Path::new("/home/omar"));
explorer.pushd(Path::new("/tmp"));
explorer.pushd(Path::new("/home/omar"));
// Pop
assert_eq!(explorer.popd().unwrap(), PathBuf::from("/home/omar"));
assert_eq!(explorer.dirstack.len(), 1);
@@ -351,9 +328,9 @@ mod tests {
// Dirstack is empty now
assert!(explorer.popd().is_none());
// Exceed limit
explorer.pushd(&Path::new("/tmp"));
explorer.pushd(&Path::new("/home/omar"));
explorer.pushd(&Path::new("/dev"));
explorer.pushd(Path::new("/tmp"));
explorer.pushd(Path::new("/home/omar"));
explorer.pushd(Path::new("/dev"));
assert_eq!(explorer.dirstack.len(), 2);
assert_eq!(*explorer.dirstack.get(1).unwrap(), PathBuf::from("/dev"));
assert_eq!(

View File

@@ -2,29 +2,6 @@
//!
//! Remotefs client builder
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::params::{AwsS3Params, GenericProtocolParams};
use super::{FileTransferProtocol, ProtocolParams};
use crate::system::config_client::ConfigClient;
@@ -63,20 +40,23 @@ impl Builder {
}
(protocol, params) => {
error!("Invalid params for protocol '{:?}'", protocol);
panic!(
"Invalid protocol '{:?}' with parameters of type {:?}",
protocol, params
)
panic!("Invalid protocol '{protocol:?}' with parameters of type {params:?}")
}
}
}
/// Build aws s3 client from parameters
fn aws_s3_client(params: AwsS3Params) -> AwsS3Fs {
let mut client = AwsS3Fs::new(params.bucket_name, params.region);
let mut client = AwsS3Fs::new(params.bucket_name).new_path_style(params.new_path_style);
if let Some(region) = params.region {
client = client.region(region);
}
if let Some(profile) = params.profile {
client = client.profile(profile);
}
if let Some(endpoint) = params.endpoint {
client = client.endpoint(endpoint);
}
if let Some(access_key) = params.access_key {
client = client.access_key(access_key);
}
@@ -151,7 +131,9 @@ mod test {
#[test]
fn should_build_aws_s3_fs() {
let params = ProtocolParams::AwsS3(
AwsS3Params::new("omar", "eu-west-1", Some("test"))
AwsS3Params::new("omar", Some("eu-west-1"), Some("test"))
.endpoint(Some("http://localhost:9000"))
.new_path_style(true)
.access_key(Some("pippo"))
.secret_access_key(Some("pluto"))
.security_token(Some("omar"))

View File

@@ -2,29 +2,6 @@
//!
//! `filetransfer` is the module which provides the file transfer protocols and remotefs builders
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
mod builder;
pub mod params;
@@ -34,7 +11,7 @@ pub use params::{FileTransferParams, ProtocolParams};
/// This enum defines the different transfer protocol available in termscp
#[derive(PartialEq, Debug, Clone, Copy)]
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub enum FileTransferProtocol {
Sftp,
Scp,

View File

@@ -2,29 +2,6 @@
//!
//! file transfer parameters
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::FileTransferProtocol;
use std::path::{Path, PathBuf};
@@ -59,12 +36,14 @@ pub struct GenericProtocolParams {
#[derive(Debug, Clone)]
pub struct AwsS3Params {
pub bucket_name: String,
pub region: String,
pub region: Option<String>,
pub endpoint: Option<String>,
pub profile: Option<String>,
pub access_key: Option<String>,
pub secret_access_key: Option<String>,
pub security_token: Option<String>,
pub session_token: Option<String>,
pub new_path_style: bool,
}
impl FileTransferParams {
@@ -82,6 +61,23 @@ impl FileTransferParams {
self.entry_directory = dir.map(|x| x.as_ref().to_path_buf());
self
}
/// Returns whether a password is supposed to be required for this protocol params.
/// The result true is returned ONLY if the supposed secret is MISSING!!!
pub fn password_missing(&self) -> bool {
match &self.params {
ProtocolParams::AwsS3(params) => params.password_missing(),
ProtocolParams::Generic(params) => params.password_missing(),
}
}
/// Set the secret to ft params for the default secret field for this protocol
pub fn set_default_secret(&mut self, secret: String) {
match &mut self.params {
ProtocolParams::AwsS3(params) => params.set_default_secret(secret),
ProtocolParams::Generic(params) => params.set_default_secret(secret),
}
}
}
impl Default for FileTransferParams {
@@ -106,6 +102,7 @@ impl ProtocolParams {
}
}
#[cfg(test)]
/// Get a mutable reference to the inner generic protocol params
pub fn mut_generic_params(&mut self) -> Option<&mut GenericProtocolParams> {
match self {
@@ -161,24 +158,43 @@ impl GenericProtocolParams {
self.password = password.map(|x| x.as_ref().to_string());
self
}
/// Returns whether a password is supposed to be required for this protocol params.
/// The result true is returned ONLY if the supposed secret is MISSING!!!
pub fn password_missing(&self) -> bool {
self.password.is_none()
}
/// Set password
pub fn set_default_secret(&mut self, secret: String) {
self.password = Some(secret);
}
}
// -- S3 params
impl AwsS3Params {
/// Instantiates a new `AwsS3Params` struct
pub fn new<S: AsRef<str>>(bucket: S, region: S, profile: Option<S>) -> Self {
pub fn new<S: AsRef<str>>(bucket: S, region: Option<S>, profile: Option<S>) -> Self {
Self {
bucket_name: bucket.as_ref().to_string(),
region: region.as_ref().to_string(),
region: region.map(|x| x.as_ref().to_string()),
profile: profile.map(|x| x.as_ref().to_string()),
endpoint: None,
access_key: None,
secret_access_key: None,
security_token: None,
session_token: None,
new_path_style: false,
}
}
/// Construct aws s3 params with specified endpoint
pub fn endpoint<S: AsRef<str>>(mut self, endpoint: Option<S>) -> Self {
self.endpoint = endpoint.map(|x| x.as_ref().to_string());
self
}
/// Construct aws s3 params with provided access key
pub fn access_key<S: AsRef<str>>(mut self, key: Option<S>) -> Self {
self.access_key = key.map(|x| x.as_ref().to_string());
@@ -202,6 +218,23 @@ impl AwsS3Params {
self.session_token = key.map(|x| x.as_ref().to_string());
self
}
/// Specify new path style when constructing aws s3 params
pub fn new_path_style(mut self, new_path_style: bool) -> Self {
self.new_path_style = new_path_style;
self
}
/// Returns whether a password is supposed to be required for this protocol params.
/// The result true is returned ONLY if the supposed secret is MISSING!!!
pub fn password_missing(&self) -> bool {
self.secret_access_key.is_none() && self.security_token.is_none()
}
/// Set password
pub fn set_default_secret(&mut self, secret: String) {
self.secret_access_key = Some(secret);
}
}
#[cfg(test)]
@@ -240,35 +273,42 @@ mod test {
#[test]
fn should_init_aws_s3_params() {
let params: AwsS3Params = AwsS3Params::new("omar", "eu-west-1", Some("test"));
let params: AwsS3Params = AwsS3Params::new("omar", Some("eu-west-1"), Some("test"));
assert_eq!(params.bucket_name.as_str(), "omar");
assert_eq!(params.region.as_str(), "eu-west-1");
assert_eq!(params.region.as_deref().unwrap(), "eu-west-1");
assert_eq!(params.profile.as_deref().unwrap(), "test");
assert!(params.endpoint.is_none());
assert!(params.access_key.is_none());
assert!(params.secret_access_key.is_none());
assert!(params.security_token.is_none());
assert!(params.session_token.is_none());
assert_eq!(params.new_path_style, false);
}
#[test]
fn should_init_aws_s3_params_with_optionals() {
let params: AwsS3Params = AwsS3Params::new("omar", "eu-west-1", Some("test"))
let params: AwsS3Params = AwsS3Params::new("omar", Some("eu-west-1"), Some("test"))
.endpoint(Some("http://omar.it"))
.access_key(Some("pippo"))
.secret_access_key(Some("pluto"))
.security_token(Some("omar"))
.session_token(Some("gerry-scotti"));
.session_token(Some("gerry-scotti"))
.new_path_style(true);
assert_eq!(params.bucket_name.as_str(), "omar");
assert_eq!(params.region.as_str(), "eu-west-1");
assert_eq!(params.region.as_deref().unwrap(), "eu-west-1");
assert_eq!(params.profile.as_deref().unwrap(), "test");
assert_eq!(params.endpoint.as_deref().unwrap(), "http://omar.it");
assert_eq!(params.access_key.as_deref().unwrap(), "pippo");
assert_eq!(params.secret_access_key.as_deref().unwrap(), "pluto");
assert_eq!(params.security_token.as_deref().unwrap(), "omar");
assert_eq!(params.session_token.as_deref().unwrap(), "gerry-scotti");
assert_eq!(params.new_path_style, true);
}
#[test]
fn references() {
let mut params = ProtocolParams::AwsS3(AwsS3Params::new("omar", "eu-west-1", Some("test")));
let mut params =
ProtocolParams::AwsS3(AwsS3Params::new("omar", Some("eu-west-1"), Some("test")));
assert!(params.s3_params().is_some());
assert!(params.generic_params().is_none());
assert!(params.mut_generic_params().is_none());
@@ -277,4 +317,83 @@ mod test {
assert!(params.generic_params().is_some());
assert!(params.mut_generic_params().is_some());
}
#[test]
fn password_missing() {
assert!(FileTransferParams::new(
FileTransferProtocol::Scp,
ProtocolParams::AwsS3(AwsS3Params::new("omar", Some("eu-west-1"), Some("test")))
)
.password_missing());
assert_eq!(
FileTransferParams::new(
FileTransferProtocol::Scp,
ProtocolParams::AwsS3(
AwsS3Params::new("omar", Some("eu-west-1"), Some("test"))
.secret_access_key(Some("test"))
)
)
.password_missing(),
false
);
assert_eq!(
FileTransferParams::new(
FileTransferProtocol::Scp,
ProtocolParams::AwsS3(
AwsS3Params::new("omar", Some("eu-west-1"), Some("test"))
.security_token(Some("test"))
)
)
.password_missing(),
false
);
assert!(
FileTransferParams::new(FileTransferProtocol::Scp, ProtocolParams::default())
.password_missing()
);
assert_eq!(
FileTransferParams::new(
FileTransferProtocol::Scp,
ProtocolParams::Generic(GenericProtocolParams::default().password(Some("Hello")))
)
.password_missing(),
false
);
}
#[test]
fn set_default_secret_aws_s3() {
let mut params = FileTransferParams::new(
FileTransferProtocol::Scp,
ProtocolParams::AwsS3(AwsS3Params::new("omar", Some("eu-west-1"), Some("test"))),
);
params.set_default_secret(String::from("secret"));
assert_eq!(
params
.params
.s3_params()
.unwrap()
.secret_access_key
.as_deref()
.unwrap(),
"secret"
);
}
#[test]
fn set_default_secret_generic() {
let mut params =
FileTransferParams::new(FileTransferProtocol::Scp, ProtocolParams::default());
params.set_default_secret(String::from("secret"));
assert_eq!(
params
.params
.generic_params()
.unwrap()
.password
.as_deref()
.unwrap(),
"secret"
);
}
}

View File

@@ -2,30 +2,8 @@
//!
//! `host` is the module which provides functionalities to host file system
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// ext
use filetime::{self, FileTime};
#[cfg(target_family = "unix")]
use remotefs::fs::UnixPex;
use remotefs::fs::{File, FileType, Metadata};
@@ -98,7 +76,7 @@ impl std::fmt::Display for HostError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let p_str: String = match self.path.as_ref() {
None => String::new(),
Some(p) => format!(" ({})", p.display().to_string()),
Some(p) => format!(" ({})", p.display()),
};
match &self.ioerr {
Some(err) => write!(f, "{}: {}{}", self.error, err, p_str),
@@ -429,6 +407,27 @@ impl Localhost {
Ok(File { path, metadata })
}
/// Set file stat
pub fn setstat(&self, path: &Path, metadata: &Metadata) -> Result<(), HostError> {
debug!("Setting stat for file at {}", path.display());
if let Some(mtime) = metadata.modified {
let mtime = FileTime::from_system_time(mtime);
debug!("setting mtime {:?}", mtime);
filetime::set_file_mtime(path, mtime)
.map_err(|e| HostError::new(HostErrorType::FileNotAccessible, Some(e), path))?;
}
if let Some(atime) = metadata.accessed {
let atime = FileTime::from_system_time(atime);
filetime::set_file_atime(path, atime)
.map_err(|e| HostError::new(HostErrorType::FileNotAccessible, Some(e), path))?;
}
#[cfg(target_family = "unix")]
if let Some(mode) = metadata.mode {
self.chmod(path, mode)?;
}
Ok(())
}
/// Execute a command on localhost
pub fn exec(&self, cmd: &str) -> Result<String, HostError> {
// Make command
@@ -648,8 +647,8 @@ mod tests {
use super::*;
#[cfg(target_family = "unix")]
use crate::utils::test_helpers::{create_sample_file, make_fsentry};
use crate::utils::test_helpers::{make_dir_at, make_file_at};
use crate::utils::test_helpers::make_fsentry;
use crate::utils::test_helpers::{create_sample_file, make_dir_at, make_file_at};
use pretty_assertions::assert_eq;
#[cfg(target_family = "unix")]
@@ -659,6 +658,8 @@ mod tests {
#[cfg(target_family = "unix")]
use std::os::unix::fs::{symlink, PermissionsExt};
use std::time::SystemTime;
use std::{ops::AddAssign, time::Duration};
#[test]
fn test_host_error_new() {
@@ -677,7 +678,7 @@ mod tests {
let entries = std::fs::read_dir(PathBuf::from("/dev").as_path()).unwrap();
let mut counter: usize = 0;
for _ in entries {
counter = counter + 1;
counter += 1;
}
assert_eq!(host.files.len(), counter);
}
@@ -719,7 +720,7 @@ mod tests {
let entries = std::fs::read_dir(PathBuf::from("/dev").as_path()).unwrap();
let mut counter: usize = 0;
for _ in entries {
counter = counter + 1;
counter += 1;
}
assert_eq!(host.list_dir().len(), counter);
}
@@ -732,10 +733,10 @@ mod tests {
assert!(host.change_wrkdir(new_dir.as_path()).is_ok());
// Verify new files
// Scan dir
let entries = std::fs::read_dir(PathBuf::from(new_dir).as_path()).unwrap();
let entries = std::fs::read_dir(new_dir.as_path()).unwrap();
let mut counter: usize = 0;
for _ in entries {
counter = counter + 1;
counter += 1;
}
assert_eq!(host.files.len(), counter);
}
@@ -816,7 +817,7 @@ mod tests {
let files: Vec<File> = host.list_dir();
// Verify files
let file_0: &File = files.get(0).unwrap();
if file_0.name() == String::from("foo.txt") {
if file_0.name() == *"foo.txt" {
assert!(file_0.metadata.symlink.is_none());
} else {
assert_eq!(
@@ -826,7 +827,7 @@ mod tests {
}
// Verify simlink
let file_1: &File = files.get(1).unwrap();
if file_1.name() == String::from("bar.txt") {
if file_1.name() == *"bar.txt" {
assert_eq!(
file_1.metadata.symlink.as_ref().unwrap(),
&PathBuf::from(format!("{}/foo.txt", tmpdir.path().display()))
@@ -919,6 +920,31 @@ mod tests {
.is_err());
}
#[test]
fn should_setstat() {
let tmpdir: tempfile::TempDir = tempfile::TempDir::new().unwrap();
let file: tempfile::NamedTempFile = create_sample_file();
let host: Localhost = Localhost::new(PathBuf::from(tmpdir.path())).ok().unwrap();
// stat
let mut filemeta = host.stat(file.path()).unwrap();
let mut new_atime = SystemTime::UNIX_EPOCH;
new_atime.add_assign(Duration::from_secs(1612164210));
let mut new_mtime = SystemTime::UNIX_EPOCH;
new_mtime.add_assign(Duration::from_secs(1613160210));
filemeta.metadata.accessed = Some(new_atime);
filemeta.metadata.modified = Some(new_mtime);
// setstat
assert!(host.setstat(filemeta.path(), filemeta.metadata()).is_ok());
let new_metadata = host.stat(file.path()).unwrap();
assert_eq!(new_metadata.metadata().accessed, Some(new_atime));
assert_eq!(new_metadata.metadata().modified, Some(new_mtime));
}
#[cfg(target_family = "unix")]
#[test]
fn test_host_chmod() {
@@ -1122,7 +1148,7 @@ mod tests {
Path::new("/tmp"),
);
assert_eq!(
format!("{}", err),
format!("{err}"),
String::from("Could not create file: address in use (/tmp)"),
);
assert_eq!(

View File

@@ -1,35 +1,12 @@
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
const TERMSCP_VERSION: &str = env!("CARGO_PKG_VERSION");
const TERMSCP_AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
// Crates
extern crate argh;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate lazy_regex;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
@@ -37,13 +14,13 @@ extern crate log;
extern crate magic_crypt;
// External libs
use argh::FromArgs;
use std::env;
use std::path::PathBuf;
use std::time::Duration;
// Include
mod activity_manager;
mod cli_opts;
mod config;
mod explorer;
mod filetransfer;
@@ -55,108 +32,33 @@ mod utils;
// namespaces
use activity_manager::{ActivityManager, NextActivity};
use cli_opts::{Args, BookmarkParams, HostParams, Remote, RunOpts, Task};
use filetransfer::FileTransferParams;
use system::logging::{self, LogLevel};
enum Task {
Activity(NextActivity),
ImportTheme(PathBuf),
InstallUpdate,
}
#[derive(FromArgs)]
#[argh(description = "
where positional can be: [address] [local-wrkdir]
Address syntax can be:
- `protocol://user@address:port:wrkdir` for protocols such as Sftp, Scp, Ftp
- `s3://bucket-name@region:profile:/wrkdir` for Aws S3 protocol
Please, report issues to <https://github.com/veeso/termscp>
Please, consider supporting the author <https://ko-fi.com/veeso>")]
struct Args {
#[argh(switch, short = 'c', description = "open termscp configuration")]
config: bool,
#[argh(switch, short = 'D', description = "enable TRACE log level")]
debug: bool,
#[argh(option, short = 'P', description = "provide password from CLI")]
password: Option<String>,
#[argh(switch, short = 'q', description = "disable logging")]
quiet: bool,
#[argh(option, short = 't', description = "import specified theme")]
theme: Option<String>,
#[argh(
switch,
short = 'u',
description = "update termscp to the latest version"
)]
update: bool,
#[argh(
option,
short = 'T',
default = "10",
description = "set UI ticks; default 10ms"
)]
ticks: u64,
#[argh(switch, short = 'v', description = "print version")]
version: bool,
// -- positional
#[argh(
positional,
description = "protocol://user@address:port:wrkdir local-wrkdir"
)]
positional: Vec<String>,
}
struct RunOpts {
remote: Option<FileTransferParams>,
ticks: Duration,
log_level: LogLevel,
task: Task,
}
impl Default for RunOpts {
fn default() -> Self {
Self {
remote: None,
ticks: Duration::from_millis(10),
log_level: LogLevel::Info,
task: Task::Activity(NextActivity::Authentication),
}
}
}
fn main() {
let args: Args = argh::from_env();
// Parse args
let mut run_opts: RunOpts = match parse_args(args) {
let run_opts: RunOpts = match parse_args(args) {
Ok(opts) => opts,
Err(err) => {
eprintln!("{}", err);
eprintln!("{err}");
std::process::exit(255);
}
};
// Setup logging
if let Err(err) = logging::init(run_opts.log_level) {
eprintln!("Failed to initialize logging: {}", err);
}
// Read password from remote
if let Err(err) = read_password(&mut run_opts) {
eprintln!("{}", err);
std::process::exit(255);
eprintln!("Failed to initialize logging: {err}");
}
info!("termscp {} started!", TERMSCP_VERSION);
// Run
info!("Starting activity manager...");
let rc: i32 = run(run_opts);
info!("termscp terminated");
let rc = run(run_opts);
info!("termscp terminated with exitcode {}", rc);
// Then return
std::process::exit(rc);
}
/// ### parse_args
///
/// Parse arguments
/// In case of success returns `RunOpts`
/// in case something is wrong returns the error message
@@ -165,8 +67,7 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
// Version
if args.version {
return Err(format!(
"termscp - {} - Developed by {}",
TERMSCP_VERSION, TERMSCP_AUTHORS,
"termscp - {TERMSCP_VERSION} - Developed by {TERMSCP_AUTHORS}",
));
}
// Setup activity?
@@ -182,7 +83,7 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
// Match ticks
run_opts.ticks = Duration::from_millis(args.ticks);
// @! extra modes
if let Some(theme) = args.theme {
if let Some(theme) = args.theme.as_deref() {
run_opts.task = Task::ImportTheme(PathBuf::from(theme));
}
if args.update {
@@ -190,74 +91,55 @@ fn parse_args(args: Args) -> Result<RunOpts, String> {
}
// @! Ordinary mode
// Remote argument
if let Some(remote) = args.positional.get(0) {
// Parse address
match utils::parser::parse_remote_opt(remote.as_str()) {
Ok(mut remote) => {
// If password is provided, set password
if let Some(passwd) = args.password {
if let Some(mut params) = remote.params.mut_generic_params() {
params.password = Some(passwd);
}
}
// Set params
run_opts.remote = Some(remote);
// In this case the first activity will be FileTransfer
run_opts.task = Task::Activity(NextActivity::FileTransfer);
}
Err(err) => {
return Err(format!("Bad address option: {}", err));
}
match parse_address_arg(&args) {
Err(err) => return Err(err),
Ok(Remote::None) => {}
Ok(remote) => {
// Set params
run_opts.remote = remote;
// In this case the first activity will be FileTransfer
run_opts.task = Task::Activity(NextActivity::FileTransfer);
}
}
// Local directory
if let Some(localdir) = args.positional.get(1) {
// Change working directory if local dir is set
let localdir: PathBuf = PathBuf::from(localdir);
if let Err(err) = env::set_current_dir(localdir.as_path()) {
return Err(format!("Bad working directory argument: {}", err));
return Err(format!("Bad working directory argument: {err}"));
}
}
Ok(run_opts)
}
/// ### read_password
///
/// Read password from tty if address is specified
fn read_password(run_opts: &mut RunOpts) -> Result<(), String> {
// Initialize client if necessary
if let Some(remote) = run_opts.remote.as_mut() {
// Ask password for generic params
if let Some(mut params) = remote.params.mut_generic_params() {
// Ask password only if generic protocol params
if params.password.is_none() {
// Ask password if unspecified
params.password = match rpassword::read_password_from_tty(Some("Password: ")) {
Ok(p) => {
if p.is_empty() {
None
} else {
debug!(
"Read password from tty: {}",
utils::fmt::shadow_password(p.as_str())
);
Some(p)
}
}
Err(_) => {
return Err("Could not read password from prompt".to_string());
}
};
}
/// Parse address argument from cli args
fn parse_address_arg(args: &Args) -> Result<Remote, String> {
if let Some(remote) = args.positional.get(0) {
if args.address_as_bookmark {
Ok(Remote::Bookmark(BookmarkParams::new(
remote,
args.password.as_ref(),
)))
} else {
// Parse address
parse_remote_address(remote.as_str())
.map(|x| Remote::Host(HostParams::new(x, args.password.as_deref())))
}
} else {
Ok(Remote::None)
}
Ok(())
}
/// Parse remote address
fn parse_remote_address(remote: &str) -> Result<FileTransferParams, String> {
utils::parser::parse_remote_opt(remote).map_err(|e| format!("Bad address option: {e}"))
}
/// ### run
///
/// Run task and return rc
fn run(mut run_opts: RunOpts) -> i32 {
fn run(run_opts: RunOpts) -> i32 {
match run_opts.task {
Task::ImportTheme(theme) => match support::import_theme(theme.as_path()) {
Ok(_) => {
@@ -265,17 +147,17 @@ fn run(mut run_opts: RunOpts) -> i32 {
0
}
Err(err) => {
eprintln!("{}", err);
eprintln!("{err}");
1
}
},
Task::InstallUpdate => match support::install_update() {
Ok(msg) => {
println!("{}", msg);
println!("{msg}");
0
}
Err(err) => {
eprintln!("Could not install update: {}", err);
eprintln!("Could not install update: {err}");
1
}
},
@@ -290,13 +172,25 @@ fn run(mut run_opts: RunOpts) -> i32 {
match ActivityManager::new(wrkdir.as_path(), run_opts.ticks) {
Ok(m) => m,
Err(err) => {
eprintln!("Could not start activity manager: {}", err);
eprintln!("Could not start activity manager: {err}");
return 1;
}
};
// Set file transfer params if set
if let Some(remote) = run_opts.remote.take() {
manager.set_filetransfer_params(remote);
match run_opts.remote {
Remote::Bookmark(BookmarkParams { name, password }) => {
if let Err(err) = manager.resolve_bookmark_name(&name, password.as_deref()) {
eprintln!("{err}");
return 1;
}
}
Remote::Host(HostParams { params, password }) => {
if let Err(err) = manager.set_filetransfer_params(params, password.as_deref()) {
eprintln!("{err}");
return 1;
}
}
Remote::None => {}
}
manager.run(activity);
0

View File

@@ -2,29 +2,6 @@
//!
//! this module exposes some extra run modes for termscp, meant to be used for "support", such as installing themes
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// mod
use crate::system::{
auto_update::{Update, UpdateStatus},
@@ -46,7 +23,7 @@ pub fn import_theme(p: &Path) -> Result<(), String> {
));
}
// Validate theme file
ThemeProvider::new(p).map_err(|e| format!("Invalid theme error: {}", e))?;
ThemeProvider::new(p).map_err(|e| format!("Invalid theme error: {e}"))?;
// get config dir
let cfg_dir: PathBuf = get_config_dir()?;
// Get theme directory
@@ -54,7 +31,7 @@ pub fn import_theme(p: &Path) -> Result<(), String> {
// Copy theme to theme_dir
fs::copy(p, theme_file.as_path())
.map(|_| ())
.map_err(|e| format!("Could not import theme: {}", e))
.map_err(|e| format!("Could not import theme: {e}"))
}
/// ### install_update
@@ -74,7 +51,7 @@ pub fn install_update() -> Result<String, String> {
{
Notification::update_installed(v.as_str());
}
Ok(format!("termscp has been updated to version {}", v))
Ok(format!("termscp has been updated to version {v}"))
}
Err(err) => {
if get_config_client()
@@ -98,8 +75,7 @@ fn get_config_dir() -> Result<PathBuf, String> {
"Your system doesn't provide a configuration directory",
)),
Err(err) => Err(format!(
"Could not initialize configuration directory: {}",
err
"Could not initialize configuration directory: {err}"
)),
}
}

View File

@@ -2,29 +2,6 @@
//!
//! Automatic update module. This module is used to upgrade the current version of termscp to the latest available on Github
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use crate::utils::parser::parse_semver;
pub use self_update::errors::Error as UpdateError;
@@ -119,7 +96,7 @@ impl Update {
new_version,
cargo_crate_version!()
);
if new_version.as_str() > cargo_crate_version!() {
if Self::is_new_version_higher(new_version.as_str(), cargo_crate_version!()) {
Some(r) // New version is available
} else {
None // No new version
@@ -128,6 +105,12 @@ impl Update {
None => None,
}
}
/// Check wether new version is higher than new version
fn is_new_version_higher(new_version: &str, current_version: &str) -> bool {
version_compare::compare(new_version, current_version).unwrap_or(version_compare::Cmp::Lt)
== version_compare::Cmp::Gt
}
}
impl From<Status> for UpdateStatus {
fn from(s: Status) -> Self {
@@ -216,4 +199,13 @@ mod test {
assert_eq!(release.body.as_str(), "fixed everything");
assert_eq!(release.version.as_str(), "0.7.0");
}
#[test]
fn should_tell_that_version_is_higher() {
assert!(Update::is_new_version_higher("0.10.0", "0.9.0"));
assert!(Update::is_new_version_higher("0.20.0", "0.19.0"));
assert!(!Update::is_new_version_higher("0.9.0", "0.10.0"));
assert!(!Update::is_new_version_higher("0.9.9", "0.10.1"));
assert!(!Update::is_new_version_higher("0.10.9", "0.11.0"));
}
}

View File

@@ -2,29 +2,6 @@
//!
//! `bookmarks_client` is the module which provides an API between the Bookmarks module and the system
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Crate
#[cfg(feature = "with-keyring")]
use super::keys::keyringstorage::KeyringStorage;
@@ -111,7 +88,7 @@ impl BookmarksClient {
error!("Failed to set new key into storage: {}", e);
return Err(SerializerError::new_ex(
SerializerErrorKind::Io,
format!("Could not write key to storage: {}", e),
format!("Could not write key to storage: {e}"),
));
}
// Return key
@@ -121,7 +98,7 @@ impl BookmarksClient {
error!("Failed to get key from storage: {}", e);
return Err(SerializerError::new_ex(
SerializerErrorKind::Io,
format!("Could not get key from storage: {}", e),
format!("Could not get key from storage: {e}"),
));
}
},
@@ -506,7 +483,7 @@ mod tests {
assert_eq!(params.profile.as_deref().unwrap(), "test");
assert_eq!(params.secret_access_key.as_deref().unwrap(), "pluto");
assert_eq!(params.bucket_name.as_str(), "omar");
assert_eq!(params.region.as_str(), "eu-west-1");
assert_eq!(params.region.as_deref().unwrap(), "eu-west-1");
}
#[test]
@@ -524,7 +501,7 @@ mod tests {
let params = bookmark.params.s3_params().unwrap();
assert_eq!(params.profile.as_deref().unwrap(), "test");
assert_eq!(params.bucket_name.as_str(), "omar");
assert_eq!(params.region.as_str(), "eu-west-1");
assert_eq!(params.region.as_deref().unwrap(), "eu-west-1");
// secrets
assert_eq!(params.access_key, None);
assert_eq!(params.secret_access_key, None);
@@ -546,7 +523,7 @@ mod tests {
let params = bookmark.params.s3_params().unwrap();
assert_eq!(params.profile.as_deref().unwrap(), "test");
assert_eq!(params.bucket_name.as_str(), "omar");
assert_eq!(params.region.as_str(), "eu-west-1");
assert_eq!(params.region.as_deref().unwrap(), "eu-west-1");
// secrets
assert_eq!(params.access_key, None);
assert_eq!(params.secret_access_key, None);
@@ -849,7 +826,9 @@ mod tests {
FileTransferParams::new(
FileTransferProtocol::AwsS3,
ProtocolParams::AwsS3(
AwsS3Params::new("omar", "eu-west-1", Some("test"))
AwsS3Params::new("omar", Some("eu-west-1"), Some("test"))
.endpoint(Some("http://localhost:9000"))
.new_path_style(false)
.access_key(Some("pippo"))
.secret_access_key(Some("pluto"))
.security_token(Some("omar"))

View File

@@ -2,29 +2,6 @@
//!
//! `config_client` is the module which provides an API between the Config module and the system
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Locals
use crate::config::{
params::{UserConfig, DEFAULT_NOTIFICATION_TRANSFER_THRESHOLD},
@@ -272,7 +249,7 @@ impl ConfigClient {
// Get key path
let ssh_key_path: PathBuf = {
let mut p: PathBuf = self.ssh_key_dir.clone();
p.push(format!("{}.key", host_name));
p.push(format!("{host_name}.key"));
p
};
info!(
@@ -413,7 +390,7 @@ impl ConfigClient {
/// Hosts are saved as `username@host` into configuration.
/// This method creates the key name, starting from host and username
fn make_ssh_host_key(host: &str, username: &str) -> String {
format!("{}@{}", username, host)
format!("{username}@{host}")
}
/// Get ssh tokens starting from ssh host key
@@ -421,7 +398,7 @@ impl ConfigClient {
/// Returns: (host, username)
fn get_ssh_tokens(host_key: &str) -> (String, String) {
let tokens: Vec<&str> = host_key.split('@').collect();
assert_eq!(tokens.len(), 2);
assert!(tokens.len() >= 2);
(String::from(tokens[1]), String::from(tokens[0]))
}
@@ -514,7 +491,7 @@ mod tests {
// Verify client has updated parameters
assert_eq!(client.get_default_protocol(), FileTransferProtocol::Scp);
assert_eq!(client.get_text_editor(), PathBuf::from("/usr/bin/vim"));
let mut expected_key_path: PathBuf = key_path.clone();
let mut expected_key_path: PathBuf = key_path;
expected_key_path.push("pi@192.168.1.31.key");
assert_eq!(
client.get_ssh_key("pi@192.168.1.31").unwrap().unwrap(),
@@ -674,7 +651,11 @@ mod tests {
let mut client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
.ok()
.unwrap();
assert_eq!(client.get_ssh_config(), None); // Null ?
let home_dir = dirs::home_dir().unwrap_or_else(|| PathBuf::from("/root"));
let mut ssh_config_path = "~/.ssh/config".to_string();
ssh_config_path = ssh_config_path.replacen('~', &home_dir.to_string_lossy(), 1);
assert_eq!(client.get_ssh_config(), Some(ssh_config_path.as_str())); // Null ?
client.set_ssh_config(Some(String::from("/tmp/ssh_config")));
assert_eq!(client.get_ssh_config(), Some("/tmp/ssh_config"));
client.set_ssh_config(None);

View File

@@ -2,29 +2,6 @@
//!
//! `environment` is the module which provides Path and values for the system environment
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Ext
use std::path::{Path, PathBuf};
@@ -149,7 +126,7 @@ mod tests {
#[serial]
fn test_system_environment_get_bookmarks_paths() {
assert_eq!(
get_bookmarks_paths(&Path::new("/home/omar/.config/termscp/")),
get_bookmarks_paths(Path::new("/home/omar/.config/termscp/")),
PathBuf::from("/home/omar/.config/termscp/bookmarks.toml"),
);
}
@@ -158,7 +135,7 @@ mod tests {
#[serial]
fn test_system_environment_get_config_paths() {
assert_eq!(
get_config_paths(&Path::new("/home/omar/.config/termscp/")),
get_config_paths(Path::new("/home/omar/.config/termscp/")),
(
PathBuf::from("/home/omar/.config/termscp/config.toml"),
PathBuf::from("/home/omar/.config/termscp/.ssh/")
@@ -170,7 +147,7 @@ mod tests {
#[serial]
fn test_system_environment_get_log_paths() {
assert_eq!(
get_log_paths(&Path::new("/home/omar/.config/termscp/")),
get_log_paths(Path::new("/home/omar/.config/termscp/")),
PathBuf::from("/home/omar/.config/termscp/termscp.log"),
);
}
@@ -179,7 +156,7 @@ mod tests {
#[serial]
fn test_system_environment_get_theme_path() {
assert_eq!(
get_theme_path(&Path::new("/home/omar/.config/termscp/")),
get_theme_path(Path::new("/home/omar/.config/termscp/")),
PathBuf::from("/home/omar/.config/termscp/theme.toml"),
);
}

View File

@@ -2,29 +2,6 @@
//!
//! `filestorage` provides an implementation of the `KeyStorage` trait using a file
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Local
use super::{KeyStorage, KeyStorageError};
// Ext
@@ -48,7 +25,7 @@ impl FileStorage {
/// Make file path for key file from `dir_path` and the application id
fn make_file_path(&self, storage_id: &str) -> PathBuf {
let mut p: PathBuf = self.dir_path.clone();
let file_name = format!(".{}.key", storage_id);
let file_name = format!(".{storage_id}.key");
p.push(file_name);
p
}
@@ -119,7 +96,7 @@ mod tests {
#[test]
fn test_system_keys_filestorage_make_dir() {
let storage: FileStorage = FileStorage::new(&Path::new("/tmp/"));
let storage: FileStorage = FileStorage::new(Path::new("/tmp/"));
assert_eq!(
storage.make_file_path("bookmarks").as_path(),
Path::new("/tmp/.bookmarks.key")

View File

@@ -2,29 +2,6 @@
//!
//! `keyringstorage` provides an implementation of the `KeyStorage` trait using the OS keyring
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Local
use super::{KeyStorage, KeyStorageError};
// Ext

View File

@@ -2,29 +2,6 @@
//!
//! `keystorage` provides the trait to manipulate to a KeyStorage
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Storages
pub mod filestorage;
#[cfg(feature = "with-keyring")]
@@ -33,7 +10,7 @@ pub mod keyringstorage;
use thiserror::Error;
/// defines the error type for the `KeyStorage`
#[derive(Debug, Error, PartialEq)]
#[derive(Debug, Error, PartialEq, Eq)]
pub enum KeyStorageError {
#[cfg(feature = "with-keyring")]
#[error("Key has a bad syntax")]

View File

@@ -2,29 +2,6 @@
//!
//! `logging` is the module which initializes the logging system for termscp
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// locals
use crate::system::environment::{get_log_paths, init_config_dir};
use crate::utils::file::open_file;
@@ -53,12 +30,9 @@ pub fn init(level: LogLevel) -> Result<(), String> {
let file: File = open_file(log_file_path.as_path(), true, true, false)
.map_err(|e| format!("Failed to open file {}: {}", log_file_path.display(), e))?;
// Prepare log config
let config = ConfigBuilder::new()
.set_time_format_str("%Y-%m-%dT%H:%M:%S%z")
.build();
let config = ConfigBuilder::new().set_time_format_rfc3339().build();
// Make logger
WriteLogger::init(level, config, file)
.map_err(|e| format!("Failed to initialize logger: {}", e))
WriteLogger::init(level, config, file).map_err(|e| format!("Failed to initialize logger: {e}"))
}
#[cfg(test)]

View File

@@ -2,29 +2,6 @@
//!
//! `system` is the module which contains functions and data types related to current system
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// modules
pub mod auto_update;
pub mod bookmarks_client;
@@ -35,3 +12,4 @@ pub mod logging;
pub mod notifications;
pub mod sshkey_storage;
pub mod theme_provider;
pub mod watcher;

View File

@@ -2,52 +2,26 @@
//!
//! `SshKeyStorage` is the module which behaves a storage for ssh keys
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Locals
use super::config_client::ConfigClient;
// Ext
use remotefs_ssh::SshKeyStorage as SshKeyStorageT;
use remotefs_ssh::SshKeyStorage as SshKeyStorageTrait;
use ssh2_config::SshConfig;
use std::collections::HashMap;
use std::path::{Path, PathBuf};
#[derive(Default)]
pub struct SshKeyStorage {
hosts: HashMap<String, PathBuf>, // Association between {user}@{host} and RSA key path
/// Association between {user}@{host} and RSA key path
hosts: HashMap<String, PathBuf>,
/// Ssh2 configuration
ssh_config: Option<SshConfig>,
}
impl SshKeyStorage {
/// Create an empty ssh key storage; used in case `ConfigClient` is not available
#[cfg(test)]
pub fn empty() -> Self {
SshKeyStorage {
hosts: HashMap::new(),
}
}
/// Make mapkey from host and username
fn make_mapkey(host: &str, username: &str) -> String {
format!("{}@{}", username, host)
format!("{username}@{host}")
}
#[cfg(test)]
@@ -57,21 +31,68 @@ impl SshKeyStorage {
let key: String = Self::make_mapkey(host, username);
self.hosts.insert(key, p);
}
}
impl SshKeyStorageT for SshKeyStorage {
fn resolve(&self, host: &str, username: &str) -> Option<&Path> {
/// Parse ssh2 config
fn parse_ssh2_config(path: &str) -> Result<SshConfig, String> {
use std::fs::File;
use std::io::BufReader;
let mut reader = File::open(path)
.map_err(|e| format!("failed to open {path}: {e}"))
.map(BufReader::new)?;
SshConfig::default()
.parse(&mut reader)
.map_err(|e| format!("Failed to parse ssh2 config: {e}"))
}
/// Resolve host via termscp ssh keys storage
fn resolve_host_in_termscp_storage(&self, host: &str, username: &str) -> Option<&Path> {
let key: String = Self::make_mapkey(host, username);
self.hosts.get(&key).map(|x| x.as_path())
}
/// Resolve host via ssh2 configuration
fn resolve_host_in_ssh2_configuration(&self, host: &str) -> Option<PathBuf> {
self.ssh_config.as_ref().and_then(|x| {
let key = x
.query(host)
.identity_file
.as_ref()
.and_then(|x| x.get(0).cloned());
key
})
}
}
impl SshKeyStorageTrait for SshKeyStorage {
fn resolve(&self, host: &str, username: &str) -> Option<PathBuf> {
// search in termscp keys
if let Some(path) = self.resolve_host_in_termscp_storage(host, username) {
return Some(path.to_path_buf());
}
debug!(
"couldn't find any ssh key associated to {} at {}. Trying with ssh2 config",
username, host
);
// otherwise search in configuration
let key = self.resolve_host_in_ssh2_configuration(host)?;
debug!("Found key in SSH config for {host}: {}", key.display());
Some(key)
}
}
impl From<&ConfigClient> for SshKeyStorage {
fn from(cfg_client: &ConfigClient) -> Self {
// read ssh2 config
let ssh_config = cfg_client.get_ssh_config().and_then(|x| {
debug!("reading ssh config at {}", x);
Self::parse_ssh2_config(x).ok()
});
let mut hosts: HashMap<String, PathBuf> =
HashMap::with_capacity(cfg_client.iter_ssh_keys().count());
debug!("Setting up SSH key storage");
// Iterate over keys
// Iterate over keys in storage
for key in cfg_client.iter_ssh_keys() {
match cfg_client.get_ssh_key(key) {
Ok(host) => match host {
@@ -89,7 +110,7 @@ impl From<&ConfigClient> for SshKeyStorage {
info!("Got SSH key for {}", key);
}
// Return storage
SshKeyStorage { hosts }
SshKeyStorage { hosts, ssh_config }
}
}
@@ -98,6 +119,7 @@ mod tests {
use super::*;
use crate::system::config_client::ConfigClient;
use crate::utils::test_helpers;
use pretty_assertions::assert_eq;
use std::path::Path;
@@ -116,7 +138,7 @@ mod tests {
// Create ssh key storage
let storage: SshKeyStorage = SshKeyStorage::from(&client);
// Verify key exists
let mut exp_key_path: PathBuf = key_path.clone();
let mut exp_key_path: PathBuf = key_path;
exp_key_path.push("pi@192.168.1.31.key");
assert_eq!(
*storage.resolve("192.168.1.31", "pi").unwrap(),
@@ -126,15 +148,44 @@ mod tests {
assert!(storage.resolve("deskichup", "veeso").is_none());
}
#[test]
fn sould_resolve_key_from_ssh2_config() {
let rsa_key = test_helpers::create_sample_file_with_content("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDErJhQxEI0+VvhlXVUyh+vMCm7aXfCA/g633AG8ezD/5EylwchtAr2JCoBWnxn4zV8nI9dMqOgm0jO4IsXpKOjQojv+0VOH7I+cDlBg0tk4hFlvyyS6YviDAfDDln3jYUM+5QNDfQLaZlH2WvcJ3mkDxLVlI9MBX1BAeSmChLxwAvxALp2ncImNQLzDO9eHcig3dtMrEKkzXQowRW5Y7eUzg2+vvVq4H2DOjWwUndvB5sJkhEfTUVE7ID8ZdGJo60kUb/02dZYj+IbkAnMCsqktk0cg/4XFX82hEfRYFeb1arkysFisPU1DOb6QielL/axeTebVplaouYcXY0pFdJt root@8c50fd4c345a");
let ssh_config_file = test_helpers::create_sample_file_with_content(format!(
r#"
Host test
HostName 127.0.0.1
Port 2222
User test
IdentityFile {}
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
"#,
rsa_key.path().display()
));
// make storage
let tmp_dir: tempfile::TempDir = tempfile::TempDir::new().ok().unwrap();
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
let mut client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
.ok()
.unwrap();
client.set_ssh_config(Some(ssh_config_file.path().to_string_lossy().to_string()));
let storage: SshKeyStorage = SshKeyStorage::from(&client);
assert_eq!(
storage.resolve("test", "pi").unwrap().as_path(),
rsa_key.path()
);
}
#[test]
fn test_system_sshkey_storage_empty() {
let storage: SshKeyStorage = SshKeyStorage::empty();
let storage: SshKeyStorage = SshKeyStorage::default();
assert_eq!(storage.hosts.len(), 0);
}
#[test]
fn test_system_sshkey_storage_add() {
let mut storage: SshKeyStorage = SshKeyStorage::empty();
let mut storage: SshKeyStorage = SshKeyStorage::default();
storage.add_key("deskichup", "veeso", PathBuf::from("/tmp/omar"));
assert_eq!(
*storage.resolve("deskichup", "veeso").unwrap(),

View File

@@ -2,29 +2,6 @@
//!
//! `theme_provider` is the module which provides an API between the theme configuration and the system
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Locals
use crate::config::{
serialization::{deserialize, serialize, SerializerError, SerializerErrorKind},

View File

@@ -0,0 +1,312 @@
//! ## File system change
//!
//! this module exposes the types to describe a change to sync on the remote file system
use crate::utils::path as path_utils;
use std::path::{Path, PathBuf};
/// Describes an operation on the remote file system to sync
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum FsChange {
/// Move file on remote
Move(FileToRename),
/// Remove file from remote
Remove(FileToRemove),
/// Upload file to remote
Update(FileUpdate),
}
impl FsChange {
/// Instantiate a new `FsChange::Move`
pub fn mov(
source: PathBuf,
destination: PathBuf,
local_watched_path: &Path,
remote_synched_path: &Path,
) -> Self {
Self::Move(FileToRename::new(
source,
destination,
local_watched_path,
remote_synched_path,
))
}
/// Instantiate a new `FsChange::Remove`
pub fn remove(
removed_path: PathBuf,
local_watched_path: &Path,
remote_synched_path: &Path,
) -> Self {
Self::Remove(FileToRemove::new(
removed_path,
local_watched_path,
remote_synched_path,
))
}
/// Instantiate a new `FsChange::Update`
pub fn update(
changed_path: PathBuf,
local_watched_path: &Path,
remote_synched_path: &Path,
) -> Self {
Self::Update(FileUpdate::new(
changed_path,
local_watched_path,
remote_synched_path,
))
}
}
/// Describes a file to rename on the remote fs
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct FileToRename {
/// Path to file which has to be renamed
source: PathBuf,
/// new filename
destination: PathBuf,
}
impl FileToRename {
/// Instantiate a new `FileToRename` given
///
/// - the path of the source on local fs
/// - the path of the destination on local fs
/// - the path of the file/directory watched on the local fs
/// - the path of the remote file/directory synched with the local fs
///
/// the `remote` is resolved pushing to `remote_synched_path` the diff between `changed_path` and `local_watched_path`
fn new(
source: PathBuf,
destination: PathBuf,
local_watched_path: &Path,
remote_synched_path: &Path,
) -> Self {
Self {
source: remote_relative_path(&source, local_watched_path, remote_synched_path),
destination: remote_relative_path(
&destination,
local_watched_path,
remote_synched_path,
),
}
}
/// Get path to the source to rename
pub fn source(&self) -> &Path {
self.source.as_path()
}
/// Get path to the destination name
pub fn destination(&self) -> &Path {
self.destination.as_path()
}
}
/// Describes a file to remove on remote fs
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct FileToRemove {
/// Path to the file which has to be removed
path: PathBuf,
}
impl FileToRemove {
/// Instantiate a new `FileToRemove` given
///
/// - the path of the file which has been removed on localhost
/// - the path of the file/directory watched on the local fs
/// - the path of the remote file/directory synched with the local fs
///
/// the `remote` is resolved pushing to `remote_synched_path` the diff between `removed_path` and `local_watched_path`
fn new(removed_path: PathBuf, local_watched_path: &Path, remote_synched_path: &Path) -> Self {
Self {
path: remote_relative_path(&removed_path, local_watched_path, remote_synched_path),
}
}
/// Get path to the file to unlink
pub fn path(&self) -> &Path {
self.path.as_path()
}
}
/// Describes a file changed to sync
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct FileUpdate {
/// Path to file which has changed
local: PathBuf,
/// Path to remote file to update
remote: PathBuf,
}
impl FileUpdate {
/// Instantiate a new `FileUpdate` given
///
/// - the path of the file which has changed
/// - the path of the file/directory watched on the local fs
/// - the path of the remote file/directory synched with the local fs
///
/// the `remote` is resolved pushing to `remote_synched_path` the diff between `changed_path` and `local_watched_path`
fn new(changed_path: PathBuf, local_watched_path: &Path, remote_synched_path: &Path) -> Self {
Self {
remote: remote_relative_path(&changed_path, local_watched_path, remote_synched_path),
local: changed_path,
}
}
/// Get path to local file to sync
pub fn local(&self) -> &Path {
self.local.as_path()
}
/// Get path to remote file to sync
pub fn remote(&self) -> &Path {
self.remote.as_path()
}
}
// -- utils
/// Get remote relative path, given the local target, the path of the local watched path and the path of the remote synched directory/file
fn remote_relative_path(
target: &Path,
local_watched_path: &Path,
remote_synched_path: &Path,
) -> PathBuf {
let local_diff = path_utils::diff_paths(target, local_watched_path);
// get absolute path to remote file associated to local file
match local_diff {
None => remote_synched_path.to_path_buf(),
Some(p) => {
let mut remote = remote_synched_path.to_path_buf();
remote.push(p);
remote
}
}
}
#[cfg(test)]
mod test {
use super::*;
use pretty_assertions::assert_eq;
#[test]
fn should_get_remote_relative_path_from_subdir() {
assert_eq!(
remote_relative_path(
Path::new("/tmp/abc/test.txt"),
Path::new("/tmp"),
Path::new("/home/foo")
)
.as_path(),
Path::new("/home/foo/abc/test.txt")
);
}
#[test]
fn should_get_remote_relative_path_same_path() {
assert_eq!(
remote_relative_path(
Path::new("/tmp/abc/test.txt"),
Path::new("/tmp/abc/test.txt"),
Path::new("/home/foo/test.txt")
)
.as_path(),
Path::new("/home/foo/test.txt")
);
}
#[test]
fn should_make_fs_change_move_from_same_directory() {
let change = FsChange::mov(
PathBuf::from("/tmp/foo.txt"),
PathBuf::from("/tmp/bar.txt"),
Path::new("/tmp"),
Path::new("/home/foo"),
);
if let FsChange::Move(change) = change {
assert_eq!(change.source(), Path::new("/home/foo/foo.txt"));
assert_eq!(change.destination(), Path::new("/home/foo/bar.txt"));
} else {
panic!("not a Move");
}
}
#[test]
fn should_make_fs_change_move_from_subdirectory() {
let change = FsChange::mov(
PathBuf::from("/tmp/abc/foo.txt"),
PathBuf::from("/tmp/abc/bar.txt"),
Path::new("/tmp/abc"),
Path::new("/home/foo"),
);
if let FsChange::Move(change) = change {
assert_eq!(change.source(), Path::new("/home/foo/foo.txt"));
assert_eq!(change.destination(), Path::new("/home/foo/bar.txt"));
} else {
panic!("not a Move");
}
}
#[test]
fn should_make_fs_change_remove_from_same_directory() {
let change = FsChange::remove(
PathBuf::from("/tmp/bar.txt"),
Path::new("/tmp/bar.txt"),
Path::new("/home/foo/bar.txt"),
);
if let FsChange::Remove(change) = change {
assert_eq!(change.path(), Path::new("/home/foo/bar.txt"));
} else {
panic!("not a remove");
}
}
#[test]
fn should_make_fs_change_remove_from_subdirectory() {
let change = FsChange::remove(
PathBuf::from("/tmp/abc/bar.txt"),
Path::new("/tmp/abc"),
Path::new("/home/foo"),
);
if let FsChange::Remove(change) = change {
assert_eq!(change.path(), Path::new("/home/foo/bar.txt"));
} else {
panic!("not a remove");
}
}
#[test]
fn should_make_fs_change_update_from_same_directory() {
let change = FsChange::update(
PathBuf::from("/tmp/bar.txt"),
Path::new("/tmp/bar.txt"),
Path::new("/home/foo/bar.txt"),
);
if let FsChange::Update(change) = change {
assert_eq!(change.local(), Path::new("/tmp/bar.txt"),);
assert_eq!(change.remote(), Path::new("/home/foo/bar.txt"));
} else {
panic!("not an update");
}
}
#[test]
fn should_make_fs_change_update_from_subdirectory() {
let change = FsChange::update(
PathBuf::from("/tmp/abc/foo.txt"),
Path::new("/tmp"),
Path::new("/home/foo/temp"),
);
if let FsChange::Update(change) = change {
assert_eq!(change.local(), Path::new("/tmp/abc/foo.txt"),);
assert_eq!(change.remote(), Path::new("/home/foo/temp/abc/foo.txt"));
} else {
panic!("not an update");
}
}
}

392
src/system/watcher/mod.rs Normal file
View File

@@ -0,0 +1,392 @@
//! ## File system watcher
//!
//! A watcher for file system paths, which reports changes on local fs
mod change;
// -- export
pub use change::FsChange;
use crate::utils::path as path_utils;
use notify::{
watcher, DebouncedEvent, Error as WatcherError, RecommendedWatcher, RecursiveMode, Watcher,
};
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError};
use std::time::Duration;
use thiserror::Error;
type FsWatcherResult<T> = Result<T, FsWatcherError>;
/// Describes an error returned by the `FsWatcher`
#[derive(Debug, Error)]
pub enum FsWatcherError {
#[error("unable to unwatch this path, since is not currently watched")]
PathNotWatched,
#[error("unable to watch path, since it's already watched")]
PathAlreadyWatched,
#[error("worker error: {0}")]
WorkerError(WatcherError),
}
impl From<WatcherError> for FsWatcherError {
fn from(err: WatcherError) -> Self {
Self::WorkerError(err)
}
}
/// File system watcher
pub struct FsWatcher {
paths: HashMap<PathBuf, PathBuf>,
receiver: Receiver<DebouncedEvent>,
watcher: RecommendedWatcher,
}
impl FsWatcher {
/// Initialize a new `FsWatcher`
pub fn init(delay: Duration) -> FsWatcherResult<Self> {
let (tx, receiver) = channel();
Ok(Self {
paths: HashMap::default(),
receiver,
watcher: watcher(tx, delay)?,
})
}
/// Poll searching for the first available disk change
pub fn poll(&self) -> FsWatcherResult<Option<FsChange>> {
match self.receiver.recv_timeout(Duration::from_millis(1)) {
Ok(DebouncedEvent::Rename(source, dest)) => Ok(self.build_fs_move(source, dest)),
Ok(DebouncedEvent::Remove(p)) => Ok(self.build_fs_remove(p)),
Ok(DebouncedEvent::Chmod(p) | DebouncedEvent::Create(p) | DebouncedEvent::Write(p)) => {
Ok(self.build_fs_update(p))
}
Ok(
DebouncedEvent::Rescan
| DebouncedEvent::NoticeRemove(_)
| DebouncedEvent::NoticeWrite(_),
) => Ok(None),
Ok(DebouncedEvent::Error(e, _)) => {
error!("FsWatcher reported error: {}", e);
Err(e.into())
}
Err(RecvTimeoutError::Timeout) => Ok(None),
Err(RecvTimeoutError::Disconnected) => panic!("File watcher died"),
}
}
/// Watch `local` path on localhost
pub fn watch(&mut self, local: &Path, remote: &Path) -> FsWatcherResult<()> {
// Start watcher if unwatched
if !self.watched(local) {
self.watcher.watch(local, RecursiveMode::Recursive)?;
// Insert new path to paths
self.paths.insert(local.to_path_buf(), remote.to_path_buf());
Ok(())
} else {
Err(FsWatcherError::PathAlreadyWatched)
}
}
/// Returns whether `path` is currently watched.
/// This method looks also in path ancestors.
///
/// Example:
/// if `/home` is watched, then if we call `watched("/home/foo/file.txt")` will return `true`
pub fn watched(&self, path: &Path) -> bool {
self.find_watched_path(path).is_some()
}
/// Returns the list of watched paths
pub fn watched_paths(&self) -> Vec<&Path> {
Vec::from_iter(self.paths.keys().map(|x| x.as_path()))
}
/// Unwatch provided path.
/// When unwatching the path, it searches for the ancestor watched path if any.
/// Returns the unwatched resolved path
pub fn unwatch(&mut self, path: &Path) -> FsWatcherResult<PathBuf> {
let watched_path = self.find_watched_path(path).map(|x| x.0.to_path_buf());
if let Some(watched_path) = watched_path {
self.watcher.unwatch(watched_path.as_path())?;
self.paths.remove(watched_path.as_path());
Ok(watched_path)
} else {
Err(FsWatcherError::PathNotWatched)
}
}
/// Given a certain path, returns the path data associated to the path which
/// is ancestor of that path in the current watched path
fn find_watched_path(&self, p: &Path) -> Option<(&Path, &Path)> {
self.paths
.iter()
.find(|(k, _)| path_utils::is_child_of(p, k))
.map(|(k, v)| (k.as_path(), v.as_path()))
}
/// Build `FsChange` from path to local `changed_file`
fn build_fs_move(&self, source: PathBuf, destination: PathBuf) -> Option<FsChange> {
if let Some((watched_local, watched_remote)) = self.find_watched_path(&source) {
Some(FsChange::mov(
source,
destination,
watched_local,
watched_remote,
))
} else {
None
}
}
/// Build `FsChange` from path to local `changed_file`
fn build_fs_remove(&self, removed_path: PathBuf) -> Option<FsChange> {
if let Some((watched_local, watched_remote)) = self.find_watched_path(&removed_path) {
Some(FsChange::remove(
removed_path,
watched_local,
watched_remote,
))
} else {
None
}
}
/// Build `FsChange` from path to local `changed_file`
fn build_fs_update(&self, changed_file: PathBuf) -> Option<FsChange> {
if let Some((watched_local, watched_remote)) = self.find_watched_path(&changed_file) {
Some(FsChange::update(
changed_file,
watched_local,
watched_remote,
))
} else {
None
}
}
}
#[cfg(test)]
mod test {
use super::*;
#[cfg(target_os = "macos")]
use crate::utils::test_helpers;
use pretty_assertions::assert_eq;
use tempfile::TempDir;
#[test]
fn should_init_fswatcher() {
let watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
assert!(watcher.paths.is_empty());
}
#[test]
fn should_watch_path() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
let tempdir = TempDir::new().unwrap();
assert!(watcher
.watch(tempdir.path(), Path::new("/tmp/test"))
.is_ok());
// check if in paths
assert_eq!(
watcher.paths.get(tempdir.path()).unwrap(),
Path::new("/tmp/test")
);
// close tempdir
assert!(tempdir.close().is_ok());
}
#[test]
fn should_not_watch_path_if_subdir_of_watched_path() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
let tempdir = TempDir::new().unwrap();
assert!(watcher
.watch(tempdir.path(), Path::new("/tmp/test"))
.is_ok());
// watch subdir
let mut subdir = tempdir.path().to_path_buf();
subdir.push("abc/def");
// should return already watched
assert!(watcher
.watch(subdir.as_path(), Path::new("/tmp/test/abc/def"))
.is_err());
// close tempdir
assert!(tempdir.close().is_ok());
}
#[test]
fn should_unwatch_path() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
let tempdir = TempDir::new().unwrap();
assert!(watcher
.watch(tempdir.path(), Path::new("/tmp/test"))
.is_ok());
// unwatch
assert!(watcher.unwatch(tempdir.path()).is_ok());
assert!(watcher.paths.get(tempdir.path()).is_none());
// close tempdir
assert!(tempdir.close().is_ok());
}
#[test]
fn should_unwatch_path_when_subdir() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
let tempdir = TempDir::new().unwrap();
assert!(watcher
.watch(tempdir.path(), Path::new("/tmp/test"))
.is_ok());
// unwatch
let mut subdir = tempdir.path().to_path_buf();
subdir.push("abc/def");
assert_eq!(
watcher.unwatch(subdir.as_path()).unwrap().as_path(),
Path::new(tempdir.path())
);
assert!(watcher.paths.get(tempdir.path()).is_none());
// close tempdir
assert!(tempdir.close().is_ok());
}
#[test]
fn should_return_err_when_unwatching_unwatched_path() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
assert!(watcher.unwatch(Path::new("/tmp")).is_err());
}
#[test]
fn should_tell_whether_path_is_watched() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
let tempdir = TempDir::new().unwrap();
assert!(watcher
.watch(tempdir.path(), Path::new("/tmp/test"))
.is_ok());
assert_eq!(watcher.watched(tempdir.path()), true);
let mut subdir = tempdir.path().to_path_buf();
subdir.push("abc/def");
assert_eq!(watcher.watched(subdir.as_path()), true);
assert_eq!(watcher.watched(Path::new("/tmp")), false);
// close tempdir
assert!(tempdir.close().is_ok());
}
#[test]
#[cfg(target_os = "macos")]
fn should_poll_file_update() {
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
let tempdir = TempDir::new().unwrap();
let tempdir_path = PathBuf::from(format!("/private{}", tempdir.path().display()));
assert!(watcher
.watch(tempdir_path.as_path(), Path::new("/tmp/test"))
.is_ok());
// create file
let file_path = test_helpers::make_file_at(tempdir_path.as_path(), "test.txt").unwrap();
// wait
std::thread::sleep(Duration::from_millis(500));
// wait till update
loop {
let fs_change = watcher.poll().unwrap();
if let Some(FsChange::Update(_)) = fs_change {
break;
}
std::thread::sleep(Duration::from_millis(500));
}
assert!(std::fs::remove_file(file_path.as_path()).is_ok());
// close tempdir
assert!(tempdir.close().is_ok());
}
#[test]
#[cfg(target_os = "macos")]
fn should_poll_file_removed() {
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
let tempdir = TempDir::new().unwrap();
let tempdir_path = PathBuf::from(format!("/private{}", tempdir.path().display()));
assert!(watcher
.watch(tempdir_path.as_path(), Path::new("/tmp/test"))
.is_ok());
// create file
let file_path = test_helpers::make_file_at(tempdir_path.as_path(), "test.txt").unwrap();
std::thread::sleep(Duration::from_millis(500));
// wait
assert!(std::fs::remove_file(file_path.as_path()).is_ok());
// poll till remove
loop {
let fs_change = watcher.poll().unwrap();
if let Some(FsChange::Remove(remove)) = fs_change {
assert_eq!(remove.path(), Path::new("/tmp/test/test.txt"));
break;
}
std::thread::sleep(Duration::from_millis(500));
}
// close tempdir
assert!(tempdir.close().is_ok());
}
/*
#[test]
#[cfg(target_family = "unix")]
fn should_poll_file_moved() {
let mut watcher = FsWatcher::init(Duration::from_millis(100)).unwrap();
let tempdir = TempDir::new().unwrap();
let tempdir_path = PathBuf::from(format!("/private{}", tempdir.path().display()));
assert!(watcher
.watch(tempdir_path.as_path(), Path::new("/tmp/test"))
.is_ok());
// create file
let file_path = test_helpers::make_file_at(tempdir_path.as_path(), "test.txt").unwrap();
// wait
std::thread::sleep(Duration::from_millis(500));
// move file
let mut new_file_path = tempdir.path().to_path_buf();
new_file_path.push("new.txt");
assert!(std::fs::rename(file_path.as_path(), new_file_path.as_path()).is_ok());
std::thread::sleep(Duration::from_millis(500));
// wait till rename
loop {
let fs_change = watcher.poll().unwrap();
if let Some(FsChange::Move(mov)) = fs_change {
assert_eq!(mov.source(), Path::new("/tmp/test/test.txt"));
assert_eq!(mov.destination(), Path::new("/tmp/test/new.txt"));
break;
}
std::thread::sleep(Duration::from_millis(500));
}
// remove file
assert!(std::fs::remove_file(new_file_path.as_path()).is_ok());
// close tempdir
assert!(tempdir.close().is_ok());
}
*/
#[test]
#[cfg(target_os = "macos")]
fn should_poll_nothing() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
let tempdir = TempDir::new().unwrap();
assert!(watcher
.watch(tempdir.path(), Path::new("/tmp/test"))
.is_ok());
assert!(watcher.poll().ok().unwrap().is_none());
// close tempdir
assert!(tempdir.close().is_ok());
}
#[test]
#[cfg(target_os = "macos")]
fn should_get_watched_paths() {
let mut watcher = FsWatcher::init(Duration::from_secs(5)).unwrap();
assert!(watcher.watch(Path::new("/tmp"), Path::new("/tmp")).is_ok());
assert!(watcher
.watch(Path::new("/home"), Path::new("/home"))
.is_ok());
let mut watched_paths = watcher.watched_paths();
watched_paths.sort();
assert_eq!(watched_paths, vec![Path::new("/home"), Path::new("/tmp")]);
}
}

View File

@@ -2,46 +2,18 @@
//!
//! `auth_activity` is the module which implements the authentication activity
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Locals
use super::{AuthActivity, FileTransferParams};
use crate::filetransfer::params::{AwsS3Params, GenericProtocolParams, ProtocolParams};
use crate::system::bookmarks_client::BookmarksClient;
use crate::system::environment;
// Ext
use std::path::PathBuf;
impl AuthActivity {
/// Delete bookmark
pub(super) fn del_bookmark(&mut self, idx: usize) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_mut() {
let name = self.bookmarks_list.get(idx).cloned();
if let Some(bookmarks_cli) = self.bookmarks_client_mut() {
// Iterate over kyes
let name: Option<&String> = self.bookmarks_list.get(idx);
if let Some(name) = name {
bookmarks_cli.del_bookmark(name);
bookmarks_cli.del_bookmark(&name);
// Write bookmarks
self.write_bookmarks();
}
@@ -52,7 +24,7 @@ impl AuthActivity {
/// Load selected bookmark (at index) to input fields
pub(super) fn load_bookmark(&mut self, idx: usize) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
if let Some(bookmarks_cli) = self.bookmarks_client() {
// Iterate over bookmarks
if let Some(key) = self.bookmarks_list.get(idx) {
if let Some(bookmark) = bookmarks_cli.get_bookmark(key) {
@@ -72,7 +44,7 @@ impl AuthActivity {
return;
}
};
if let Some(bookmarks_cli) = self.bookmarks_client.as_mut() {
if let Some(bookmarks_cli) = self.bookmarks_client_mut() {
bookmarks_cli.add_bookmark(name.clone(), params, save_password);
// Save bookmarks
self.write_bookmarks();
@@ -85,10 +57,10 @@ impl AuthActivity {
}
/// Delete recent
pub(super) fn del_recent(&mut self, idx: usize) {
if let Some(client) = self.bookmarks_client.as_mut() {
let name: Option<&String> = self.recents_list.get(idx);
let name = self.recents_list.get(idx).cloned();
if let Some(client) = self.bookmarks_client_mut() {
if let Some(name) = name {
client.del_recent(name);
client.del_recent(&name);
// Write bookmarks
self.write_bookmarks();
}
@@ -99,7 +71,7 @@ impl AuthActivity {
/// Load selected recent (at index) to input fields
pub(super) fn load_recent(&mut self, idx: usize) {
if let Some(client) = self.bookmarks_client.as_ref() {
if let Some(client) = self.bookmarks_client() {
// Iterate over bookmarks
if let Some(key) = self.recents_list.get(idx) {
if let Some(bookmark) = client.get_recent(key) {
@@ -119,7 +91,7 @@ impl AuthActivity {
return;
}
};
if let Some(bookmarks_cli) = self.bookmarks_client.as_mut() {
if let Some(bookmarks_cli) = self.bookmarks_client_mut() {
bookmarks_cli.add_recent(params);
// Save bookmarks
self.write_bookmarks();
@@ -128,67 +100,31 @@ impl AuthActivity {
/// Write bookmarks to file
fn write_bookmarks(&mut self) {
if let Some(bookmarks_cli) = self.bookmarks_client.as_ref() {
if let Some(bookmarks_cli) = self.bookmarks_client() {
if let Err(err) = bookmarks_cli.write_bookmarks() {
self.mount_error(format!("Could not write bookmarks: {}", err).as_str());
self.mount_error(format!("Could not write bookmarks: {err}").as_str());
}
}
}
/// Initialize bookmarks client
pub(super) fn init_bookmarks_client(&mut self) {
// Get config dir
match environment::init_config_dir() {
Ok(path) => {
// If some configure client, otherwise do nothing; don't bother users telling them that bookmarks are not supported on their system.
if let Some(config_dir_path) = path {
let bookmarks_file: PathBuf =
environment::get_bookmarks_paths(config_dir_path.as_path());
// Initialize client
match BookmarksClient::new(
bookmarks_file.as_path(),
config_dir_path.as_path(),
16,
) {
Ok(cli) => {
// Load bookmarks into list
let mut bookmarks_list: Vec<String> =
Vec::with_capacity(cli.iter_bookmarks().count());
for bookmark in cli.iter_bookmarks() {
bookmarks_list.push(bookmark.clone());
}
// Load recents into list
let mut recents_list: Vec<String> =
Vec::with_capacity(cli.iter_recents().count());
for recent in cli.iter_recents() {
recents_list.push(recent.clone());
}
self.bookmarks_client = Some(cli);
self.bookmarks_list = bookmarks_list;
self.recents_list = recents_list;
// Sort bookmark list
self.sort_bookmarks();
self.sort_recents();
}
Err(err) => {
self.mount_error(
format!(
"Could not initialize bookmarks (at \"{}\", \"{}\"): {}",
bookmarks_file.display(),
config_dir_path.display(),
err
)
.as_str(),
);
}
}
}
if let Some(cli) = self.bookmarks_client_mut() {
// Load bookmarks into list
let mut bookmarks_list: Vec<String> = Vec::with_capacity(cli.iter_bookmarks().count());
for bookmark in cli.iter_bookmarks() {
bookmarks_list.push(bookmark.clone());
}
Err(err) => {
self.mount_error(
format!("Could not initialize configuration directory: {}", err).as_str(),
);
// Load recents into list
let mut recents_list: Vec<String> = Vec::with_capacity(cli.iter_recents().count());
for recent in cli.iter_recents() {
recents_list.push(recent.clone());
}
self.bookmarks_list = bookmarks_list;
self.recents_list = recents_list;
// Sort bookmark list
self.sort_bookmarks();
self.sort_recents();
}
}
@@ -212,6 +148,12 @@ impl AuthActivity {
// Load parameters into components
self.protocol = bookmark.protocol;
self.mount_protocol(bookmark.protocol);
self.mount_remote_directory(
bookmark
.entry_directory
.map(|x| x.to_string_lossy().to_string())
.unwrap_or_default(),
);
match bookmark.params {
ProtocolParams::AwsS3(params) => self.load_bookmark_s3_into_gui(params),
ProtocolParams::Generic(params) => self.load_bookmark_generic_into_gui(params),
@@ -227,11 +169,13 @@ impl AuthActivity {
fn load_bookmark_s3_into_gui(&mut self, params: AwsS3Params) {
self.mount_s3_bucket(params.bucket_name.as_str());
self.mount_s3_region(params.region.as_str());
self.mount_s3_region(params.region.as_deref().unwrap_or(""));
self.mount_s3_endpoint(params.endpoint.as_deref().unwrap_or(""));
self.mount_s3_profile(params.profile.as_deref().unwrap_or(""));
self.mount_s3_access_key(params.access_key.as_deref().unwrap_or(""));
self.mount_s3_secret_access_key(params.secret_access_key.as_deref().unwrap_or(""));
self.mount_s3_security_token(params.security_token.as_deref().unwrap_or(""));
self.mount_s3_session_token(params.session_token.as_deref().unwrap_or(""));
self.mount_s3_new_path_style(params.new_path_style);
}
}

View File

@@ -2,29 +2,6 @@
//!
//! auth activity bookmarks components
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::{FormMsg, Msg, UiMsg};
use tui_realm_stdlib::{Input, List, Radio};
@@ -246,6 +223,14 @@ impl Component<Msg, NoUserEvent> for DeleteBookmarkPopup {
self.perform(Cmd::Move(Direction::Right));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('y'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Form(FormMsg::DeleteBookmark)),
Event::Keyboard(KeyEvent {
code: Key::Char('n'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Ui(UiMsg::CloseDeleteBookmark)),
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => {
@@ -306,6 +291,14 @@ impl Component<Msg, NoUserEvent> for DeleteRecentPopup {
self.perform(Cmd::Move(Direction::Right));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('y'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Form(FormMsg::DeleteRecent)),
Event::Keyboard(KeyEvent {
code: Key::Char('n'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Ui(UiMsg::CloseDeleteRecent)),
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => {
@@ -447,7 +440,7 @@ impl Component<Msg, NoUserEvent> for BookmarkName {
}
Event::Keyboard(KeyEvent {
code: Key::Char(ch),
modifiers: KeyModifiers::NONE,
..
}) => {
self.perform(Cmd::Type(ch));
Some(Msg::None)

View File

@@ -2,29 +2,6 @@
//!
//! auth activity components for file transfer params form
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
use tui_realm_stdlib::{Input, Radio};
@@ -49,7 +26,7 @@ impl ProtocolRadio {
.color(color)
.modifiers(BorderType::Rounded),
)
.choices(&["SFTP", "SCP", "FTP", "FTPS", "AWS S3"])
.choices(&["SFTP", "SCP", "FTP", "FTPS", "S3"])
.foreground(color)
.rewind(true)
.title("Protocol", Alignment::Left)
@@ -112,6 +89,42 @@ impl Component<Msg, NoUserEvent> for ProtocolRadio {
}
}
// -- remote directory
#[derive(MockComponent)]
pub struct InputRemoteDirectory {
component: Input,
}
impl InputRemoteDirectory {
pub fn new(remote_dir: &str, color: Color) -> Self {
Self {
component: Input::default()
.borders(
Borders::default()
.color(color)
.modifiers(BorderType::Rounded),
)
.foreground(color)
.placeholder("/home/foo", Style::default().fg(Color::Rgb(128, 128, 128)))
.title("Default remote directory", Alignment::Left)
.input_type(InputType::Text)
.value(remote_dir),
}
}
}
impl Component<Msg, NoUserEvent> for InputRemoteDirectory {
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
handle_input_ev(
self,
ev,
Msg::Ui(UiMsg::RemoteDirectoryBlurDown),
Msg::Ui(UiMsg::RemoteDirectoryBlurUp),
)
}
}
// -- address
#[derive(MockComponent)]
@@ -328,6 +341,102 @@ impl Component<Msg, NoUserEvent> for InputS3Region {
}
}
// -- s3 endpoint
#[derive(MockComponent)]
pub struct InputS3Endpoint {
component: Input,
}
impl InputS3Endpoint {
pub fn new(endpoint: &str, color: Color) -> Self {
Self {
component: Input::default()
.borders(
Borders::default()
.color(color)
.modifiers(BorderType::Rounded),
)
.foreground(color)
.placeholder(
"http://localhost:9000",
Style::default().fg(Color::Rgb(128, 128, 128)),
)
.title("Endpoint", Alignment::Left)
.input_type(InputType::Text)
.value(endpoint),
}
}
}
impl Component<Msg, NoUserEvent> for InputS3Endpoint {
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
handle_input_ev(
self,
ev,
Msg::Ui(UiMsg::S3EndpointBlurDown),
Msg::Ui(UiMsg::S3EndpointBlurUp),
)
}
}
// -- s3 new path style
#[derive(MockComponent)]
pub struct RadioS3NewPathStyle {
component: Radio,
}
impl RadioS3NewPathStyle {
pub fn new(new_path_style: bool, color: Color) -> Self {
Self {
component: Radio::default()
.borders(
Borders::default()
.color(color)
.modifiers(BorderType::Rounded),
)
.choices(&["Yes", "No"])
.foreground(color)
.rewind(true)
.title("New path style", Alignment::Left)
.value(usize::from(!new_path_style)),
}
}
}
impl Component<Msg, NoUserEvent> for RadioS3NewPathStyle {
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
match ev {
Event::Keyboard(KeyEvent {
code: Key::Left, ..
}) => {
self.perform(Cmd::Move(Direction::Left));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Right, ..
}) => {
self.perform(Cmd::Move(Direction::Right));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => Some(Msg::Form(FormMsg::Connect)),
Event::Keyboard(KeyEvent {
code: Key::Down, ..
}) => Some(Msg::Ui(UiMsg::S3NewPathStyleBlurDown)),
Event::Keyboard(KeyEvent { code: Key::Up, .. }) => {
Some(Msg::Ui(UiMsg::S3NewPathStyleBlurUp))
}
Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => {
Some(Msg::Ui(UiMsg::ParamsFormBlur))
}
_ => None,
}
}
}
// -- s3 profile
#[derive(MockComponent)]
@@ -544,9 +653,14 @@ fn handle_input_ev(
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => Some(Msg::Form(FormMsg::Connect)),
Event::Keyboard(KeyEvent {
// NOTE: escaped control sequence
code: Key::Char('c') | Key::Char('h') | Key::Char('r') | Key::Char('s'),
modifiers: KeyModifiers::CONTROL,
}) => Some(Msg::None),
Event::Keyboard(KeyEvent {
code: Key::Char(ch),
modifiers: KeyModifiers::NONE | KeyModifiers::SHIFT,
..
}) => {
component.perform(Cmd::Type(ch));
Some(Msg::None)

View File

@@ -2,29 +2,6 @@
//!
//! auth activity components
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::{FileTransferProtocol, FormMsg, Msg, UiMsg};
mod bookmarks;
@@ -37,9 +14,9 @@ pub use bookmarks::{
RecentsList,
};
pub use form::{
InputAddress, InputPassword, InputPort, InputS3AccessKey, InputS3Bucket, InputS3Profile,
InputS3Region, InputS3SecretAccessKey, InputS3SecurityToken, InputS3SessionToken,
InputUsername, ProtocolRadio,
InputAddress, InputPassword, InputPort, InputRemoteDirectory, InputS3AccessKey, InputS3Bucket,
InputS3Endpoint, InputS3Profile, InputS3Region, InputS3SecretAccessKey, InputS3SecurityToken,
InputS3SessionToken, InputUsername, ProtocolRadio, RadioS3NewPathStyle,
};
pub use popup::{
ErrorPopup, InfoPopup, InstallUpdatePopup, Keybindings, QuitPopup, ReleaseNotes, WaitPopup,

View File

@@ -2,34 +2,11 @@
//!
//! auth activity popups
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::{FormMsg, Msg, UiMsg};
use tui_realm_stdlib::{List, Paragraph, Radio, Textarea};
use tuirealm::command::{Cmd, CmdResult, Direction, Position};
use tuirealm::event::{Key, KeyEvent};
use tuirealm::event::{Key, KeyEvent, KeyModifiers};
use tuirealm::props::{Alignment, BorderType, Borders, Color, TableBuilder, TextSpan};
use tuirealm::{Component, Event, MockComponent, NoUserEvent, State, StateValue};
@@ -209,6 +186,14 @@ impl Component<Msg, NoUserEvent> for QuitPopup {
self.perform(Cmd::Move(Direction::Right));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('y'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Form(FormMsg::Quit)),
Event::Keyboard(KeyEvent {
code: Key::Char('n'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Ui(UiMsg::CloseQuitPopup)),
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => {
@@ -268,6 +253,14 @@ impl Component<Msg, NoUserEvent> for InstallUpdatePopup {
self.perform(Cmd::Move(Direction::Right));
Some(Msg::None)
}
Event::Keyboard(KeyEvent {
code: Key::Char('y'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Form(FormMsg::InstallUpdate)),
Event::Keyboard(KeyEvent {
code: Key::Char('n'),
modifiers: KeyModifiers::NONE,
}) => Some(Msg::Ui(UiMsg::CloseInstallUpdatePopup)),
Event::Keyboard(KeyEvent {
code: Key::Enter, ..
}) => {

View File

@@ -2,29 +2,6 @@
//!
//! auth activity texts
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::Msg;
use tui_realm_stdlib::{Label, Span};

View File

@@ -2,29 +2,6 @@
//!
//! `auth_activity` is the module which implements the authentication activity
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
use super::{AuthActivity, FileTransferParams, FileTransferProtocol};
use crate::filetransfer::params::ProtocolParams;
use crate::system::auto_update::{Release, Update, UpdateStatus};
@@ -78,7 +55,7 @@ impl AuthActivity {
Ok(FileTransferParams {
protocol,
params: ProtocolParams::Generic(params),
entry_directory: None,
entry_directory: self.get_input_remote_directory(),
})
}
@@ -88,13 +65,10 @@ impl AuthActivity {
if params.bucket_name.is_empty() {
return Err("Invalid bucket");
}
if params.region.is_empty() {
return Err("Invalid region");
}
Ok(FileTransferParams {
protocol: FileTransferProtocol::AwsS3,
params: ProtocolParams::AwsS3(params),
entry_directory: None,
entry_directory: self.get_input_remote_directory(),
})
}
@@ -133,7 +107,7 @@ impl AuthActivity {
// Report error
error!("Failed to get latest version: {}", err);
self.mount_error(
format!("Could not check for new updates: {}", err).as_str(),
format!("Could not check for new updates: {err}").as_str(),
);
}
}
@@ -162,13 +136,13 @@ impl AuthActivity {
if self.config().get_notifications() {
Notification::update_installed(ver.as_str());
}
self.mount_info(format!("termscp has been updated to version {}!", ver))
self.mount_info(format!("termscp has been updated to version {ver}!"))
}
Err(err) => {
if self.config().get_notifications() {
Notification::update_failed(err.to_string());
}
self.mount_error(format!("Could not install update: {}", err))
self.mount_error(format!("Could not install update: {err}"))
}
}
}

View File

@@ -2,29 +2,6 @@
//!
//! `auth_activity` is the module which implements the authentication activity
/**
* MIT License
*
* termscp - Copyright (c) 2021 Christian Visintin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Sub modules
mod bookmarks;
mod components;
@@ -66,8 +43,11 @@ pub enum Id {
Protocol,
QuitPopup,
RecentsList,
RemoteDirectory,
S3AccessKey,
S3Bucket,
S3Endpoint,
S3NewPathStyle,
S3Profile,
S3Region,
S3SecretAccessKey,
@@ -80,14 +60,14 @@ pub enum Id {
WindowSizeError,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub enum Msg {
Form(FormMsg),
Ui(UiMsg),
None,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum FormMsg {
Connect,
DeleteBookmark,
@@ -101,7 +81,7 @@ pub enum FormMsg {
SaveBookmark,
}
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum UiMsg {
AddressBlurDown,
AddressBlurUp,
@@ -123,10 +103,16 @@ pub enum UiMsg {
ProtocolBlurDown,
ProtocolBlurUp,
RececentsListBlur,
RemoteDirectoryBlurDown,
RemoteDirectoryBlurUp,
S3AccessKeyBlurDown,
S3AccessKeyBlurUp,
S3BucketBlurDown,
S3BucketBlurUp,
S3EndpointBlurDown,
S3EndpointBlurUp,
S3NewPathStyleBlurDown,
S3NewPathStyleBlurUp,
S3ProfileBlurDown,
S3ProfileBlurUp,
S3RegionBlurDown,
@@ -166,7 +152,6 @@ const STORE_KEY_RELEASE_NOTES: &str = "AUTH_RELEASE_NOTES";
/// AuthActivity is the data holder for the authentication activity
pub struct AuthActivity {
app: Application<Id, Msg, NoUserEvent>,
bookmarks_client: Option<BookmarksClient>,
/// List of bookmarks
bookmarks_list: Vec<String>,
/// List of recent hosts
@@ -190,7 +175,6 @@ impl AuthActivity {
.poll_timeout(ticks),
),
context: None,
bookmarks_client: None,
bookmarks_list: Vec::new(),
exit_reason: None,
recents_list: Vec::new(),
@@ -214,6 +198,14 @@ impl AuthActivity {
self.context().config()
}
fn bookmarks_client(&self) -> Option<&BookmarksClient> {
self.context().bookmarks_client()
}
fn bookmarks_client_mut(&mut self) -> Option<&mut BookmarksClient> {
self.context_mut().bookmarks_client_mut()
}
/// Returns a reference to theme
fn theme(&self) -> &Theme {
self.context().theme_provider().theme()
@@ -253,9 +245,8 @@ impl Activity for AuthActivity {
// Initialize view
self.init();
// Init bookmarks client
if self.bookmarks_client.is_none() {
if self.bookmarks_client().is_some() {
self.init_bookmarks_client();
// View bookarmsk
self.view_bookmarks();
self.view_recent_connections();
}
@@ -284,7 +275,7 @@ impl Activity for AuthActivity {
}
}
Err(err) => {
self.mount_error(format!("Application error: {}", err));
self.mount_error(format!("Application error: {err}"));
}
}
// View

Some files were not shown because too many files have changed in this diff Show More