Compare commits
116 commits
Author | SHA1 | Date | |
---|---|---|---|
578fdb0c1b | |||
61903d6140 | |||
bc28d99f87 | |||
a0989bdc73 | |||
9b7577ce65 | |||
69081acc51 | |||
a10ebcd10c | |||
74fc62483b | |||
f2d49809ac | |||
7766698c68 | |||
0d34f49564 | |||
783116217d | |||
c8074ef4b6 | |||
29fbb2de67 | |||
|
15c4327c85 | ||
|
93d5806e49 | ||
f5caf49c92 | |||
5347a60057 | |||
934a86d5b7 | |||
2dc6b3343e | |||
7e7d922129 | |||
56fa241fe4 | |||
ecd9646f59 | |||
3ef64b6903 | |||
40aa548781 | |||
22aefed03a | |||
2a675aa9d5 | |||
bd3e770a0d | |||
ba9003a88c | |||
7c5f42916a | |||
a7b28c1bc9 | |||
8de978608d | |||
c72485f363 | |||
c02b5efdb2 | |||
df01da5ba1 | |||
1ebc3b4911 | |||
12728a4f17 | |||
e4ff6329ec | |||
ac3063c9d3 | |||
1c0e2a500a | |||
e13c0dcba2 | |||
8b97d67ba4 | |||
b3478e58b0 | |||
0351b5e214 | |||
c15d53ce35 | |||
f149e5f8f5 | |||
86faa0659a | |||
fd4f13e4a7 | |||
7dc768776e | |||
b8f5a83af5 | |||
b3933dd478 | |||
7a182731d3 | |||
47114cd91d | |||
74865e30d5 | |||
aa35f1bbe8 | |||
761831460f | |||
49a1782b11 | |||
08890a7ece | |||
cb7e4e85dc | |||
7afef789fc | |||
0b75ce13ba | |||
90b8cd023b | |||
8a4d8b4e94 | |||
a09c2198d9 | |||
fe13a3a4ca | |||
d019906d6d | |||
a159a2b84b | |||
3c34497229 | |||
ea3316b270 | |||
3bb3bec5d3 | |||
e63fefe182 | |||
b75a385e70 | |||
3522d0ffa7 | |||
02e3a8fd86 | |||
84accf9a2d | |||
921b959f14 | |||
5b1f0ec982 | |||
d612646d23 | |||
69f1200cad | |||
f1d8526baa | |||
83ff73e793 | |||
7538883511 | |||
b8f1284cdc | |||
841eb76210 | |||
620309d64a | |||
5d3759d2f0 | |||
504097f1c8 | |||
eeb074117c | |||
071ace4f4a | |||
b6b782bd1d | |||
5c14ed53ac | |||
92ca9d8f72 | |||
d7fe8dde9e | |||
24785e44d6 | |||
7f943f241b | |||
8ff073fd8a | |||
a3570de65e | |||
b4295c14ca | |||
8aa7fe2129 | |||
300e558df2 | |||
d1816d5f8c | |||
94350c46f0 | |||
79670a6f9c | |||
97b8129002 | |||
fa40f2f932 | |||
d09443ac47 | |||
adb7042e35 | |||
629228d365 | |||
9e8ec4db3c | |||
775aa5add8 | |||
73eba2a0d6 | |||
28aa4a7716 | |||
b88ee3e6c6 | |||
eff8a851b4 | |||
9026b19219 | |||
0788d18642 |
9 changed files with 2383 additions and 174 deletions
16
COPYING
Normal file
16
COPYING
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
QFT: An application for Quick (and really reliable) Peer-To-Peer file transfer.
|
||||||
|
|
||||||
|
Copyright (C) 2022 Daniel H. / TudbuT
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
654
Cargo.lock
generated
654
Cargo.lock
generated
|
@ -2,6 +2,660 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "addr2line"
|
||||||
|
version = "0.20.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3"
|
||||||
|
dependencies = [
|
||||||
|
"gimli",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "adler"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "aho-corasick"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ansi_term"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atty"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "backtrace"
|
||||||
|
version = "0.3.68"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12"
|
||||||
|
dependencies = [
|
||||||
|
"addr2line",
|
||||||
|
"cc",
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"libc",
|
||||||
|
"miniz_oxide",
|
||||||
|
"object",
|
||||||
|
"rustc-demangle",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bindgen"
|
||||||
|
version = "0.54.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "66c0bb6167449588ff70803f4127f0684f9063097eca5016f37eb52b92c2cf36"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cexpr",
|
||||||
|
"cfg-if 0.1.10",
|
||||||
|
"clang-sys",
|
||||||
|
"clap",
|
||||||
|
"env_logger",
|
||||||
|
"lazy_static",
|
||||||
|
"lazycell",
|
||||||
|
"log",
|
||||||
|
"peeking_take_while",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"regex",
|
||||||
|
"rustc-hash",
|
||||||
|
"shlex",
|
||||||
|
"which",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cc"
|
||||||
|
version = "1.0.82"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cexpr"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
|
||||||
|
dependencies = [
|
||||||
|
"nom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "0.1.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clang-sys"
|
||||||
|
version = "0.29.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a"
|
||||||
|
dependencies = [
|
||||||
|
"glob",
|
||||||
|
"libc",
|
||||||
|
"libloading",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap"
|
||||||
|
version = "2.34.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||||
|
dependencies = [
|
||||||
|
"ansi_term",
|
||||||
|
"atty",
|
||||||
|
"bitflags",
|
||||||
|
"strsim",
|
||||||
|
"textwrap",
|
||||||
|
"unicode-width",
|
||||||
|
"vec_map",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "deranged"
|
||||||
|
version = "0.3.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "embed-resource"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e62abb876c07e4754fae5c14cafa77937841f01740637e17d78dc04352f32a5e"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"rustc_version",
|
||||||
|
"toml",
|
||||||
|
"vswhom",
|
||||||
|
"winreg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_logger"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
|
||||||
|
dependencies = [
|
||||||
|
"atty",
|
||||||
|
"humantime",
|
||||||
|
"log",
|
||||||
|
"regex",
|
||||||
|
"termcolor",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "failure"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
|
||||||
|
dependencies = [
|
||||||
|
"backtrace",
|
||||||
|
"failure_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "failure_derive"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"synstructure",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.2.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if 1.0.0",
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gimli"
|
||||||
|
version = "0.27.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glob"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.1.19"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humantime"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
|
||||||
|
dependencies = [
|
||||||
|
"quick-error",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iui"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "git+https://github.com/rust-native-ui/libui-rs#3496903ae9c4fd68731587dc11739da90a4f0e12"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"failure",
|
||||||
|
"libc",
|
||||||
|
"ui-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazycell"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.147"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libloading"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "log"
|
||||||
|
version = "0.4.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memchr"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.7.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
|
||||||
|
dependencies = [
|
||||||
|
"adler",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "5.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "object"
|
||||||
|
version = "0.31.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "peeking_take_while"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkg-config"
|
||||||
|
version = "0.3.27"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppv-lite86"
|
||||||
|
version = "0.2.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.66"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "qft"
|
name = "qft"
|
||||||
|
version = "0.5.6"
|
||||||
|
dependencies = [
|
||||||
|
"iui",
|
||||||
|
"rand",
|
||||||
|
"time",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick-error"
|
||||||
|
version = "1.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.33"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex"
|
||||||
|
version = "1.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-automata",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-automata"
|
||||||
|
version = "0.3.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"memchr",
|
||||||
|
"regex-syntax",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "regex-syntax"
|
||||||
|
version = "0.7.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-demangle"
|
||||||
|
version = "0.1.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-hash"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc_version"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
||||||
|
dependencies = [
|
||||||
|
"semver",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semver"
|
||||||
|
version = "1.0.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde"
|
||||||
|
version = "1.0.171"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "30e27d1e4fd7659406c492fd6cfaf2066ba8773de45ca75e855590f856dc34a9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shlex"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "strsim"
|
||||||
|
version = "0.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "1.0.109"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "synstructure"
|
||||||
|
version = "0.12.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"unicode-xid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "termcolor"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-width",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.3.26"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a79d09ac6b08c1ab3906a2f7cc2e81a0e27c7ae89c63812df75e52bef0751e07"
|
||||||
|
dependencies = [
|
||||||
|
"deranged",
|
||||||
|
"serde",
|
||||||
|
"time-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time-core"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "toml"
|
||||||
|
version = "0.5.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ui-sys"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "git+https://github.com/rust-native-ui/libui-rs#3496903ae9c4fd68731587dc11739da90a4f0e12"
|
||||||
|
dependencies = [
|
||||||
|
"bindgen",
|
||||||
|
"cc",
|
||||||
|
"embed-resource",
|
||||||
|
"libc",
|
||||||
|
"pkg-config",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-width"
|
||||||
|
version = "0.1.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-xid"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vec_map"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vswhom"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "be979b7f07507105799e854203b470ff7c78a1639e330a58f183b5fea574608b"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"vswhom-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vswhom-sys"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d3b17ae1f6c8a2b28506cd96d412eebf83b4a0ff2cbefeeb952f2f9dfa44ba18"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "which"
|
||||||
|
version = "3.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-util"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winreg"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
[package]
|
[package]
|
||||||
name = "qft"
|
name = "qft"
|
||||||
version = "0.1.1"
|
version = "0.5.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
iui = { git = "https://github.com/rust-native-ui/libui-rs", optional = true, version = "0.3" }
|
||||||
|
rand = { version = "0.8", optional = true }
|
||||||
|
time = "0.3"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
gui = [ "dep:iui", "dep:rand" ]
|
||||||
|
|
2
Cross.toml
Normal file
2
Cross.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[target.x86_64-apple-darwin]
|
||||||
|
image = "ghcr.io/cross-rs/x86_64-apple-darwin-cross:local"
|
674
LICENSE
Normal file
674
LICENSE
Normal file
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
158
README.md
Normal file
158
README.md
Normal file
|
@ -0,0 +1,158 @@
|
||||||
|
# qft
|
||||||
|
|
||||||
|
QFT is a small application for Quick (and really reliable) Peer-To-Peer UDP file transfer.
|
||||||
|
|
||||||
|
## If a friend sent you here...
|
||||||
|
|
||||||
|
...look at the "Releases" section on the sidebar. You should see a link titled vX.Y.Z. Click on
|
||||||
|
that, and then choose the right file for your OS: `qft` for Linux, `qft-mac` for Mac, and `qft.exe`
|
||||||
|
for Windows. Download this file, make it executable in case of Linux or Mac, and then follow your
|
||||||
|
friend's instructions on how to receive the file they wanted to send you.
|
||||||
|
|
||||||
|
## Usage:
|
||||||
|
- Find a public QFT helper (for example tudbut.de:4277)
|
||||||
|
- On the sender PC, enter `qft sender <helper> <shared-phrase> <filename>`.
|
||||||
|
- On the receiver PC, enter `qft receiver <helper> <shared-phrase> <filename>`.
|
||||||
|
- Both PCs should start transferring after a short while. If they don't, try again.
|
||||||
|
|
||||||
|
OR
|
||||||
|
- On both PCs, enter `qft gui`.
|
||||||
|
- Select mode
|
||||||
|
- Select file to send and file to save to
|
||||||
|
- Update the shared phrases and bitrate to match
|
||||||
|
- Click start
|
||||||
|
|
||||||
|
### Arguments:
|
||||||
|
```
|
||||||
|
qft helper <bind-port>
|
||||||
|
qft sender <helper-address>:<helper-port> <phrase> <filename> [send-delay] [bitrate] [skip]
|
||||||
|
qft receiver <helper-address>:<helper-port> <phrase> <filename> [bitrate] [skip]
|
||||||
|
```
|
||||||
|
|
||||||
|
## What helpers do
|
||||||
|
|
||||||
|
Helpers are NOT relays for data, they are only used to ESTABLISH the connection.
|
||||||
|
|
||||||
|
Helpers are there to help with holepunching.
|
||||||
|
- P1 connects\* to helper
|
||||||
|
- P1 sends the phrase to the helper
|
||||||
|
- P1 waits for a response
|
||||||
|
- Some time passes
|
||||||
|
- P2 connects\* to the same helper
|
||||||
|
- P2 sends the phrase to the helper
|
||||||
|
- P2 gets P1's public IP and port
|
||||||
|
- P1 gets P2's public IP and port
|
||||||
|
- P1 and P2 disconnect\* from the helper
|
||||||
|
- P1 and P2 start a loop (slightly simplified):
|
||||||
|
- fire a packet at eachother multiple times
|
||||||
|
- try to receive as many packets from the other one
|
||||||
|
- if none are received, loop again
|
||||||
|
- if one is received, exit the loop
|
||||||
|
- Connection between P1 and P2 is established.
|
||||||
|
|
||||||
|
\*UDP is a connection-less protocol, there are no handshakes. The word "connection" is used here as
|
||||||
|
an indicator that data will be exchanged between the "connected" parties. The word "disconnect" is used
|
||||||
|
here as an indicator that no more data will be exchanged between the "previously connected" parties.
|
||||||
|
|
||||||
|
## Debunking some myths about P2P networking
|
||||||
|
|
||||||
|
- "True P2P is only possible without a NAT" - [Both my experiments and wikipedia would like to have
|
||||||
|
a word about hole punching.](https://en.wikipedia.org/wiki/UDP_hole_punching) The only issue I
|
||||||
|
have found are *some* german mobile data providers, but sending large files over mobile data is
|
||||||
|
rarely something you'd want to do - and if so, use something like croc or the magic wormhole,
|
||||||
|
which aren't purely true P2P.
|
||||||
|
- "Croc is P2P as well, why does this exist?" - Croc is not Peer-to-Peer. Croc uses a relay server
|
||||||
|
to exchange data between the two clients (unless one of the client has a port-forward set up,
|
||||||
|
which is almost never the case). That is Client-to-Server-to-Client, which is *not* really
|
||||||
|
Peer-to-Peer. Peer-to-Peer means two clients sending their data directly to eachother, without a
|
||||||
|
server. "Peers make a portion of their resources, such as processing power, disk storage or
|
||||||
|
network bandwidth, directly available to other network participants, without the need for central
|
||||||
|
coordination by servers or stable hosts." -
|
||||||
|
[Wikipedia](https://en.wikipedia.org/wiki/Peer-to-peer)
|
||||||
|
|
||||||
|
## Tips 'n Tricks
|
||||||
|
- You can add a number to the end of both of your commands (after the filename) to
|
||||||
|
boost transfer speeds (lower = faster), but a too small number might cause unreliability
|
||||||
|
due to local network conditions, VPNs, etc (default is 500). This will modify the delay between
|
||||||
|
packets sent.
|
||||||
|
- You can also add a number *after that*. It will modify packet size, and a higher number here has
|
||||||
|
similar effects as a lower one in the previous arg.
|
||||||
|
- You can run a helper yourself, as the "helper" mode argument suggests. This helper should simply
|
||||||
|
be run on a server which is reachable from all over the web (a cheap VPS will definitely do).
|
||||||
|
- Helpers don't **have to** be run on a public server, they work in LAN too, but that way, only
|
||||||
|
computers in the same LAN will be able to use them.
|
||||||
|
- You can allow streaming (for example when you want to transmit from /dev/stdin) by setting
|
||||||
|
the `QFT_STREAM` environmental variable.
|
||||||
|
- To use qfts and qftr aliases on linux or mac, run (replacing `(shell)` with your shell name,
|
||||||
|
usually bash or zsh):
|
||||||
|
```sh
|
||||||
|
echo 'alias qftr="qft receiver tudbut.de:4277"' >> ~/.(shell)rc
|
||||||
|
echo 'alias qfts="qft sender tudbut.de:4277"' >> ~/.(shell)rc
|
||||||
|
source ~/.(shell)rc
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cool stuff
|
||||||
|
- Files are transferred over UDP, but qft has additional reliability measures in place to avoid
|
||||||
|
broken files.
|
||||||
|
- Unreliable internet connection? No problem! QFT will simply pause transmission until the
|
||||||
|
connection is back! Doesn't work? Check out the "Resume a fully stopped transfer" section!
|
||||||
|
- Did you know you can hibernate or suspend your computer while it's transferring and it'll continue
|
||||||
|
where it left of, even when only one side is suspended? (Unless your router blocked the port, read
|
||||||
|
the "Resume a fully stopped transfer" section in that case)
|
||||||
|
- QFT can withstand heavy ~~weather~~ network conditions: 1000ms ping is just as fast as 10ms ping,
|
||||||
|
packet loss/reorder rates of over 10% are tolerated (but can slow speeds down, especially when
|
||||||
|
ping is high).
|
||||||
|
- It's written in *100% pure Rust*.
|
||||||
|
|
||||||
|
## Resume a fully stopped transfer
|
||||||
|
You most likely won't need this unless the transfer completely died due to a VERY long pause or a
|
||||||
|
computer restart, but if you do:
|
||||||
|
|
||||||
|
Stop qft on both ends and start it again with the [skip] parameter in place (if you didn't specify a
|
||||||
|
bitrate before, the default is 256). It will skip those bytes and continue where you specified.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### It says `Connecting...` but doesn't connect
|
||||||
|
One of your ends didn't correctly connect to the helper. Stop the transfer on both ends
|
||||||
|
and try again.
|
||||||
|
|
||||||
|
## Croc
|
||||||
|
|
||||||
|
Many people have mentioned how this is like croc. It isn't, because croc uses a relay that all your
|
||||||
|
data is sent through. This is a bottleneck and also means that the relay admins are responsible for
|
||||||
|
the content that is sent. The relay also buffers a lot of data, meaning its RAM might fill up if the
|
||||||
|
sender's connection is much faster than the receiver's. Croc being tagged "peer-to-peer" is
|
||||||
|
misleading at best because it rarely uses the P2P capabilities (it requires a port-forward to do
|
||||||
|
P2P, which is rarely done). Read the previous section about P2P myths if you think Croc is always
|
||||||
|
peer-to-peer.
|
||||||
|
|
||||||
|
## [Relevant XKCD](https://xkcd.com/949)
|
||||||
|
|
||||||
|
![Relevant XKCD Image](https://imgs.xkcd.com/comics/file_transfer.png)
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
#### What is a helper?
|
||||||
|
|
||||||
|
As explained above, it is used to establish the connection between the two partners.
|
||||||
|
|
||||||
|
#### Why is a helper needed?
|
||||||
|
|
||||||
|
Your router uses a thing called **N**etwork **A**ddress **T**ranslation. It is required because
|
||||||
|
otherwise, there would be way too many IP addresses in use and the internet would cease to work
|
||||||
|
during busy times. This NAT is also a problem however, because it is a layer between your PC and the
|
||||||
|
open internet. When there is a new incoming connection, the NAT won't know which PC in your LAN to
|
||||||
|
forward the connection to, so the connection is simply rejected. Any Peer-to-Peer software therefore
|
||||||
|
needs a helper server (also called "STUN" server) which both peers will ask for the other's IP
|
||||||
|
address and port. Both peers can then send a bunch of outgoing connections to eachother. If
|
||||||
|
everything goes well, both peers have sent an outgoing with the right timing, causing both NATs to
|
||||||
|
*think* they are outgoing connections, when actually, they are a sort of combination of incoming and
|
||||||
|
outgoing ones.
|
||||||
|
|
||||||
|
TL;DR: P2P networking is impossible without a helper server, because of Routers. Port-forwarding
|
||||||
|
would be required otherwise, which can be hard to set up.
|
||||||
|
|
||||||
|
#### How to make a public/private helper?
|
||||||
|
|
||||||
|
Read the 2nd bullet point in the Tips 'n Tricks section.
|
BIN
logo.png
Normal file
BIN
logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 172 KiB |
351
src/gui.rs
Normal file
351
src/gui.rs
Normal file
|
@ -0,0 +1,351 @@
|
||||||
|
use std::{env, process, thread};
|
||||||
|
|
||||||
|
use iui::{controls::*, *};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct RefMut<T> {
|
||||||
|
to: *mut T,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> RefMut<T> {
|
||||||
|
pub fn new(to: &mut T) -> RefMut<T> {
|
||||||
|
RefMut { to: to as *mut T }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get(&self) -> &mut T {
|
||||||
|
unsafe { self.to.as_mut().unwrap() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl<T> Sync for RefMut<T> {}
|
||||||
|
|
||||||
|
unsafe impl<T> Send for RefMut<T> {}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
struct Ref<T> {
|
||||||
|
to: *const T,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> Ref<T> {
|
||||||
|
pub fn new(to: &T) -> Ref<T> {
|
||||||
|
Ref { to: to as *const T }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get(&self) -> &T {
|
||||||
|
unsafe { self.to.as_ref().unwrap() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe impl<T> Sync for Ref<T> {}
|
||||||
|
|
||||||
|
unsafe impl<T> Send for Ref<T> {}
|
||||||
|
|
||||||
|
fn wrap<T: Into<Control>>(ui: &UI, s: &str, c: T) -> Group {
|
||||||
|
let mut g = Group::new(ui, s);
|
||||||
|
g.set_child(ui, c);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn gui() -> Result<(), iui::UIError> {
|
||||||
|
let ui: UI = UI::init()?;
|
||||||
|
|
||||||
|
let mut window = Window::new(&ui, "QFT", 500, 600, WindowType::NoMenubar);
|
||||||
|
let mut vbox = VerticalBox::new(&ui);
|
||||||
|
vbox.set_padded(&ui, false);
|
||||||
|
|
||||||
|
let mut mode = Combobox::new(&ui);
|
||||||
|
let modeb = Ref::new(&mode);
|
||||||
|
mode.append(&ui, "Receive");
|
||||||
|
mode.append(&ui, "Send");
|
||||||
|
mode.set_selected(&ui, 1);
|
||||||
|
let mdb = Ref::new(&mode);
|
||||||
|
vbox.append(&ui, wrap(&ui, "Mode: ", mode), LayoutStrategy::Compact);
|
||||||
|
|
||||||
|
let mut helper_data = HorizontalBox::new(&ui);
|
||||||
|
helper_data.set_padded(&ui, true);
|
||||||
|
let mut helper = Entry::new(&ui);
|
||||||
|
let helperb = Ref::new(&helper);
|
||||||
|
helper.set_value(&ui, "tudbut.de:4277");
|
||||||
|
helper_data.append(&ui, helper, LayoutStrategy::Stretchy);
|
||||||
|
let mut phrase = Entry::new(&ui);
|
||||||
|
let phraseb = Ref::new(&phrase);
|
||||||
|
phrase.set_value(
|
||||||
|
&ui,
|
||||||
|
format!("my-cool-phrase-{}", rand::random::<u16>()).as_str(),
|
||||||
|
);
|
||||||
|
helper_data.append(&ui, phrase, LayoutStrategy::Stretchy);
|
||||||
|
vbox.append(
|
||||||
|
&ui,
|
||||||
|
wrap(&ui, "Shared Phrase: ", helper_data),
|
||||||
|
LayoutStrategy::Compact,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut path = env::current_exe()
|
||||||
|
.unwrap()
|
||||||
|
.into_os_string()
|
||||||
|
.into_string()
|
||||||
|
.unwrap();
|
||||||
|
let pathb = Ref::new(&path);
|
||||||
|
let mut select_path = Button::new(&ui, format!("Select a file ({})", path).as_str());
|
||||||
|
let bb = RefMut::new(&mut select_path);
|
||||||
|
let pb = RefMut::new(&mut path);
|
||||||
|
let wb = Ref::new(&window);
|
||||||
|
let uib = Ref::new(&ui);
|
||||||
|
select_path.on_clicked(&ui, move |_| {
|
||||||
|
let r = if mdb.get().selected(uib.get()) == 0 {
|
||||||
|
wb.get()
|
||||||
|
.save_file(uib.get())
|
||||||
|
.map(|x| x.into_os_string().into_string().unwrap())
|
||||||
|
} else {
|
||||||
|
wb.get()
|
||||||
|
.open_file(uib.get())
|
||||||
|
.map(|x| x.into_os_string().into_string().unwrap())
|
||||||
|
};
|
||||||
|
match r {
|
||||||
|
Some(path) => {
|
||||||
|
bb.get()
|
||||||
|
.set_text(uib.get(), format!("Select a file ({})", &path).as_str());
|
||||||
|
*pb.get() = path;
|
||||||
|
}
|
||||||
|
None => (),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
vbox.append(
|
||||||
|
&ui,
|
||||||
|
wrap(&ui, "Path: ", select_path),
|
||||||
|
LayoutStrategy::Compact,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut delay = VerticalBox::new(&ui);
|
||||||
|
let mut delay_slider = Slider::new(&ui, 100, 3_000);
|
||||||
|
let delayb = Ref::new(&delay_slider);
|
||||||
|
let mut delay_box = Entry::new(&ui);
|
||||||
|
delay_slider.set_value(&ui, 500);
|
||||||
|
delay_box.set_value(&ui, "500");
|
||||||
|
// We know that ui.main() will wait until the UI is dead, so these are safe.
|
||||||
|
let sb = RefMut::new(&mut delay_slider);
|
||||||
|
let bb = RefMut::new(&mut delay_box);
|
||||||
|
let uib = Ref::new(&ui);
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
delay_box.on_changed(&ui, move |val| {
|
||||||
|
sb.get().set_value(
|
||||||
|
uib.get(),
|
||||||
|
u16::from_str_radix(val.as_str(), 10).unwrap_or(256) as i32,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
delay_slider.on_changed(&ui, move |val| {
|
||||||
|
bb.get().set_value(uib1.get(), val.to_string().as_str());
|
||||||
|
});
|
||||||
|
delay.set_padded(&ui, true);
|
||||||
|
delay.append(&ui, delay_slider, LayoutStrategy::Compact);
|
||||||
|
delay.append(&ui, delay_box, LayoutStrategy::Compact);
|
||||||
|
vbox.append(
|
||||||
|
&ui,
|
||||||
|
wrap(
|
||||||
|
&ui,
|
||||||
|
"Delay in µs: (higher = more reliable, lower = faster)",
|
||||||
|
delay,
|
||||||
|
),
|
||||||
|
LayoutStrategy::Compact,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut speed = VerticalBox::new(&ui);
|
||||||
|
let mut speed_slider = Slider::new(&ui, 100, 3_000);
|
||||||
|
let speedb = Ref::new(&speed_slider);
|
||||||
|
let mut speed_box = Entry::new(&ui);
|
||||||
|
speed_slider.set_value(&ui, 256);
|
||||||
|
speed_box.set_value(&ui, "256");
|
||||||
|
// We know that ui.main() will wait until the UI is dead, so these are safe.
|
||||||
|
let sb = RefMut::new(&mut speed_slider);
|
||||||
|
let bb = RefMut::new(&mut speed_box);
|
||||||
|
let uib = Ref::new(&ui);
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
speed_box.on_changed(&ui, move |val| {
|
||||||
|
sb.get().set_value(
|
||||||
|
uib.get(),
|
||||||
|
u16::from_str_radix(val.as_str(), 10).unwrap_or(256) as i32,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
speed_slider.on_changed(&ui, move |val| {
|
||||||
|
bb.get().set_value(uib1.get(), val.to_string().as_str());
|
||||||
|
});
|
||||||
|
speed.set_padded(&ui, true);
|
||||||
|
speed.append(&ui, speed_slider, LayoutStrategy::Compact);
|
||||||
|
speed.append(&ui, speed_box, LayoutStrategy::Compact);
|
||||||
|
vbox.append(
|
||||||
|
&ui,
|
||||||
|
wrap(
|
||||||
|
&ui,
|
||||||
|
"Bitrate: (lower = more reliable, higher = faster)",
|
||||||
|
speed,
|
||||||
|
),
|
||||||
|
LayoutStrategy::Compact,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut skip = Entry::new(&ui);
|
||||||
|
let skipb = Ref::new(&skip);
|
||||||
|
skip.set_value(&ui, "0");
|
||||||
|
vbox.append(
|
||||||
|
&ui,
|
||||||
|
wrap(&ui, "Resume from: ", skip),
|
||||||
|
LayoutStrategy::Compact,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut bar = ProgressBar::new();
|
||||||
|
let barb = RefMut::new(&mut bar);
|
||||||
|
bar.set_value(&ui, ProgressBarValue::Determinate(0));
|
||||||
|
vbox.append(&ui, wrap(&ui, "Progress: ", bar), LayoutStrategy::Compact);
|
||||||
|
|
||||||
|
let mut send_button = Button::new(&ui, "Start");
|
||||||
|
let bb = RefMut::new(&mut send_button);
|
||||||
|
let uib = Ref::new(&ui);
|
||||||
|
send_button.on_clicked(&ui, move |b| {
|
||||||
|
b.disable(uib.get());
|
||||||
|
let bb = bb.clone();
|
||||||
|
let rargs = env::args().collect::<Vec<String>>();
|
||||||
|
let mut args = vec![rargs.get(0).unwrap().clone()];
|
||||||
|
let a = String::from(match modeb.get().selected(uib.get()) {
|
||||||
|
0 => "receiver",
|
||||||
|
1 => "sender",
|
||||||
|
_ => "version",
|
||||||
|
});
|
||||||
|
args.push(a);
|
||||||
|
let a = helperb.get().value(uib.get());
|
||||||
|
args.push(a);
|
||||||
|
let a = phraseb.get().value(uib.get());
|
||||||
|
args.push(a);
|
||||||
|
let a = pathb.get().clone();
|
||||||
|
args.push(a);
|
||||||
|
if modeb.get().selected(uib.get()) == 1 {
|
||||||
|
let a = delayb.get().value(uib.get()).to_string();
|
||||||
|
args.push(a);
|
||||||
|
}
|
||||||
|
let a = speedb.get().value(uib.get()).to_string();
|
||||||
|
args.push(a);
|
||||||
|
let a = skipb.get().value(uib.get());
|
||||||
|
args.push(a);
|
||||||
|
match modeb.get().selected(uib.get()) {
|
||||||
|
0 => {
|
||||||
|
barb.get()
|
||||||
|
.set_value(uib.get(), ProgressBarValue::Indeterminate);
|
||||||
|
let uib = uib.clone();
|
||||||
|
let barb = barb.clone();
|
||||||
|
|
||||||
|
thread::spawn(move || {
|
||||||
|
let mut last_percentage = -1;
|
||||||
|
let lpb = RefMut::new(&mut last_percentage);
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
let barb1 = barb.clone();
|
||||||
|
crate::receiver(&args, move |f| {
|
||||||
|
let lpb1 = lpb.clone();
|
||||||
|
let uib = uib1.clone();
|
||||||
|
let barb = barb1.clone();
|
||||||
|
uib1.get().queue_main(move || {
|
||||||
|
let percentage = (f * 100 as f32) as i32;
|
||||||
|
if percentage != *lpb1.get() {
|
||||||
|
barb.get().set_value(
|
||||||
|
uib.get(),
|
||||||
|
ProgressBarValue::Determinate(percentage as u32),
|
||||||
|
);
|
||||||
|
*lpb1.get() = percentage;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
let barb1 = barb.clone();
|
||||||
|
uib.get().queue_main(move || {
|
||||||
|
barb1
|
||||||
|
.get()
|
||||||
|
.set_value(uib1.get(), ProgressBarValue::Determinate(100));
|
||||||
|
bb.get().enable(uib1.get());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
1 => {
|
||||||
|
barb.get()
|
||||||
|
.set_value(uib.get(), ProgressBarValue::Indeterminate);
|
||||||
|
let uib = uib.clone();
|
||||||
|
let barb = barb.clone();
|
||||||
|
|
||||||
|
thread::spawn(move || {
|
||||||
|
let mut last_percentage = -1;
|
||||||
|
let lpb = RefMut::new(&mut last_percentage);
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
let barb1 = barb.clone();
|
||||||
|
crate::sender(&args, move |f| {
|
||||||
|
let lpb1 = lpb.clone();
|
||||||
|
let uib = uib1.clone();
|
||||||
|
let barb = barb1.clone();
|
||||||
|
uib1.get().queue_main(move || {
|
||||||
|
let percentage = (f * 100 as f32) as i32;
|
||||||
|
if percentage != *lpb1.get() {
|
||||||
|
barb.get().set_value(
|
||||||
|
uib.get(),
|
||||||
|
ProgressBarValue::Determinate(percentage as u32),
|
||||||
|
);
|
||||||
|
*lpb1.get() = percentage;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
let barb1 = barb.clone();
|
||||||
|
uib.get().queue_main(move || {
|
||||||
|
barb1
|
||||||
|
.get()
|
||||||
|
.set_value(uib1.get(), ProgressBarValue::Determinate(100));
|
||||||
|
bb.get().enable(uib1.get());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_ => panic!("invalid mode"),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
vbox.append(
|
||||||
|
&ui,
|
||||||
|
wrap(&ui, "Start: ", send_button),
|
||||||
|
LayoutStrategy::Compact,
|
||||||
|
);
|
||||||
|
|
||||||
|
let uib = Ref::new(&ui);
|
||||||
|
window.on_closing(&ui, move |_| {
|
||||||
|
let mut quit_window =
|
||||||
|
Window::new(uib.get(), "Really quit?", 300, 100, WindowType::NoMenubar);
|
||||||
|
let mut vbox = VerticalBox::new(uib.get());
|
||||||
|
|
||||||
|
let label = Label::new(uib.get(), "Do you really want to quit?");
|
||||||
|
vbox.append(uib.get(), label, LayoutStrategy::Compact);
|
||||||
|
|
||||||
|
vbox.append(uib.get(), Spacer::new(uib.get()), LayoutStrategy::Stretchy);
|
||||||
|
|
||||||
|
let mut hbox = HorizontalBox::new(uib.get());
|
||||||
|
hbox.set_padded(uib.get(), true);
|
||||||
|
let mut button1 = Button::new(uib.get(), "Quit");
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
button1.on_clicked(uib.get(), move |_| {
|
||||||
|
uib1.get().quit();
|
||||||
|
process::exit(0);
|
||||||
|
});
|
||||||
|
let mut button2 = Button::new(uib.get(), "Cancel");
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
// We know button2 won't be destroyed until quit_window is dead, so these are fine
|
||||||
|
let qwb = RefMut::new(&mut quit_window);
|
||||||
|
button2.on_clicked(uib.get(), move |_| quit_window.hide(uib1.get()));
|
||||||
|
let quit_window = qwb.get();
|
||||||
|
hbox.append(uib.get(), button1, LayoutStrategy::Stretchy);
|
||||||
|
hbox.append(uib.get(), button2, LayoutStrategy::Stretchy);
|
||||||
|
vbox.append(uib.get(), hbox, LayoutStrategy::Compact);
|
||||||
|
|
||||||
|
quit_window.set_child(uib.get(), vbox);
|
||||||
|
let uib1 = uib.clone();
|
||||||
|
quit_window.on_closing(uib.get(), move |w| w.hide(uib1.get()));
|
||||||
|
quit_window.show(uib.get());
|
||||||
|
});
|
||||||
|
|
||||||
|
window.set_child(&ui, vbox);
|
||||||
|
window.show(&ui);
|
||||||
|
|
||||||
|
ui.event_loop().run(&ui);
|
||||||
|
println!("GUI done");
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
694
src/main.rs
694
src/main.rs
|
@ -1,95 +1,69 @@
|
||||||
|
#[cfg(feature = "gui")]
|
||||||
|
mod gui;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
collections::HashMap,
|
||||||
io::{Error, Read, Write},
|
env,
|
||||||
|
fs::{File, OpenOptions},
|
||||||
|
io::{stdout, Error, Read, Seek, SeekFrom, Write},
|
||||||
net::*,
|
net::*,
|
||||||
time::Duration,
|
ops::Mul,
|
||||||
|
str::FromStr,
|
||||||
|
thread,
|
||||||
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
|
|
||||||
trait Ordinal {
|
use time::{Date, PrimitiveDateTime, Time};
|
||||||
fn ordinal(&self) -> isize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#[derive(Ord, Eq, PartialOrd, PartialEq)]
|
||||||
enum SafeReadWritePacket {
|
enum SafeReadWritePacket {
|
||||||
WRITE,
|
Write,
|
||||||
ACK,
|
Ack,
|
||||||
END,
|
ResendRequest,
|
||||||
}
|
End,
|
||||||
|
|
||||||
impl Ordinal for SafeReadWritePacket {
|
|
||||||
fn ordinal(&self) -> isize {
|
|
||||||
match self {
|
|
||||||
SafeReadWritePacket::WRITE => 0,
|
|
||||||
SafeReadWritePacket::ACK => 1,
|
|
||||||
SafeReadWritePacket::END => 2,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
use SafeReadWritePacket::*;
|
||||||
|
|
||||||
struct SafeReadWrite {
|
struct SafeReadWrite {
|
||||||
socket: UdpSocket,
|
socket: UdpSocket,
|
||||||
packet_count_out: u8,
|
last_transmitted: HashMap<u16, Vec<u8>>,
|
||||||
packet_count_in: u8,
|
packet_count_out: u64,
|
||||||
|
packet_count_in: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Wrap<T>(T);
|
||||||
|
|
||||||
|
impl Mul<Wrap<&str>> for u64 {
|
||||||
|
type Output = String;
|
||||||
|
|
||||||
|
fn mul(self, rhs: Wrap<&str>) -> Self::Output {
|
||||||
|
let strings: Vec<&str> = (0..self).map(|_| rhs.0).collect();
|
||||||
|
strings.join("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SafeReadWrite {
|
impl SafeReadWrite {
|
||||||
pub fn new(socket: UdpSocket) -> SafeReadWrite {
|
pub fn new(socket: UdpSocket) -> SafeReadWrite {
|
||||||
SafeReadWrite {
|
SafeReadWrite {
|
||||||
socket,
|
socket,
|
||||||
|
last_transmitted: HashMap::new(),
|
||||||
packet_count_in: 0,
|
packet_count_in: 0,
|
||||||
packet_count_out: 0,
|
packet_count_out: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_safe(&mut self, buf: &[u8]) -> Result<(), Error> {
|
pub fn write_safe(&mut self, buf: &[u8], delay: u64) -> Result<(), Error> {
|
||||||
if buf.len() > 0xfffd {
|
self.write_flush_safe(buf, false, delay)
|
||||||
panic!(
|
}
|
||||||
"too large data packet sent over SafeReadWrite ({} > 0xfffd)",
|
|
||||||
buf.len()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let id = self.packet_count_out;
|
pub fn write_flush_safe(&mut self, buf: &[u8], flush: bool, delay: u64) -> Result<(), Error> {
|
||||||
self.packet_count_out += 1;
|
self.internal_write_safe(buf, Write, flush, false, delay)
|
||||||
|
|
||||||
let mut buf = Vec::from(buf);
|
|
||||||
buf.insert(0, SafeReadWritePacket::WRITE.ordinal() as u8);
|
|
||||||
buf.insert(0, id);
|
|
||||||
let buf = buf.as_slice();
|
|
||||||
|
|
||||||
self.socket
|
|
||||||
.set_read_timeout(Some(Duration::from_secs(1)))
|
|
||||||
.expect("cannot set_read_timeout");
|
|
||||||
|
|
||||||
let mut resend = true;
|
|
||||||
while resend {
|
|
||||||
match self.socket.send(buf) {
|
|
||||||
Ok(x) => {
|
|
||||||
if x != buf.len() {
|
|
||||||
panic!("bad buf length")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(x) => return Err(x),
|
|
||||||
}
|
|
||||||
let mut buf = [0, 0];
|
|
||||||
match self.socket.recv(&mut buf).ok() {
|
|
||||||
Some(x) => {
|
|
||||||
if x == 0 {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if buf[1] == SafeReadWritePacket::ACK.ordinal() as u8 && buf[0] == id {
|
|
||||||
resend = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_safe(&mut self, buf: &[u8]) -> Result<(Vec<u8>, usize), Error> {
|
pub fn read_safe(&mut self, buf: &[u8]) -> Result<(Vec<u8>, usize), Error> {
|
||||||
if buf.len() > 0xfffd {
|
if buf.len() > 0xfffc {
|
||||||
panic!(
|
panic!(
|
||||||
"attempted to receive too large data packet with SafeReadWrite ({} > 0xfffd)",
|
"attempted to receive too large data packet with SafeReadWrite ({} > 0xfffc)",
|
||||||
buf.len()
|
buf.len()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -97,203 +71,577 @@ impl SafeReadWrite {
|
||||||
let mut mbuf = Vec::from(buf);
|
let mut mbuf = Vec::from(buf);
|
||||||
mbuf.insert(0, 0);
|
mbuf.insert(0, 0);
|
||||||
mbuf.insert(0, 0);
|
mbuf.insert(0, 0);
|
||||||
|
mbuf.insert(0, 0);
|
||||||
let buf: &mut [u8] = mbuf.as_mut();
|
let buf: &mut [u8] = mbuf.as_mut();
|
||||||
|
|
||||||
let mut r = (vec![], 0);
|
let mut r = (vec![], 0);
|
||||||
|
|
||||||
let mut try_again = true;
|
let mut try_again = true;
|
||||||
|
let mut is_catching_up = false;
|
||||||
while try_again {
|
while try_again {
|
||||||
match self.socket.recv(buf) {
|
match self.socket.recv(buf) {
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
if x == 0 {
|
if x < 3 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if buf[0] <= self.packet_count_in {
|
let id = u16::from_be_bytes([buf[0], buf[1]]);
|
||||||
|
if id <= self.packet_count_in as u16 {
|
||||||
self.socket
|
self.socket
|
||||||
.send(&[buf[0], SafeReadWritePacket::ACK.ordinal() as u8])
|
.send(&[buf[0], buf[1], Ack as u8])
|
||||||
.expect("send error");
|
.expect("send error");
|
||||||
}
|
}
|
||||||
if buf[0] == self.packet_count_in {
|
if id == self.packet_count_in as u16 {
|
||||||
|
if id == 0xffff {
|
||||||
|
println!("\nPacket ID wrap successful.");
|
||||||
|
}
|
||||||
try_again = false;
|
try_again = false;
|
||||||
self.packet_count_in += 1;
|
self.packet_count_in += 1;
|
||||||
r.1 = x - 2;
|
r.1 = x - 3;
|
||||||
|
} else if id > self.packet_count_in as u16
|
||||||
|
&& (id - self.packet_count_in as u16) < 0xC000
|
||||||
|
{
|
||||||
|
if !is_catching_up && !env::var("QFT_HIDE_DROPS").is_ok() {
|
||||||
|
println!(
|
||||||
|
"\r\x1b[KA packet dropped: {} (got) is newer than {} (expected)",
|
||||||
|
&id,
|
||||||
|
&(self.packet_count_in as u16)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
is_catching_up = true;
|
||||||
|
// ask to resend, then do nothing
|
||||||
|
let id = (self.packet_count_in as u16).to_be_bytes();
|
||||||
|
self.socket
|
||||||
|
.send(&[id[0], id[1], ResendRequest as u8])
|
||||||
|
.expect("send error");
|
||||||
}
|
}
|
||||||
if buf[0] > self.packet_count_in {
|
if buf[2] == End as u8 {
|
||||||
panic!("illegal packet id {} > {}", buf[0], self.packet_count_in);
|
|
||||||
}
|
|
||||||
if buf[1] == SafeReadWritePacket::END.ordinal() as u8 {
|
|
||||||
return Ok((vec![], 0));
|
return Ok((vec![], 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(x) => return Err(x),
|
Err(_) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mbuf.remove(0);
|
mbuf.remove(0);
|
||||||
mbuf.remove(0);
|
mbuf.remove(0);
|
||||||
|
mbuf.remove(0);
|
||||||
r.0 = mbuf;
|
r.0 = mbuf;
|
||||||
return Ok(r);
|
return Ok(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn end(mut self) -> UdpSocket {
|
pub fn end(mut self) -> UdpSocket {
|
||||||
let id = self.packet_count_out;
|
let _ = self.internal_write_safe(&mut [], End, true, true, 3000);
|
||||||
self.packet_count_out += 1;
|
|
||||||
|
|
||||||
let mut buf = vec![];
|
|
||||||
buf.insert(0, SafeReadWritePacket::END.ordinal() as u8);
|
|
||||||
buf.insert(0, id);
|
|
||||||
let buf = buf.as_slice();
|
|
||||||
|
|
||||||
self.socket
|
self.socket
|
||||||
.set_read_timeout(Some(Duration::from_secs(1)))
|
}
|
||||||
.expect("cannot set_read_timeout");
|
|
||||||
|
|
||||||
let mut resend = true;
|
fn internal_write_safe(
|
||||||
while resend {
|
&mut self,
|
||||||
|
buf: &[u8],
|
||||||
|
packet: SafeReadWritePacket,
|
||||||
|
flush: bool,
|
||||||
|
exit_on_lost: bool,
|
||||||
|
delay: u64,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
if buf.len() > 0xfffc {
|
||||||
|
panic!(
|
||||||
|
"too large data packet sent over SafeReadWrite ({} > 0xfffc)",
|
||||||
|
buf.len()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let id = (self.packet_count_out as u16).to_be_bytes();
|
||||||
|
let idn = self.packet_count_out as u16;
|
||||||
|
self.packet_count_out += 1;
|
||||||
|
|
||||||
|
let mut vbuf = Vec::from(buf);
|
||||||
|
vbuf.insert(0, packet as u8);
|
||||||
|
vbuf.insert(0, id[1]);
|
||||||
|
vbuf.insert(0, id[0]); // this is now the first byte
|
||||||
|
let buf = vbuf.as_slice();
|
||||||
|
|
||||||
|
loop {
|
||||||
match self.socket.send(buf) {
|
match self.socket.send(buf) {
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
if x != buf.len() {
|
if x != buf.len() {
|
||||||
panic!("internet down")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(_) => return self.socket,
|
|
||||||
}
|
|
||||||
let mut buf = [0, 0];
|
|
||||||
match self.socket.recv(&mut buf).ok() {
|
|
||||||
Some(x) => {
|
|
||||||
if x == 0 {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if buf[1] == SafeReadWritePacket::ACK.ordinal() as u8 && buf[0] == id {
|
}
|
||||||
resend = false;
|
Err(_) => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thread::sleep(Duration::from_micros(delay));
|
||||||
|
self.last_transmitted.insert(idn, vbuf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let mut buf = [0, 0, 0];
|
||||||
|
let mut wait = idn == 0xffff || flush;
|
||||||
|
if self.last_transmitted.len() < 256 {
|
||||||
|
self.socket
|
||||||
|
.set_read_timeout(Some(Duration::from_millis(1)))
|
||||||
|
.unwrap();
|
||||||
|
} else {
|
||||||
|
wait = true;
|
||||||
|
}
|
||||||
|
let mut start = unix_millis();
|
||||||
|
if idn == 0xffff {
|
||||||
|
print!("\nPacket ID needs to wrap. Waiting for partner to catch up...")
|
||||||
|
}
|
||||||
|
let mut is_catching_up = false;
|
||||||
|
loop {
|
||||||
|
match (
|
||||||
|
if !wait {
|
||||||
|
self.socket.set_nonblocking(true).unwrap()
|
||||||
|
} else {
|
||||||
|
()
|
||||||
|
},
|
||||||
|
self.socket.recv(&mut buf).ok(),
|
||||||
|
self.socket.set_nonblocking(false).unwrap(),
|
||||||
|
)
|
||||||
|
.1
|
||||||
|
{
|
||||||
|
Some(x) => {
|
||||||
|
if x != 3 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if buf[2] == Ack as u8 {
|
||||||
|
let n = u16::from_be_bytes([buf[0], buf[1]]);
|
||||||
|
self.last_transmitted.remove(&n);
|
||||||
|
if n == idn {
|
||||||
|
if idn == 0xffff {
|
||||||
|
println!("\r\x1b[KPacket ID wrap successful.");
|
||||||
|
}
|
||||||
|
wait = false;
|
||||||
|
self.last_transmitted.clear(); // if the latest packet is ACK'd, all
|
||||||
|
// previous ones must be as well.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if buf[2] == ResendRequest as u8 {
|
||||||
|
let mut n = u16::from_be_bytes([buf[0], buf[1]]);
|
||||||
|
thread::sleep(Duration::from_millis(100));
|
||||||
|
while let Some(_) = self.socket.recv(&mut buf).ok() {}
|
||||||
|
if !is_catching_up && !env::var("QFT_HIDE_DROPS").is_ok() {
|
||||||
|
println!("\r\x1b[KA packet dropped: {}", &n);
|
||||||
|
}
|
||||||
|
if !is_catching_up {
|
||||||
|
wait = true;
|
||||||
|
is_catching_up = true;
|
||||||
|
while n <= idn && !(idn == 0xffff && n == 0) {
|
||||||
|
let buf = self.last_transmitted.get(&n);
|
||||||
|
if let Some(buf) = buf {
|
||||||
|
loop {
|
||||||
|
// resend until success
|
||||||
|
match self.socket.send(&buf.as_slice()) {
|
||||||
|
Ok(x) => {
|
||||||
|
if x != buf.len() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread::sleep(Duration::from_millis(4));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// do NOT remove from last_transmitted yet, wait for Ack to do that.
|
||||||
|
n += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
if unix_millis() - start > 5000 && exit_on_lost {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if unix_millis() - start > 10000 {
|
||||||
|
println!("\n10s passed since last packet ==> Contact broke. Trying to resend packet...");
|
||||||
|
if let Some(buf) = self.last_transmitted.get(&idn) {
|
||||||
|
loop {
|
||||||
|
match self.socket.send(buf) {
|
||||||
|
Ok(x) => {
|
||||||
|
if x != buf.len() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thread::sleep(Duration::from_millis(4));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
start = unix_millis();
|
||||||
|
} else {
|
||||||
|
break; // Latest packet was already ACK'd ==> No packets properly lost ==> Can continue with next packet.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !wait {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.socket
|
self.socket
|
||||||
|
.set_read_timeout(Some(Duration::from_millis(1000)))
|
||||||
|
.unwrap();
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
if args.len() <= 1 {
|
if args.len() == 0 {
|
||||||
print_args(&args);
|
panic!("no args");
|
||||||
|
}
|
||||||
|
if args.len() == 1 {
|
||||||
|
#[cfg(feature = "gui")]
|
||||||
|
match gui::gui() {
|
||||||
|
Ok(_) => (),
|
||||||
|
Err(_) => print_args(&args),
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "gui"))]
|
||||||
|
print_args(&args)
|
||||||
}
|
}
|
||||||
match args
|
match args
|
||||||
.get(1)
|
.get(1)
|
||||||
.expect("no args supplied, check if the first arg is truly the program name")
|
.unwrap() // checked in previous if-statement
|
||||||
.as_str()
|
.as_str()
|
||||||
{
|
{
|
||||||
"helper" => helper(&args),
|
"helper" => helper(&args),
|
||||||
"sender" => sender(&args),
|
"sender" => sender(&args, |_| {}),
|
||||||
"receiver" => receiver(&args),
|
"receiver" => receiver(&args, |_| {}),
|
||||||
|
#[cfg(feature = "gui")]
|
||||||
|
"gui" => gui::gui().expect("can't use gui"),
|
||||||
|
#[cfg(not(feature = "gui"))]
|
||||||
|
"gui" => println!("Feature 'gui' was not enabled during compilation. GUI not available."),
|
||||||
|
"version" => println!("QFT version: {}", env!("CARGO_PKG_VERSION")),
|
||||||
_ => print_args(&args),
|
_ => print_args(&args),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn helper(args: &Vec<String>) {
|
pub fn helper(args: &Vec<String>) {
|
||||||
let bind_addr = (
|
let bind_addr = (
|
||||||
"0.0.0.0",
|
"0.0.0.0",
|
||||||
u16::from_str_radix(args[2].as_str(), 10).expect("invalid port: must be integer"),
|
u16::from_str_radix(args[2].as_str(), 10).expect("invalid port: must be integer"),
|
||||||
);
|
);
|
||||||
|
let mut map: HashMap<[u8; 200], SocketAddr> = HashMap::new();
|
||||||
let listener = UdpSocket::bind(&bind_addr).expect("unable to create socket");
|
let listener = UdpSocket::bind(&bind_addr).expect("unable to create socket");
|
||||||
let mut buf = [0 as u8];
|
let mut buf = [0 as u8; 200];
|
||||||
|
let mut last_log_time = unix_millis();
|
||||||
|
let mut amount_since_log = 0;
|
||||||
|
let mut helper_log = OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.write(true)
|
||||||
|
.append(true)
|
||||||
|
.open("qft_helper_log.txt")
|
||||||
|
.expect("unable to create helper log");
|
||||||
loop {
|
loop {
|
||||||
let (_, addr) = listener.recv_from(&mut buf).expect("read error");
|
let (l, addr) = listener.recv_from(&mut buf).expect("read error");
|
||||||
// we got a connection
|
if l != 200 {
|
||||||
if listener.send_to(&addr.port().to_be_bytes(), addr).is_ok() {
|
continue;
|
||||||
// success!
|
|
||||||
println!("Helped {}! :D", addr);
|
|
||||||
}
|
}
|
||||||
}
|
if map.contains_key(&buf) {
|
||||||
}
|
let other = map.get(&buf).unwrap();
|
||||||
|
// we got a connection
|
||||||
fn sender(args: &Vec<String>) {
|
let mut bytes: &[u8] = addr.to_string().bytes().collect::<Vec<u8>>().leak();
|
||||||
let mut bind_addr = ("0.0.0.0", 0);
|
let mut addr_buf = [0 as u8; 200];
|
||||||
{
|
for i in 0..bytes.len().min(200) {
|
||||||
let holepunch = UdpSocket::bind(&bind_addr).expect("unable to create socket");
|
addr_buf[i] = bytes[i];
|
||||||
let mut buf = [0 as u8; 2];
|
|
||||||
holepunch
|
|
||||||
.connect(args.get(2).unwrap_or_else(|| {
|
|
||||||
print_args(args);
|
|
||||||
panic!("unreachable")
|
|
||||||
}))
|
|
||||||
.expect("unable to connect to helper");
|
|
||||||
holepunch.send(&[0]).expect("unable to talk to helper");
|
|
||||||
holepunch
|
|
||||||
.recv(&mut buf)
|
|
||||||
.expect("unable to receive from helper");
|
|
||||||
// buf should now contain our port.
|
|
||||||
bind_addr = ("0.0.0.0", u16::from_be_bytes(buf));
|
|
||||||
println!("Holepunch successful. Running on port {}.", bind_addr.1);
|
|
||||||
}
|
|
||||||
// we have the needed bind_addr and did the holepunch
|
|
||||||
{
|
|
||||||
let connection = UdpSocket::bind(&bind_addr).expect("unable to create send socket");
|
|
||||||
let mut buf = [0 as u8; 256];
|
|
||||||
let mut file = File::open(args.get(3).unwrap_or_else(|| {
|
|
||||||
print_args(args);
|
|
||||||
panic!("unreachable")
|
|
||||||
}))
|
|
||||||
.expect("file not readable");
|
|
||||||
connection
|
|
||||||
.connect(connection.recv_from(&mut buf).expect("connect error").1)
|
|
||||||
.expect("connect error");
|
|
||||||
|
|
||||||
let mut sc = SafeReadWrite::new(connection);
|
|
||||||
loop {
|
|
||||||
let read = file.read(&mut buf).expect("file read error");
|
|
||||||
if read == 0 {
|
|
||||||
println!("Transfer done. Thank you!");
|
|
||||||
sc.end();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
bytes = other.to_string().bytes().collect::<Vec<u8>>().leak();
|
||||||
sc.write_safe(&buf[..read]).expect("send error");
|
let mut other_buf = [0 as u8; 200];
|
||||||
println!("Sent {} bytes", read);
|
for i in 0..bytes.len().min(200) {
|
||||||
|
other_buf[i] = bytes[i];
|
||||||
|
}
|
||||||
|
if listener.send_to(&addr_buf, other).is_ok()
|
||||||
|
&& listener.send_to(&other_buf, addr).is_ok()
|
||||||
|
{
|
||||||
|
// success!
|
||||||
|
println!("Helped {} and {}! :D", addr, other);
|
||||||
|
amount_since_log += 1;
|
||||||
|
if unix_millis() - last_log_time > 10000 {
|
||||||
|
let d = PrimitiveDateTime::new(
|
||||||
|
Date::from_calendar_date(1970, time::Month::January, 1).unwrap(),
|
||||||
|
Time::MIDNIGHT,
|
||||||
|
) + Duration::from_millis(unix_millis());
|
||||||
|
helper_log
|
||||||
|
.write(
|
||||||
|
format!(
|
||||||
|
"{} | {} {}>\n",
|
||||||
|
d,
|
||||||
|
amount_since_log,
|
||||||
|
amount_since_log * Wrap("=")
|
||||||
|
)
|
||||||
|
.as_bytes(),
|
||||||
|
)
|
||||||
|
.expect("error writing to log");
|
||||||
|
helper_log.flush().expect("error writing to log");
|
||||||
|
last_log_time = unix_millis();
|
||||||
|
amount_since_log = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.remove(&buf);
|
||||||
|
} else {
|
||||||
|
map.insert(buf, addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn receiver(args: &Vec<String>) {
|
pub fn sender<F: Fn(f32)>(args: &Vec<String>, on_progress: F) {
|
||||||
let connection = UdpSocket::bind(("0.0.0.0", 0)).expect("unable to create receive socket");
|
let connection = holepunch(args);
|
||||||
let mut buf: &[u8] = &[0 as u8; 256];
|
let dly = args
|
||||||
let mut file = File::create(args.get(3).unwrap_or_else(|| {
|
.get(5)
|
||||||
|
.map(|s| u64::from_str_radix(s, 10))
|
||||||
|
.unwrap_or(Ok(500))
|
||||||
|
.expect("bad delay operand");
|
||||||
|
let br = args
|
||||||
|
.get(6)
|
||||||
|
.map(|s| u32::from_str_radix(s, 10))
|
||||||
|
.unwrap_or(Ok(256))
|
||||||
|
.expect("bad bitrate argument");
|
||||||
|
let begin = args
|
||||||
|
.get(7)
|
||||||
|
.map(|s| u64::from_str_radix(s, 10))
|
||||||
|
.unwrap_or(Ok(0))
|
||||||
|
.expect("bad begin operand");
|
||||||
|
let mut buf: Vec<u8> = Vec::new();
|
||||||
|
buf.resize(br as usize, 0);
|
||||||
|
let mut buf = buf.leak();
|
||||||
|
let mut file = File::open(args.get(4).unwrap_or_else(|| {
|
||||||
print_args(args);
|
print_args(args);
|
||||||
panic!("unreachable")
|
panic!("unreachable")
|
||||||
}))
|
}))
|
||||||
.expect("file not writable");
|
.expect("file not readable");
|
||||||
connection
|
|
||||||
.connect(args.get(2).unwrap_or_else(|| {
|
if begin != 0 {
|
||||||
|
println!("Skipping to {}...", begin);
|
||||||
|
file.seek(SeekFrom::Start(begin)).expect("unable to skip");
|
||||||
|
println!("Done.");
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut sc = SafeReadWrite::new(connection);
|
||||||
|
let mut bytes_sent: u64 = 0;
|
||||||
|
let mut last_update = unix_millis();
|
||||||
|
let len = file.metadata().expect("bad metadata").len();
|
||||||
|
sc.write_safe(&len.to_be_bytes(), 3000)
|
||||||
|
.expect("unable to send file length");
|
||||||
|
println!("Length: {}", &len);
|
||||||
|
let mut time = unix_millis();
|
||||||
|
loop {
|
||||||
|
let read = file.read(&mut buf).expect("file read error");
|
||||||
|
if read == 0 && !env::var("QFT_STREAM").is_ok() {
|
||||||
|
println!();
|
||||||
|
println!("Transfer done. Thank you!");
|
||||||
|
sc.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sc.write_safe(&buf[..read], dly).expect("send error");
|
||||||
|
bytes_sent += read as u64;
|
||||||
|
if (bytes_sent % (br * 20) as u64) < (br as u64) {
|
||||||
|
let elapsed = unix_millis() - time;
|
||||||
|
let elapsed = if elapsed == 0 { 1 } else { elapsed };
|
||||||
|
|
||||||
|
print!(
|
||||||
|
"\r\x1b[KSent {} bytes; Speed: {} kb/s",
|
||||||
|
bytes_sent,
|
||||||
|
br as usize * 20 / elapsed as usize
|
||||||
|
);
|
||||||
|
stdout().flush().unwrap();
|
||||||
|
time = unix_millis();
|
||||||
|
}
|
||||||
|
if unix_millis() - last_update > 100 {
|
||||||
|
on_progress((bytes_sent + begin) as f32 / len as f32);
|
||||||
|
last_update = unix_millis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn receiver<F: Fn(f32)>(args: &Vec<String>, on_progress: F) {
|
||||||
|
let connection = holepunch(args);
|
||||||
|
let br = args
|
||||||
|
.get(5)
|
||||||
|
.map(|s| u32::from_str_radix(s, 10))
|
||||||
|
.unwrap_or(Ok(256))
|
||||||
|
.expect("bad bitrate argument");
|
||||||
|
let begin = args
|
||||||
|
.get(6)
|
||||||
|
.map(|s| u64::from_str_radix(s, 10))
|
||||||
|
.unwrap_or(Ok(0))
|
||||||
|
.expect("bad begin operand");
|
||||||
|
let mut buf: Vec<u8> = Vec::new();
|
||||||
|
buf.resize(br as usize, 0);
|
||||||
|
let buf: &[u8] = buf.leak();
|
||||||
|
let mut file = OpenOptions::new()
|
||||||
|
.truncate(false)
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.open(&args.get(4).unwrap_or_else(|| {
|
||||||
print_args(args);
|
print_args(args);
|
||||||
panic!("unreachable")
|
panic!("unreachable")
|
||||||
}))
|
}))
|
||||||
.expect("unable to connect");
|
.expect("file not writable");
|
||||||
connection.send(&[0]).expect("connect write error");
|
|
||||||
|
if begin != 0 {
|
||||||
|
println!("Skipping to {}...", begin);
|
||||||
|
file.seek(SeekFrom::Start(begin)).expect("unable to skip");
|
||||||
|
println!("Done.");
|
||||||
|
}
|
||||||
|
|
||||||
let mut sc = SafeReadWrite::new(connection);
|
let mut sc = SafeReadWrite::new(connection);
|
||||||
|
let mut bytes_received: u64 = 0;
|
||||||
|
let mut last_update = unix_millis();
|
||||||
|
let mut len_bytes = [0 as u8; 8];
|
||||||
|
let len = sc
|
||||||
|
.read_safe(&mut len_bytes)
|
||||||
|
.expect("unable to read length from sender")
|
||||||
|
.0;
|
||||||
|
let len = u64::from_be_bytes([
|
||||||
|
len[0], len[1], len[2], len[3], len[4], len[5], len[6], len[7],
|
||||||
|
]);
|
||||||
|
let _ = file.set_len(len);
|
||||||
|
println!("Length: {}", &len);
|
||||||
|
let mut time = unix_millis();
|
||||||
loop {
|
loop {
|
||||||
let (mbuf, len) = sc.read_safe(buf).expect("read error");
|
let (mbuf, amount) = sc.read_safe(buf).expect("read error");
|
||||||
buf = &mbuf.leak()[..len];
|
let buf = &mbuf.leak()[..amount];
|
||||||
if len == 0 {
|
if amount == 0 {
|
||||||
|
println!();
|
||||||
println!("Transfer done. Thank you!");
|
println!("Transfer done. Thank you!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.write(buf).expect("write error");
|
file.write(buf).expect("write error");
|
||||||
println!("Received {} bytes", len);
|
file.flush().expect("file flush error");
|
||||||
|
bytes_received += amount as u64;
|
||||||
|
if (bytes_received % (br * 20) as u64) < (br as u64) {
|
||||||
|
let elapsed = unix_millis() - time;
|
||||||
|
let elapsed = if elapsed == 0 { 1 } else { elapsed };
|
||||||
|
|
||||||
|
print!(
|
||||||
|
"\r\x1b[KReceived {} bytes; Speed: {} kb/s",
|
||||||
|
bytes_received,
|
||||||
|
br as usize * 20 / elapsed as usize
|
||||||
|
);
|
||||||
|
stdout().flush().unwrap();
|
||||||
|
time = unix_millis();
|
||||||
|
}
|
||||||
|
if unix_millis() - last_update > 100 {
|
||||||
|
on_progress((bytes_received + begin) as f32 / len as f32);
|
||||||
|
last_update = unix_millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn holepunch(args: &Vec<String>) -> UdpSocket {
|
||||||
|
let bind_addr = (Ipv4Addr::from(0 as u32), 0);
|
||||||
|
let holepunch = UdpSocket::bind(&bind_addr).expect("unable to create socket");
|
||||||
|
holepunch
|
||||||
|
.connect(args.get(2).unwrap_or_else(|| {
|
||||||
|
print_args(args);
|
||||||
|
panic!("unreachable")
|
||||||
|
}))
|
||||||
|
.expect("unable to connect to helper");
|
||||||
|
let bytes = args
|
||||||
|
.get(3)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
print_args(args);
|
||||||
|
panic!("unreachable")
|
||||||
|
})
|
||||||
|
.as_bytes();
|
||||||
|
let mut buf = [0 as u8; 200];
|
||||||
|
for i in 0..bytes.len().min(200) {
|
||||||
|
buf[i] = bytes[i];
|
||||||
|
}
|
||||||
|
holepunch.send(&buf).expect("unable to talk to helper");
|
||||||
|
holepunch
|
||||||
|
.recv(&mut buf)
|
||||||
|
.expect("unable to receive from helper");
|
||||||
|
// buf should now contain our partner's address data.
|
||||||
|
let mut s = Vec::from(buf);
|
||||||
|
s.retain(|e| *e != 0);
|
||||||
|
let bind_addr = String::from_utf8_lossy(s.as_slice()).to_string();
|
||||||
|
println!(
|
||||||
|
"Holepunching {} (partner) and :{} (you).",
|
||||||
|
bind_addr,
|
||||||
|
holepunch.local_addr().unwrap().port()
|
||||||
|
);
|
||||||
|
holepunch
|
||||||
|
.connect(SocketAddrV4::from_str(bind_addr.as_str()).unwrap())
|
||||||
|
.expect("connection failed");
|
||||||
|
holepunch
|
||||||
|
.set_read_timeout(Some(Duration::from_secs(1)))
|
||||||
|
.unwrap();
|
||||||
|
holepunch
|
||||||
|
.set_write_timeout(Some(Duration::from_secs(1)))
|
||||||
|
.unwrap();
|
||||||
|
if env::var("QFT_USE_TIMED_HOLEPUNCH").is_ok() {
|
||||||
|
println!("Warning: You are using the QFT_USE_TIMED_HOLEPUNCH environment variable. This won't allow for more \
|
||||||
|
backwards-compatibility, rather it only exists as a fallback for bad connections. Please make absolutely \
|
||||||
|
sure your partner uses QFT_USE_TIMED_HOLEPUNCH as well, data might otherwise get corrupted on the receiver.");
|
||||||
|
println!("Waiting...");
|
||||||
|
let mut stop = false;
|
||||||
|
while !stop {
|
||||||
|
thread::sleep(Duration::from_millis(500 - (unix_millis() % 500)));
|
||||||
|
println!("CONNECT {}", unix_millis());
|
||||||
|
let _ = holepunch.send(&[0]);
|
||||||
|
let result = holepunch.recv(&mut [0, 0]);
|
||||||
|
if result.is_ok() && result.unwrap() == 1 {
|
||||||
|
holepunch.send(&[0, 0]).expect("connection failed");
|
||||||
|
let result = holepunch.recv(&mut [0, 0]);
|
||||||
|
if result.is_ok() && result.unwrap() == 2 {
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("Connecting...");
|
||||||
|
thread::sleep(Duration::from_millis(500 - (unix_millis() % 500)));
|
||||||
|
for _ in 0..40 {
|
||||||
|
let m = unix_millis();
|
||||||
|
let _ = holepunch.send(&[0]);
|
||||||
|
thread::sleep(Duration::from_millis((50 - (unix_millis() - m)).max(0)));
|
||||||
|
}
|
||||||
|
let mut result = Ok(1);
|
||||||
|
while result.is_ok() && result.unwrap() == 1 {
|
||||||
|
result = holepunch.recv(&mut [0, 0]);
|
||||||
|
}
|
||||||
|
holepunch.send(&[0, 0]).expect("connection failed");
|
||||||
|
holepunch.send(&[0, 0]).expect("connection failed");
|
||||||
|
result = Ok(1);
|
||||||
|
while result.is_ok() && result.unwrap() != 2 {
|
||||||
|
result = holepunch.recv(&mut [0, 0]);
|
||||||
|
}
|
||||||
|
result = Ok(1);
|
||||||
|
while result.is_ok() && result.unwrap() == 2 {
|
||||||
|
result = holepunch.recv(&mut [0, 0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("Holepunch and connection successful.");
|
||||||
|
return holepunch;
|
||||||
|
}
|
||||||
|
|
||||||
fn print_args(args: &Vec<String>) {
|
fn print_args(args: &Vec<String>) {
|
||||||
let f = args.get(0).unwrap();
|
let f = args.get(0).unwrap();
|
||||||
println!(
|
println!(
|
||||||
"No arguments. Needed: \n\
|
"No arguments. Needed: \n\
|
||||||
| {} helper <bind-port>\n\
|
| {} helper <bind-port>\n\
|
||||||
| {} sender <helper-address>:<helper-port> <filename>\n\
|
| {} sender <helper-address>:<helper-port> <phrase> <filename> [send-dly] [bitrate] [skip]\n\
|
||||||
| {} receiver <sender-address>:<sender-port> <filename>",
|
| {} receiver <helper-address>:<helper-port> <phrase> <filename> [bitrate] [skip]\n\
|
||||||
f, f, f
|
| {} gui\n\
|
||||||
|
| {} version\n",
|
||||||
|
f, f, f, f, f
|
||||||
);
|
);
|
||||||
panic!("No arguments");
|
panic!("No arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn unix_millis() -> u64 {
|
||||||
|
SystemTime::now()
|
||||||
|
.duration_since(SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_millis() as u64
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue