├── .gitignore ├── application ├── .gitignore ├── src │ ├── commands │ │ ├── mod.rs │ │ └── version.rs │ ├── server │ │ ├── filesystem │ │ │ ├── archive │ │ │ │ ├── create │ │ │ │ │ └── mod.rs │ │ │ │ └── multi_reader.rs │ │ │ ├── limiter │ │ │ │ └── none.rs │ │ │ └── pull │ │ │ │ └── resolver.rs │ │ ├── resources.rs │ │ └── configuration │ │ │ └── process │ │ │ ├── yaml.rs │ │ │ ├── plain.rs │ │ │ └── json.rs │ ├── routes │ │ ├── upload │ │ │ └── mod.rs │ │ ├── api │ │ │ ├── backups │ │ │ │ ├── mod.rs │ │ │ │ └── _backup_.rs │ │ │ ├── servers │ │ │ │ ├── _server_ │ │ │ │ │ ├── install │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── abort.rs │ │ │ │ │ ├── schedules │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ └── _schedule_ │ │ │ │ │ │ │ ├── abort.rs │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── trigger.rs │ │ │ │ │ ├── files │ │ │ │ │ │ ├── operations │ │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ │ └── _operation_.rs │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── pull │ │ │ │ │ │ │ └── _pull_.rs │ │ │ │ │ │ └── create_directory.rs │ │ │ │ │ ├── ws │ │ │ │ │ │ ├── mod.rs │ │ │ │ │ │ ├── deny.rs │ │ │ │ │ │ └── permissions.rs │ │ │ │ │ ├── logs.rs │ │ │ │ │ ├── script.rs │ │ │ │ │ ├── commands.rs │ │ │ │ │ └── backup │ │ │ │ │ │ ├── _backup_ │ │ │ │ │ │ └── mod.rs │ │ │ │ │ │ └── mod.rs │ │ │ │ └── mod.rs │ │ │ ├── system │ │ │ │ ├── config.rs │ │ │ │ ├── stats │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── ws.rs │ │ │ │ ├── mod.rs │ │ │ │ └── logs │ │ │ │ │ ├── _file_.rs │ │ │ │ │ └── mod.rs │ │ │ ├── transfers │ │ │ │ └── _server_.rs │ │ │ └── mod.rs │ │ ├── download │ │ │ └── mod.rs │ │ └── mod.rs │ ├── deserialize.rs │ ├── ssh │ │ └── mod.rs │ ├── lib.rs │ ├── io │ │ ├── mod.rs │ │ ├── counting_writer.rs │ │ ├── counting_reader.rs │ │ ├── hash_reader.rs │ │ └── compression │ │ │ └── mod.rs │ ├── utils.rs │ └── models.rs ├── build.rs └── Cargo.toml ├── unrar-rs ├── .gitignore ├── README.md ├── unrar_sys │ ├── vendor │ │ ├── unrar │ │ │ ├── dll.rc │ │ │ ├── rs16.cpp │ │ │ ├── rarpch.cpp │ │ │ ├── list.hpp │ │ │ ├── global.cpp │ │ │ ├── resource.cpp │ │ │ ├── smallfn.hpp │ │ │ ├── rarlang.hpp │ │ │ ├── volume.hpp │ │ │ ├── version.hpp │ │ │ ├── resource.hpp │ │ │ ├── ui.cpp │ │ │ ├── global.hpp │ │ │ ├── dll.def │ │ │ ├── dll_nocrypt.def │ │ │ ├── log.hpp │ │ │ ├── smallfn.cpp │ │ │ ├── filcreat.hpp │ │ │ ├── crc.hpp │ │ │ ├── isnt.hpp │ │ │ ├── filestr.hpp │ │ │ ├── sha1.hpp │ │ │ ├── sha256.hpp │ │ │ ├── encname.hpp │ │ │ ├── raros.hpp │ │ │ ├── options.cpp │ │ │ ├── log.cpp │ │ │ ├── coder.hpp │ │ │ ├── consio.hpp │ │ │ ├── extinfo.hpp │ │ │ ├── rs.hpp │ │ │ ├── secpassword.hpp │ │ │ ├── strlist.hpp │ │ │ ├── headers.cpp │ │ │ ├── hardlinks.cpp │ │ │ ├── find.hpp │ │ │ ├── rarvm.hpp │ │ │ ├── system.hpp │ │ │ ├── rawread.hpp │ │ │ ├── getbits.cpp │ │ │ ├── rartypes.hpp │ │ │ ├── coder.cpp │ │ │ ├── crypt1.cpp │ │ │ ├── rardefs.hpp │ │ │ ├── uisilent.cpp │ │ │ ├── rs16.hpp │ │ │ ├── qopen.hpp │ │ │ ├── match.hpp │ │ │ ├── rar.hpp │ │ │ ├── readme.txt │ │ │ ├── hash.hpp │ │ │ ├── filefn.hpp │ │ │ ├── rijndael.hpp │ │ │ ├── license.txt │ │ │ ├── makefile │ │ │ ├── encname.cpp │ │ │ ├── strfn.hpp │ │ │ ├── getbits.hpp │ │ │ ├── crypt3.cpp │ │ │ ├── unicode.hpp │ │ │ ├── scantree.hpp │ │ │ ├── compress.hpp │ │ │ ├── uicommon.cpp │ │ │ ├── suballoc.hpp │ │ │ ├── recvol.hpp │ │ │ ├── timefn.hpp │ │ │ ├── errhnd.hpp │ │ │ ├── rdwrfn.hpp │ │ │ ├── rar.cpp │ │ │ └── acknow.txt │ │ ├── patches.txt │ │ ├── Documentation │ │ │ ├── RARSetChangeVolProc.md │ │ │ ├── RARSetProcessDataProc.md │ │ │ ├── RAROpenArchiveEx.md │ │ │ ├── RAROpenArchive.md │ │ │ ├── RARCloseArchive.md │ │ │ ├── RARGetDllVersion.md │ │ │ ├── Introduction.md │ │ │ ├── RARReadHeaderEx.md │ │ │ ├── RARSetPassword.md │ │ │ ├── index.md │ │ │ ├── RARReadHeader.md │ │ │ └── RARSetCallback.md │ │ ├── upgrade.sh │ │ └── README.md │ ├── Cargo.toml │ └── build.rs ├── src │ ├── pathed │ │ ├── mod.rs │ │ ├── all.rs │ │ └── linux.rs │ └── lib.rs ├── examples │ ├── basic_list.rs │ ├── basic_extract.rs │ ├── read_named.rs │ └── lister.rs ├── Cargo.toml └── LICENSE-MIT ├── .github └── FUNDING.yml ├── Dockerfile ├── LICENSE └── Cargo.toml /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | config*.yml 3 | -------------------------------------------------------------------------------- /application/.gitignore: -------------------------------------------------------------------------------- 1 | seccomp.min.json 2 | -------------------------------------------------------------------------------- /unrar-rs/.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | Cargo.lock 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: ["calagopus-rs", "0x7d8"] 2 | ko_fi: "rjansen" 3 | -------------------------------------------------------------------------------- /unrar-rs/README.md: -------------------------------------------------------------------------------- 1 | # unrar 2 | 3 | 4 | -------------------------------------------------------------------------------- /application/src/commands/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod configure; 2 | pub mod diagnostics; 3 | pub mod service_install; 4 | pub mod version; 5 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/dll.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/calagopus-rs/wings/HEAD/unrar-rs/unrar_sys/vendor/unrar/dll.rc -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rs16.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/calagopus-rs/wings/HEAD/unrar-rs/unrar_sys/vendor/unrar/rs16.cpp -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rarpch.cpp: -------------------------------------------------------------------------------- 1 | // We use rarpch.cpp to create precompiled headers for MS Visual C++. 2 | #include "rar.hpp" 3 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/list.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_LIST_ 2 | #define _RAR_LIST_ 3 | 4 | void ListArchive(CommandData *Cmd); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/global.cpp: -------------------------------------------------------------------------------- 1 | #define INCLUDEGLOBAL 2 | 3 | #ifdef _MSC_VER 4 | #pragma hdrstop 5 | #endif 6 | 7 | #include "rar.hpp" 8 | -------------------------------------------------------------------------------- /application/src/server/filesystem/archive/create/mod.rs: -------------------------------------------------------------------------------- 1 | mod seven_zip; 2 | mod tar; 3 | mod zip; 4 | 5 | pub use seven_zip::*; 6 | pub use tar::*; 7 | pub use zip::*; 8 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/resource.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | 4 | 5 | 6 | 7 | #ifndef RARDLL 8 | const wchar* St(MSGID StringId) 9 | { 10 | return StringId; 11 | } 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/patches.txt: -------------------------------------------------------------------------------- 1 | 5accdb7d4e49618640183a0cbe868fef74db5c73 2 | f2adc5820c30216f5ac27fb888040b6618d90ae6 3 | c3b414e28f87f06df43d6ab91220faf1647f7433 4 | 7db15f7346050feae8aaa574d172fac33c52bbf1 5 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/smallfn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SMALLFN_ 2 | #define _RAR_SMALLFN_ 3 | 4 | int ToPercent(int64 N1,int64 N2); 5 | int ToPercentUnlim(int64 N1,int64 N2); 6 | void RARInitData(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rarlang.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_LANG_ 2 | #define _RAR_LANG_ 3 | 4 | #ifdef USE_RC 5 | #include "rarres.hpp" 6 | #else 7 | #include "loclang.hpp" 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/volume.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_VOLUME_ 2 | #define _RAR_VOLUME_ 3 | 4 | bool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName, 5 | wchar Command); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/version.hpp: -------------------------------------------------------------------------------- 1 | #define RARVER_MAJOR 7 2 | #define RARVER_MINOR 1 3 | #define RARVER_BETA 0 4 | #define RARVER_DAY 12 5 | #define RARVER_MONTH 5 6 | #define RARVER_YEAR 2024 7 | -------------------------------------------------------------------------------- /unrar-rs/src/pathed/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg_attr(any(target_os = "linux", target_os = "netbsd"), path = "linux.rs")] 2 | #[cfg_attr(not(any(target_os = "linux", target_os = "netbsd")), path = "all.rs")] 3 | mod os; 4 | 5 | pub(crate) use os::*; 6 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/resource.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RESOURCE_ 2 | #define _RAR_RESOURCE_ 3 | 4 | #ifdef RARDLL 5 | #define St(x) (L"") 6 | #else 7 | const wchar *St(MSGID StringId); 8 | #endif 9 | 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/ui.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #include "uicommon.cpp" 4 | 5 | #ifdef SILENT 6 | #include "uisilent.cpp" 7 | #else 8 | 9 | 10 | 11 | 12 | #include "uiconsole.cpp" 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/global.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_GLOBAL_ 2 | #define _RAR_GLOBAL_ 3 | 4 | #ifdef INCLUDEGLOBAL 5 | #define EXTVAR 6 | #else 7 | #define EXTVAR extern 8 | #endif 9 | 10 | EXTVAR ErrorHandler ErrHandler; 11 | 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /application/src/routes/upload/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::router::OpenApiRouter; 3 | 4 | mod file; 5 | 6 | pub fn router(state: &State) -> OpenApiRouter { 7 | OpenApiRouter::new() 8 | .nest("/file", file::router(state)) 9 | .with_state(state.clone()) 10 | } 11 | -------------------------------------------------------------------------------- /application/src/routes/api/backups/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::router::OpenApiRouter; 3 | 4 | mod _backup_; 5 | 6 | pub fn router(state: &State) -> OpenApiRouter { 7 | OpenApiRouter::new() 8 | .nest("/{backup}", _backup_::router(state)) 9 | .with_state(state.clone()) 10 | } 11 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/install/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::router::OpenApiRouter; 3 | 4 | mod abort; 5 | 6 | pub fn router(state: &State) -> OpenApiRouter { 7 | OpenApiRouter::new() 8 | .nest("/abort", abort::router(state)) 9 | .with_state(state.clone()) 10 | } 11 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/dll.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | RAROpenArchive 3 | RAROpenArchiveEx 4 | RARCloseArchive 5 | RARReadHeader 6 | RARReadHeaderEx 7 | RARProcessFile 8 | RARProcessFileW 9 | RARSetCallback 10 | RARSetChangeVolProc 11 | RARSetProcessDataProc 12 | RARSetPassword 13 | RARGetDllVersion 14 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | RUN apk add --no-cache ca-certificates coreutils curl btrfs-progs xfsprogs-extra zfs restic && \ 4 | update-ca-certificates 5 | 6 | # Add wings-rs and entrypoint 7 | ARG TARGETPLATFORM 8 | COPY .docker/${TARGETPLATFORM#linux/}/wings-rs /usr/bin/wings-rs 9 | 10 | ENTRYPOINT ["/usr/bin/wings-rs"] 11 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/dll_nocrypt.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | RAROpenArchive 3 | RAROpenArchiveEx 4 | RARCloseArchive 5 | RARReadHeader 6 | RARReadHeaderEx 7 | RARProcessFile 8 | RARProcessFileW 9 | RARSetCallback 10 | RARSetChangeVolProc 11 | RARSetProcessDataProc 12 | ; RARSetPassword 13 | RARGetDllVersion 14 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/schedules/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::router::OpenApiRouter; 3 | 4 | mod _schedule_; 5 | 6 | pub fn router(state: &State) -> OpenApiRouter { 7 | OpenApiRouter::new() 8 | .nest("/{schedule}", _schedule_::router(state)) 9 | .with_state(state.clone()) 10 | } 11 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/files/operations/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::router::OpenApiRouter; 3 | 4 | mod _operation_; 5 | 6 | pub fn router(state: &State) -> OpenApiRouter { 7 | OpenApiRouter::new() 8 | .nest("/{operation}", _operation_::router(state)) 9 | .with_state(state.clone()) 10 | } 11 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/log.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_LOG_ 2 | #define _RAR_LOG_ 3 | 4 | void InitLogOptions(const std::wstring &LogFileName,RAR_CHARSET CSet); 5 | void CloseLogOptions(); 6 | 7 | #ifdef SILENT 8 | inline void Log(const wchar *ArcName,const wchar *fmt,...) {} 9 | #else 10 | void Log(const wchar *ArcName,const wchar *fmt,...); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/smallfn.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | int ToPercent(int64 N1,int64 N2) 4 | { 5 | if (N2 OpenApiRouter { 8 | OpenApiRouter::new() 9 | .nest("/deny", deny::router(state)) 10 | .nest("/permissions", permissions::router(state)) 11 | .with_state(state.clone()) 12 | } 13 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/filcreat.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_FILECREATE_ 2 | #define _RAR_FILECREATE_ 3 | 4 | bool FileCreate(CommandData *Cmd,File *NewFile,std::wstring &Name, 5 | bool *UserReject,int64 FileSize=INT64NDF, 6 | RarTime *FileTime=NULL,bool WriteOnly=false); 7 | 8 | #if defined(_WIN_ALL) 9 | bool UpdateExistingShortName(const std::wstring &Name); 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/crc.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_CRC_ 2 | #define _RAR_CRC_ 3 | 4 | // This function is only to intialize external CRC tables. We do not need to 5 | // call it before calculating CRC32. 6 | void InitCRC32(uint *CRCTab); 7 | 8 | uint CRC32(uint StartCRC,const void *Addr,size_t Size); 9 | 10 | #ifndef SFX_MODULE 11 | ushort Checksum14(ushort StartCRC,const void *Addr,size_t Size); 12 | #endif 13 | 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/isnt.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_ISNT_ 2 | #define _RAR_ISNT_ 3 | 4 | enum WINNT_VERSION { 5 | WNT_NONE=0,WNT_NT351=0x0333,WNT_NT4=0x0400,WNT_W2000=0x0500, 6 | WNT_WXP=0x0501,WNT_W2003=0x0502,WNT_VISTA=0x0600,WNT_W7=0x0601, 7 | WNT_W8=0x0602,WNT_W81=0x0603,WNT_W10=0x0a00 8 | }; 9 | 10 | DWORD WinNT(); 11 | 12 | 13 | // Replace it with actual check when available. 14 | bool IsWindows11OrGreater(); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /unrar-rs/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!("../README.md")] 2 | #![warn(missing_docs)] 3 | 4 | pub use archive::Archive; 5 | use unrar_sys as native; 6 | mod archive; 7 | pub mod error; 8 | mod open_archive; 9 | mod pathed; 10 | pub use error::UnrarResult; 11 | pub use open_archive::FileHash; 12 | pub use open_archive::{ 13 | CursorBeforeFile, CursorBeforeHeader, FileHeader, List, ListSplit, OpenArchive, Process, 14 | Stream, VolumeInfo, 15 | }; 16 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/filestr.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_FILESTR_ 2 | #define _RAR_FILESTR_ 3 | 4 | bool ReadTextFile( 5 | const std::wstring &Name, 6 | StringList *List, 7 | bool Config, 8 | bool AbortOnError=false, 9 | RAR_CHARSET SrcCharset=RCH_DEFAULT, 10 | bool Unquote=false, 11 | bool SkipComments=false, 12 | bool ExpandEnvStr=false 13 | ); 14 | 15 | RAR_CHARSET DetectTextEncoding(const byte *Data,size_t DataSize); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/sha1.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SHA1_ 2 | #define _RAR_SHA1_ 3 | 4 | typedef struct { 5 | uint32 state[5]; 6 | uint64 count; 7 | unsigned char buffer[64]; 8 | } sha1_context; 9 | 10 | void sha1_init( sha1_context * c ); 11 | void sha1_process(sha1_context * c, const byte *data, size_t len); 12 | void sha1_process_rar29(sha1_context *context, const unsigned char *data, size_t len); 13 | void sha1_done( sha1_context * c, uint32 digest[5] ); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /unrar-rs/examples/basic_list.rs: -------------------------------------------------------------------------------- 1 | use unrar::Archive; 2 | 3 | fn main() { 4 | // Basic args parsing 5 | // Usage: cargo run --example basic_list path/to/archive.rar 6 | let args = std::env::args(); 7 | let file = args.skip(1).next().unwrap_or("archive.rar".to_owned()); 8 | 9 | let archive = Archive::new(&file).open_for_listing().unwrap(); 10 | for e in archive { 11 | let entry = e.unwrap(); 12 | println!("{}", entry.filename.to_string_lossy()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/sha256.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SHA256_ 2 | #define _RAR_SHA256_ 3 | 4 | #define SHA256_DIGEST_SIZE 32 5 | 6 | typedef struct 7 | { 8 | uint32 H[8]; 9 | uint64 Count; 10 | byte Buffer[64]; 11 | } sha256_context; 12 | 13 | void sha256_init(sha256_context *ctx); 14 | void sha256_process(sha256_context *ctx, const void *Data, size_t Size); 15 | void sha256_done(sha256_context *ctx, byte *Digest); 16 | void sha256_get(const void *Data, size_t Size, byte *Digest); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /application/src/routes/download/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::router::OpenApiRouter; 3 | 4 | mod backup; 5 | mod directory; 6 | mod file; 7 | mod files; 8 | 9 | pub fn router(state: &State) -> OpenApiRouter { 10 | OpenApiRouter::new() 11 | .nest("/file", file::router(state)) 12 | .nest("/files", files::router(state)) 13 | .nest("/directory", directory::router(state)) 14 | .nest("/backup", backup::router(state)) 15 | .with_state(state.clone()) 16 | } 17 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARSetChangeVolProc.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

11 | void PASCAL RARSetChangeVolProc(HANDLE hArcData, 12 | int PASCAL (*ChangeVolProc)(char *ArcName,int Mode)) 13 |

14 | 15 |

Description

16 | 17 | Obsolete. Use the callback function instead. 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /unrar-rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unrar" 3 | version = "0.6.0" 4 | authors = [ 5 | "Danyel Bayraktar ", 6 | "vjoki ", 7 | ] 8 | edition = "2021" 9 | 10 | license = "MIT OR Apache-2.0" 11 | description = "list and extract RAR archives" 12 | repository = "https://github.com/muja/unrar.rs" 13 | 14 | [dependencies] 15 | regex = "1" 16 | bitflags = "2" 17 | widestring = "1" 18 | 19 | [dependencies.unrar_sys] 20 | path = "unrar_sys" 21 | version = "0.5" 22 | 23 | [dev-dependencies] 24 | tempfile = "3.12.0" 25 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARSetProcessDataProc.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

11 | void PASCAL RARSetProcessDataProc(HANDLE hArcData, 12 | int PASCAL (*ProcessDataProc)(unsigned char *Addr,int Size)) 13 |

14 | 15 |

Description

16 | 17 | Obsolete. Use the callback function instead. 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/encname.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_ENCNAME_ 2 | #define _RAR_ENCNAME_ 3 | 4 | class EncodeFileName 5 | { 6 | private: 7 | void AddFlags(byte Value,std::vector &EncName); 8 | 9 | byte Flags; 10 | uint FlagBits; 11 | size_t FlagsPos; 12 | size_t DestSize; 13 | public: 14 | EncodeFileName(); 15 | void Encode(const std::string &Name,const std::wstring &NameW,std::vector &EncName); 16 | void Decode(const char *Name,size_t NameSize,const byte *EncName,size_t EncSize,std::wstring &NameW); 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /application/src/commands/version.rs: -------------------------------------------------------------------------------- 1 | use chrono::Datelike; 2 | use clap::ArgMatches; 3 | use std::sync::Arc; 4 | 5 | const TARGET: &str = env!("CARGO_TARGET"); 6 | 7 | pub async fn version( 8 | _matches: &ArgMatches, 9 | _config: Option<&Arc>, 10 | ) -> Result { 11 | println!( 12 | "github.com/calagopus-rs/wings {}:{} ({TARGET})", 13 | crate::VERSION, 14 | crate::GIT_COMMIT 15 | ); 16 | println!( 17 | "copyright © 2025 - {} 0x7d8 & Contributors", 18 | chrono::Local::now().year() 19 | ); 20 | 21 | Ok(0) 22 | } 23 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/raros.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RAROS_ 2 | #define _RAR_RAROS_ 3 | 4 | #if defined(__WIN32__) || defined(_WIN32) 5 | #define _WIN_ALL // Defined for all Windows platforms, 32 and 64 bit, mobile and desktop. 6 | #ifdef _M_X64 7 | #define _WIN_64 8 | #else 9 | #define _WIN_32 10 | #endif 11 | #endif 12 | 13 | #if defined(ANDROID) || defined(__ANDROID__) 14 | #define _UNIX 15 | #define _ANDROID 16 | #endif 17 | 18 | #ifdef __APPLE__ 19 | #define _UNIX 20 | #define _APPLE 21 | #endif 22 | 23 | #if !defined(_WIN_ALL) && !defined(_UNIX) 24 | #define _UNIX 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/options.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | RAROptions::RAROptions() 4 | { 5 | Init(); 6 | } 7 | 8 | 9 | void RAROptions::Init() 10 | { 11 | memset(this,0,sizeof(RAROptions)); 12 | WinSize=0x2000000; 13 | WinSizeLimit=0x100000000; 14 | Overwrite=OVERWRITE_DEFAULT; 15 | Method=3; 16 | MsgStream=MSG_STDOUT; 17 | ConvertNames=NAMES_ORIGINALCASE; 18 | xmtime=EXTTIME_MAX; 19 | FileSizeLess=INT64NDF; 20 | FileSizeMore=INT64NDF; 21 | HashType=HASH_CRC32; 22 | #ifdef RAR_SMP 23 | Threads=GetNumberOfThreads(); 24 | #endif 25 | #ifdef USE_QOPEN 26 | QOpenMode=QOPEN_AUTO; 27 | #endif 28 | } 29 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | usage() { 4 | echo "Usage: $0 " 5 | exit $1 6 | } 7 | 8 | fatal() { 9 | echo >&2 "fatal: $1, aborting..." 10 | exit 1 11 | } 12 | 13 | cd "$(dirname "$(realpath "$0")")" 14 | 15 | #git status --porcelain | grep -v '^??' >/dev/null && fatal "git repository must not be dirty" 16 | 17 | [ -z "$1" ] && usage 1 18 | [ "$1" = "--help" ] && usage 0 19 | 20 | curl "$1" -o src.tar.gz && 21 | 22 | tar xvf src.tar.gz && 23 | 24 | rm src.tar.gz && 25 | 26 | git add unrar && 27 | 28 | while read patch; do 29 | git cherry-pick -n $patch 30 | done < patches.txt -------------------------------------------------------------------------------- /unrar-rs/examples/basic_extract.rs: -------------------------------------------------------------------------------- 1 | use unrar::Archive; 2 | 3 | fn main() -> Result<(), Box> { 4 | let mut archive = Archive::new("../archive.rar") 5 | .open_for_processing() 6 | .unwrap(); 7 | while let Some(header) = archive.read_header()? { 8 | println!( 9 | "{} bytes: {}", 10 | header.entry().unpacked_size, 11 | header.entry().filename.to_string_lossy(), 12 | ); 13 | archive = if header.entry().is_file() { 14 | header.extract()? 15 | } else { 16 | header.skip()? 17 | }; 18 | } 19 | Ok(()) 20 | } 21 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "unrar_sys" 3 | version = "0.5.8" 4 | authors = ["Danyel Bayraktar "] 5 | 6 | build = "build.rs" 7 | license = "MIT OR Apache-2.0" 8 | description = "FFI bindings to unrar (with minimal abstractions)" 9 | repository = "https://github.com/muja/unrar.rs" 10 | edition = "2021" 11 | 12 | [features] 13 | default = ["std"] 14 | std = ["libc/std", "winapi/std"] 15 | 16 | [dependencies] 17 | libc = { version = "0.2", default-features = false } 18 | 19 | [build-dependencies] 20 | cc = "1" 21 | 22 | [target.'cfg(windows)'.dependencies] 23 | winapi = { version = "0.3", features = ["minwindef", "ntdef"] } 24 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/README.md: -------------------------------------------------------------------------------- 1 | # updating unrar DLL 2 | 3 | Upgrading unrar DLL is simple: 4 | 5 | - download the latest release from https://www.rarlab.com/rar_add.htm (titled "UnRAR release source" at the time of writing) 6 | - extract the tarball into this directory (top level directory is `unrar/` in both cases) 7 | - apply the patches from [`patches.txt`](./patches.txt): `git add unrar && cat patches.txt | xargs git cherry-pick -n` 8 | 9 | The small script [`upgrade.sh`](./upgrade.sh) will automate these steps if you provide it the URL to the tarball, e.g.: 10 | 11 | ```bash 12 | ./upgrade.sh https://www.rarlab.com/rar/unrarsrc-6.2.12.tar.gz 13 | ``` 14 | -------------------------------------------------------------------------------- /application/src/routes/api/system/config.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod get { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::GetState, 8 | }; 9 | 10 | #[utoipa::path(get, path = "/", responses( 11 | (status = OK, body = inline(crate::config::InnerConfig)), 12 | ))] 13 | pub async fn route(state: GetState) -> ApiResponseResult { 14 | ApiResponse::json(&**state.config).ok() 15 | } 16 | } 17 | 18 | pub fn router(state: &State) -> OpenApiRouter { 19 | OpenApiRouter::new() 20 | .routes(routes!(get::route)) 21 | .with_state(state.clone()) 22 | } 23 | -------------------------------------------------------------------------------- /application/src/deserialize.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Deserializer, de::DeserializeOwned}; 2 | 3 | #[inline] 4 | pub fn deserialize_optional<'de, T, D>(deserializer: D) -> Result, D::Error> 5 | where 6 | T: DeserializeOwned, 7 | D: Deserializer<'de>, 8 | { 9 | let value = serde_json::Value::deserialize(deserializer)?; 10 | 11 | Ok(serde_json::from_value(value).ok()) 12 | } 13 | 14 | #[inline] 15 | pub fn deserialize_defaultable<'de, T, D>(deserializer: D) -> Result 16 | where 17 | T: DeserializeOwned + Default, 18 | D: Deserializer<'de>, 19 | { 20 | let value = serde_json::Value::deserialize(deserializer)?; 21 | 22 | Ok(serde_json::from_value(value).unwrap_or_default()) 23 | } 24 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/log.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | 4 | 5 | void InitLogOptions(const std::wstring &LogFileName,RAR_CHARSET CSet) 6 | { 7 | } 8 | 9 | 10 | void CloseLogOptions() 11 | { 12 | } 13 | 14 | 15 | #ifndef SILENT 16 | void Log(const wchar *ArcName,const wchar *fmt,...) 17 | { 18 | // Preserve the error code for possible following system error message. 19 | int Code=ErrHandler.GetSystemErrorCode(); 20 | 21 | uiAlarm(UIALARM_ERROR); 22 | 23 | va_list arglist; 24 | va_start(arglist,fmt); 25 | 26 | std::wstring s=vwstrprintf(fmt,arglist); 27 | 28 | ReplaceEsc(s); 29 | 30 | va_end(arglist); 31 | eprintf(L"%ls",s.c_str()); 32 | ErrHandler.SetSystemErrorCode(Code); 33 | } 34 | #endif 35 | 36 | 37 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/coder.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Contents: 'Carryless rangecoder' by Dmitry Subbotin * 3 | ****************************************************************************/ 4 | 5 | 6 | class RangeCoder 7 | { 8 | public: 9 | void InitDecoder(Unpack *UnpackRead); 10 | inline int GetCurrentCount(); 11 | inline uint GetCurrentShiftCount(uint SHIFT); 12 | inline void Decode(); 13 | inline void PutChar(unsigned int c); 14 | inline byte GetChar(); 15 | 16 | uint low, code, range; 17 | struct SUBRANGE 18 | { 19 | uint LowCount, HighCount, scale; 20 | } SubRange; 21 | 22 | Unpack *UnpackRead; 23 | }; 24 | -------------------------------------------------------------------------------- /application/src/server/resources.rs: -------------------------------------------------------------------------------- 1 | use super::state::ServerState; 2 | use serde::{Deserialize, Serialize}; 3 | use utoipa::ToSchema; 4 | 5 | nestify::nest! { 6 | #[derive(ToSchema, Default, Deserialize, Serialize, Clone, Copy, PartialEq)] 7 | pub struct ResourceUsage { 8 | pub memory_bytes: u64, 9 | pub memory_limit_bytes: u64, 10 | pub disk_bytes: u64, 11 | 12 | pub state: ServerState, 13 | 14 | #[schema(inline)] 15 | pub network: #[derive(ToSchema, Default, Deserialize, Serialize, Clone, Copy, PartialEq)] pub struct ResourceUsageNetwork { 16 | pub rx_bytes: u64, 17 | pub tx_bytes: u64, 18 | }, 19 | 20 | pub cpu_absolute: f64, 21 | pub uptime: u64, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /application/src/ssh/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::routes::State; 2 | use std::{ 3 | collections::{HashMap, HashSet}, 4 | net::SocketAddr, 5 | sync::Arc, 6 | }; 7 | 8 | mod auth; 9 | mod exec; 10 | mod sftp; 11 | mod shell; 12 | 13 | pub struct Server { 14 | pub state: State, 15 | } 16 | 17 | impl russh::server::Server for Server { 18 | type Handler = auth::SshSession; 19 | 20 | fn new_client(&mut self, client: Option) -> Self::Handler { 21 | auth::SshSession { 22 | state: Arc::clone(&self.state), 23 | server: None, 24 | 25 | user_ip: client.map(|addr| addr.ip()), 26 | user_uuid: None, 27 | 28 | clients: HashMap::new(), 29 | shell_clients: HashSet::new(), 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /application/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod commands; 2 | pub mod config; 3 | pub mod deserialize; 4 | pub mod io; 5 | pub mod models; 6 | pub mod remote; 7 | pub mod response; 8 | pub mod routes; 9 | pub mod server; 10 | pub mod ssh; 11 | pub mod stats; 12 | pub mod utils; 13 | 14 | pub const VERSION: &str = env!("CARGO_PKG_VERSION"); 15 | pub const GIT_COMMIT: &str = env!("CARGO_GIT_COMMIT"); 16 | pub const BUFFER_SIZE: usize = 32 * 1024; 17 | 18 | #[inline(always)] 19 | #[cold] 20 | fn cold_path() {} 21 | 22 | #[inline(always)] 23 | pub fn likely(b: bool) -> bool { 24 | if b { 25 | true 26 | } else { 27 | cold_path(); 28 | false 29 | } 30 | } 31 | 32 | #[inline(always)] 33 | pub fn unlikely(b: bool) -> bool { 34 | if b { 35 | cold_path(); 36 | true 37 | } else { 38 | false 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/consio.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_CONSIO_ 2 | #define _RAR_CONSIO_ 3 | 4 | void InitConsole(); 5 | void SetConsoleMsgStream(MESSAGE_TYPE MsgStream); 6 | void SetConsoleRedirectCharset(RAR_CHARSET RedirectCharset); 7 | void ProhibitConsoleInput(); 8 | void OutComment(const std::wstring &Comment); 9 | 10 | #ifndef SILENT 11 | bool GetConsolePassword(UIPASSWORD_TYPE Type,const std::wstring &FileName,SecPassword *Password); 12 | #endif 13 | 14 | #ifdef SILENT 15 | inline void mprintf(const wchar *fmt,...) {} 16 | inline void eprintf(const wchar *fmt,...) {} 17 | inline void Alarm() {} 18 | inline int Ask(const wchar *AskStr) {return 0;} 19 | inline bool getwstr(std::wstring &str) {return false;} 20 | #else 21 | void mprintf(const wchar *fmt,...); 22 | void eprintf(const wchar *fmt,...); 23 | void Alarm(); 24 | int Ask(const wchar *AskStr); 25 | bool getwstr(std::wstring &str); 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/extinfo.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_EXTINFO_ 2 | #define _RAR_EXTINFO_ 3 | 4 | bool IsRelativeSymlinkSafe(CommandData *Cmd,const std::wstring &SrcName,std::wstring PrepSrcName,const std::wstring &TargetName); 5 | bool ExtractSymlink(CommandData *Cmd,ComprDataIO &DataIO,Archive &Arc,const std::wstring &LinkName,bool &UpLink); 6 | #ifdef _UNIX 7 | void SetUnixOwner(Archive &Arc,const std::wstring &FileName); 8 | #endif 9 | 10 | bool ExtractHardlink(CommandData *Cmd,const std::wstring &NameNew,const std::wstring &NameExisting); 11 | 12 | std::wstring GetStreamNameNTFS(Archive &Arc); 13 | 14 | #ifdef _WIN_ALL 15 | bool SetPrivilege(LPCTSTR PrivName); 16 | #endif 17 | 18 | void SetExtraInfo20(CommandData *Cmd,Archive &Arc,const std::wstring &Name); 19 | void SetExtraInfo(CommandData *Cmd,Archive &Arc,const std::wstring &Name); 20 | void SetFileHeaderExtra(CommandData *Cmd,Archive &Arc,const std::wstring &Name); 21 | 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /application/src/io/mod.rs: -------------------------------------------------------------------------------- 1 | use std::io::{Read, Write}; 2 | 3 | pub mod abort; 4 | pub mod compression; 5 | pub mod counting_reader; 6 | pub mod counting_writer; 7 | pub mod fixed_reader; 8 | pub mod hash_reader; 9 | pub mod limited_reader; 10 | pub mod limited_writer; 11 | pub mod range_reader; 12 | 13 | pub fn copy( 14 | reader: &mut (impl ?Sized + Read), 15 | writer: &mut (impl ?Sized + Write), 16 | ) -> std::io::Result<()> { 17 | let mut buffer = vec![0; crate::BUFFER_SIZE]; 18 | 19 | copy_shared(&mut buffer, reader, writer) 20 | } 21 | 22 | pub fn copy_shared( 23 | buffer: &mut [u8], 24 | reader: &mut (impl ?Sized + Read), 25 | writer: &mut (impl ?Sized + Write), 26 | ) -> std::io::Result<()> { 27 | loop { 28 | let bytes_read = reader.read(buffer)?; 29 | 30 | if crate::unlikely(bytes_read == 0) { 31 | break; 32 | } 33 | 34 | writer.write_all(&buffer[..bytes_read])?; 35 | } 36 | 37 | Ok(()) 38 | } 39 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rs.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RS_ 2 | #define _RAR_RS_ 3 | 4 | #define MAXPAR 255 // Maximum parity data size. 5 | #define MAXPOL 512 // Maximum polynomial degree. 6 | 7 | class RSCoder 8 | { 9 | private: 10 | void gfInit(); 11 | int gfMult(int a,int b); 12 | void pnInit(); 13 | void pnMult(int *p1,int *p2,int *r); 14 | 15 | int gfExp[MAXPOL]; // Galois field exponents. 16 | int gfLog[MAXPAR+1]; // Galois field logarithms. 17 | 18 | int GXPol[MAXPOL*2]; // Generator polynomial g(x). 19 | 20 | int ErrorLocs[MAXPAR+1],ErrCount; 21 | int Dnm[MAXPAR+1]; 22 | 23 | int ParSize; // Parity bytes size and so the number of recovery volumes. 24 | int ELPol[MAXPOL]; // Error locator polynomial. 25 | bool FirstBlockDone; 26 | public: 27 | void Init(int ParSize); 28 | void Encode(byte *Data,int DataSize,byte *DestData); 29 | bool Decode(byte *Data,int DataSize,int *EraLoc,int EraSize); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RAROpenArchiveEx.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

HANDLE PASCAL RAROpenArchiveEx(struct RAROpenArchiveDataEx *ArchiveData)

11 | 12 |

Description

13 |

Open RAR archive and allocate memory structures. Replaces the obsolete 14 | RAROpenArchive providing more options 15 | and Unicode names support. 16 |

17 | 18 |

Parameters

19 | 20 | ArchiveData 21 |
22 | Points to RAROpenArchiveDataEx structure. 23 |
24 | 25 |

Return values

26 |
27 | Archive handle or NULL in case of error. 28 |
29 | 30 |

See also

31 |
32 | RAROpenArchiveDataEx structure. 33 |
34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /application/src/routes/api/system/stats/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod ws; 5 | 6 | mod get { 7 | use crate::{ 8 | response::{ApiResponse, ApiResponseResult}, 9 | routes::GetState, 10 | stats::SystemStats, 11 | }; 12 | use serde::Serialize; 13 | use utoipa::ToSchema; 14 | 15 | #[derive(ToSchema, Serialize)] 16 | pub struct Response<'a> { 17 | stats: &'a SystemStats, 18 | } 19 | 20 | #[utoipa::path(get, path = "/", responses( 21 | (status = OK, body = inline(Response)), 22 | ))] 23 | pub async fn route(state: GetState) -> ApiResponseResult { 24 | ApiResponse::json(Response { 25 | stats: &*state.stats_manager.get_stats().await, 26 | }) 27 | .ok() 28 | } 29 | } 30 | 31 | pub fn router(state: &State) -> OpenApiRouter { 32 | OpenApiRouter::new() 33 | .routes(routes!(get::route)) 34 | .nest("/ws", ws::router(state)) 35 | .with_state(state.clone()) 36 | } 37 | -------------------------------------------------------------------------------- /application/src/io/counting_writer.rs: -------------------------------------------------------------------------------- 1 | use std::sync::{ 2 | Arc, 3 | atomic::{AtomicU64, Ordering}, 4 | }; 5 | 6 | pub struct CountingWriter { 7 | inner: W, 8 | pub bytes_written: Arc, 9 | } 10 | 11 | impl CountingWriter { 12 | pub fn new_with_bytes_written(inner: W, bytes_written: Arc) -> Self { 13 | Self { 14 | inner, 15 | bytes_written, 16 | } 17 | } 18 | 19 | #[inline] 20 | pub fn into_inner(self) -> W { 21 | self.inner 22 | } 23 | } 24 | 25 | impl std::io::Write for CountingWriter { 26 | #[inline] 27 | fn write(&mut self, buf: &[u8]) -> std::io::Result { 28 | let bytes_written = self.inner.write(buf)?; 29 | self.bytes_written 30 | .fetch_add(bytes_written as u64, Ordering::Relaxed); 31 | Ok(bytes_written) 32 | } 33 | 34 | #[inline] 35 | fn flush(&mut self) -> std::io::Result<()> { 36 | self.inner.flush() 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/secpassword.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SECURE_PASSWORD_ 2 | #define _RAR_SECURE_PASSWORD_ 3 | 4 | // Store a password securely (if data encryption is provided by OS) 5 | // or obfuscated to make search for password in memory dump less trivial. 6 | class SecPassword 7 | { 8 | private: 9 | void Process(const wchar *Src,size_t SrcSize,wchar *Dst,size_t DstSize,bool Encode); 10 | 11 | std::vector Password = std::vector(MAXPASSWORD); 12 | bool PasswordSet; 13 | public: 14 | SecPassword(); 15 | ~SecPassword(); 16 | void Clean(); 17 | void Get(wchar *Psw,size_t MaxSize); 18 | void Get(std::wstring &Psw); 19 | void Set(const wchar *Psw); 20 | bool IsSet() {return PasswordSet;} 21 | size_t Length(); 22 | bool operator == (SecPassword &psw); 23 | }; 24 | 25 | 26 | void cleandata(void *data,size_t size); 27 | inline void cleandata(std::wstring &s) {cleandata(&s[0],s.size()*sizeof(s[0]));} 28 | void SecHideData(void *Data,size_t DataSize,bool Encode,bool CrossProcess); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/strlist.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_STRLIST_ 2 | #define _RAR_STRLIST_ 3 | 4 | class StringList 5 | { 6 | private: 7 | std::vector StringData; 8 | size_t CurPos; 9 | 10 | size_t StringsCount; 11 | 12 | size_t SaveCurPos[16],SavePosNumber; 13 | public: 14 | StringList(); 15 | void Reset(); 16 | // void AddStringA(const char *Str); 17 | void AddString(const wchar *Str); 18 | void AddString(const std::wstring &Str); 19 | // bool GetStringA(char *Str,size_t MaxLength); 20 | bool GetString(wchar *Str,size_t MaxLength); 21 | bool GetString(std::wstring &Str); 22 | bool GetString(wchar *Str,size_t MaxLength,int StringNum); 23 | bool GetString(std::wstring &Str,int StringNum); 24 | wchar* GetString(); 25 | bool GetString(wchar **Str); 26 | void Rewind(); 27 | size_t ItemsCount() {return StringsCount;}; 28 | size_t GetCharCount() {return StringData.size();} 29 | bool Search(const std::wstring &Str,bool CaseSensitive); 30 | void SavePosition(); 31 | void RestorePosition(); 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RAROpenArchive.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

HANDLE PASCAL RAROpenArchive(struct RAROpenArchiveData *ArchiveData)

11 | 12 |

Description

13 |

Open RAR archive and allocate memory structures.

14 |

This function is obsolete. It does not support Unicode names 15 | and does not allow to specify the callback function. It is recommended 16 | to use RAROpenArchiveEx instead.

17 | 18 |

Parameters

19 | 20 | ArchiveData 21 |
22 | Points to RAROpenArchiveData structure. 23 |
24 | 25 |

Return values

26 |
27 | Archive handle or NULL in case of error. 28 |
29 | 30 |

See also

31 |
32 | RAROpenArchiveData structure. 33 |
34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /unrar-rs/src/pathed/all.rs: -------------------------------------------------------------------------------- 1 | use std::path::{Path, PathBuf}; 2 | use widestring::{WideCStr, WideCString}; 3 | 4 | pub(crate) type RarString = WideCString; 5 | pub(crate) type RarStr = WideCStr; 6 | 7 | pub(crate) fn construct(path: &Path) -> RarString { 8 | WideCString::from_os_str(path).expect("Unexpected nul in path") 9 | } 10 | 11 | pub(crate) fn process_file( 12 | handle: *const unrar_sys::Handle, 13 | operation: i32, 14 | dest_path: Option<&RarStr>, 15 | dest_name: Option<&RarStr>, 16 | ) -> i32 { 17 | unsafe { 18 | unrar_sys::RARProcessFileW( 19 | handle, 20 | operation, 21 | dest_path 22 | .map(|path| path.as_ptr().cast()) 23 | .unwrap_or(std::ptr::null()), 24 | dest_name 25 | .map(|file| file.as_ptr().cast()) 26 | .unwrap_or(std::ptr::null()), 27 | ) 28 | } 29 | } 30 | 31 | pub(crate) fn preprocess_extract( 32 | base: Option<&Path>, 33 | _filename: &PathBuf, 34 | ) -> (Option, Option) { 35 | (base.map(construct), None) 36 | } 37 | -------------------------------------------------------------------------------- /unrar-rs/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/headers.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | void FileHeader::Reset(size_t SubDataSize) 4 | { 5 | SubData.resize(SubDataSize); 6 | BaseBlock::Reset(); 7 | FileHash.Init(HASH_NONE); 8 | mtime.Reset(); 9 | atime.Reset(); 10 | ctime.Reset(); 11 | SplitBefore=false; 12 | SplitAfter=false; 13 | 14 | UnknownUnpSize=0; 15 | 16 | SubFlags=0; // Important for RAR 3.0 subhead. 17 | 18 | CryptMethod=CRYPT_NONE; 19 | Encrypted=false; 20 | SaltSet=false; 21 | UsePswCheck=false; 22 | UseHashKey=false; 23 | Lg2Count=0; 24 | 25 | Solid=false; 26 | Dir=false; 27 | WinSize=0; 28 | Inherited=false; 29 | SubBlock=false; 30 | CommentInHeader=false; 31 | Version=false; 32 | LargeFile=false; 33 | 34 | RedirType=FSREDIR_NONE; 35 | DirTarget=false; 36 | UnixOwnerSet=false; 37 | } 38 | 39 | 40 | /* 41 | FileHeader& FileHeader::operator = (FileHeader &hd) 42 | { 43 | SubData.Reset(); 44 | memcpy(this,&hd,sizeof(*this)); 45 | SubData.CleanData(); 46 | SubData=hd.SubData; 47 | return *this; 48 | } 49 | */ 50 | 51 | 52 | void MainHeader::Reset() 53 | { 54 | *this={}; 55 | } 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Calagopus, 0x7d8 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/hardlinks.cpp: -------------------------------------------------------------------------------- 1 | bool ExtractHardlink(CommandData *Cmd,const std::wstring &NameNew,const std::wstring &NameExisting) 2 | { 3 | if (!FileExist(NameExisting)) 4 | { 5 | uiMsg(UIERROR_HLINKCREATE,NameNew); 6 | uiMsg(UIERROR_NOLINKTARGET); 7 | ErrHandler.SetErrorCode(RARX_CREATE); 8 | return false; 9 | } 10 | CreatePath(NameNew,true,Cmd->DisableNames); 11 | 12 | #ifdef _WIN_ALL 13 | bool Success=CreateHardLink(NameNew.c_str(),NameExisting.c_str(),NULL)!=0; 14 | if (!Success) 15 | { 16 | uiMsg(UIERROR_HLINKCREATE,NameNew); 17 | ErrHandler.SysErrMsg(); 18 | ErrHandler.SetErrorCode(RARX_CREATE); 19 | } 20 | return Success; 21 | #elif defined(_UNIX) 22 | std::string NameExistingA,NameNewA; 23 | WideToChar(NameExisting,NameExistingA); 24 | WideToChar(NameNew,NameNewA); 25 | bool Success=link(NameExistingA.c_str(),NameNewA.c_str())==0; 26 | if (!Success) 27 | { 28 | uiMsg(UIERROR_HLINKCREATE,NameNew); 29 | ErrHandler.SysErrMsg(); 30 | ErrHandler.SetErrorCode(RARX_CREATE); 31 | } 32 | return Success; 33 | #else 34 | return false; 35 | #endif 36 | } 37 | 38 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/find.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_FINDDATA_ 2 | #define _RAR_FINDDATA_ 3 | 4 | enum FINDDATA_FLAGS { 5 | FDDF_SECONDDIR=1 // Second encounter of same directory in SCAN_GETDIRSTWICE ScanTree mode. 6 | }; 7 | 8 | struct FindData 9 | { 10 | std::wstring Name; 11 | uint64 Size; 12 | uint FileAttr; 13 | bool IsDir; 14 | bool IsLink; 15 | RarTime mtime; 16 | RarTime ctime; 17 | RarTime atime; 18 | #ifdef _WIN_ALL 19 | FILETIME ftCreationTime; 20 | FILETIME ftLastAccessTime; 21 | FILETIME ftLastWriteTime; 22 | #endif 23 | uint Flags; 24 | bool Error; 25 | }; 26 | 27 | class FindFile 28 | { 29 | private: 30 | #ifdef _WIN_ALL 31 | static HANDLE Win32Find(HANDLE hFind,const std::wstring &Mask,FindData *fd); 32 | #endif 33 | 34 | std::wstring FindMask; 35 | bool FirstCall; 36 | #ifdef _WIN_ALL 37 | HANDLE hFind; 38 | #else 39 | DIR *dirp; 40 | #endif 41 | public: 42 | FindFile(); 43 | ~FindFile(); 44 | void SetMask(const std::wstring &Mask); 45 | bool Next(FindData *fd,bool GetSymLink=false); 46 | static bool FastFind(const std::wstring &FindMask,FindData *fd,bool GetSymLink=false); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARCloseArchive.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

int PASCAL RARCloseArchive(HANDLE hArcData)

11 | 12 |

Description

13 |

14 | Close RAR archive and release allocated memory. It must be called when 15 | archive processing is finished, even if the archive processing was stopped 16 | due to an error.

17 | 18 |

Parameters

19 | 20 | hArcData 21 |
22 | This parameter should contain the archive handle obtained from 23 | RAROpenArchive or 24 | RAROpenArchiveEx function call. 25 |
26 | 27 |

Return values

28 |
29 | 30 | 31 | 32 |
0Success
ERAR_ECLOSEArchive close error
33 |
34 | 35 |

See also

36 |
37 | RAROpenArchiveEx function. 38 |
39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /unrar-rs/src/pathed/linux.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::{CStr, CString}; 2 | use std::path::{Path, PathBuf}; 3 | 4 | pub(crate) type RarString = CString; 5 | pub(crate) type RarStr = CStr; 6 | 7 | pub(crate) fn construct>(path: P) -> RarString { 8 | CString::new(path.as_ref().as_os_str().as_encoded_bytes()).unwrap() 9 | } 10 | 11 | pub(crate) fn process_file( 12 | handle: *const unrar_sys::Handle, 13 | operation: i32, 14 | dest_path: Option<&RarStr>, 15 | dest_name: Option<&RarStr>, 16 | ) -> i32 { 17 | unsafe { 18 | unrar_sys::RARProcessFile( 19 | handle, 20 | operation, 21 | dest_path 22 | .map(|path| path.as_ptr().cast()) 23 | .unwrap_or(std::ptr::null()), 24 | dest_name 25 | .map(|file| file.as_ptr().cast()) 26 | .unwrap_or(std::ptr::null()), 27 | ) 28 | } 29 | } 30 | 31 | pub(crate) fn preprocess_extract( 32 | base: Option<&Path>, 33 | filename: &PathBuf, 34 | ) -> (Option, Option) { 35 | ( 36 | None, 37 | Some(construct(base.unwrap_or(".".as_ref()).join(filename))), 38 | ) 39 | } 40 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARGetDllVersion.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

int PASCAL RARGetDllVersion()

11 | 12 |

Description

13 | 14 | Returns API version. 15 | 16 |

Parameters

17 | 18 | None. 19 | 20 |

Return values

21 |

Returns an integer value denoting UnRAR.dll API version, which is also 22 | defined in unrar.h as RAR_DLL_VERSION. API version number is incremented 23 | only in case of noticeable changes in UnRAR.dll API. Do not confuse it 24 | with version of UnRAR.dll stored in DLL resources, which is incremented 25 | with every DLL rebuild.

26 | 27 |

If RARGetDllVersion() returns a value lower than UnRAR.dll, which your 28 | application was designed for, it may indicate that DLL version is too old 29 | and it may fail to provide all necessary functions to your application.

30 | 31 |

This function is missing in very old versions of UnRAR.dll, 32 | so it is safer to use LoadLibrary and GetProcAddress to access it.

33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rarvm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_VM_ 2 | #define _RAR_VM_ 3 | 4 | #define VM_MEMSIZE 0x40000 5 | #define VM_MEMMASK (VM_MEMSIZE-1) 6 | 7 | enum VM_StandardFilters { 8 | VMSF_NONE, VMSF_E8, VMSF_E8E9, VMSF_ITANIUM, VMSF_RGB, VMSF_AUDIO, 9 | VMSF_DELTA 10 | }; 11 | 12 | struct VM_PreparedProgram 13 | { 14 | VM_PreparedProgram() 15 | { 16 | FilteredDataSize=0; 17 | Type=VMSF_NONE; 18 | } 19 | VM_StandardFilters Type; 20 | uint InitR[7]; 21 | byte *FilteredData; 22 | uint FilteredDataSize; 23 | }; 24 | 25 | class RarVM 26 | { 27 | private: 28 | bool ExecuteStandardFilter(VM_StandardFilters FilterType); 29 | uint FilterItanium_GetBits(byte *Data,uint BitPos,uint BitCount); 30 | void FilterItanium_SetBits(byte *Data,uint BitField,uint BitPos,uint BitCount); 31 | 32 | byte *Mem; 33 | uint R[8]; 34 | public: 35 | RarVM(); 36 | ~RarVM(); 37 | void Init(); 38 | void Prepare(byte *Code,uint CodeSize,VM_PreparedProgram *Prg); 39 | void Execute(VM_PreparedProgram *Prg); 40 | void SetMemory(size_t Pos,byte *Data,size_t DataSize); 41 | static uint ReadData(BitInput &Inp); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /application/src/utils.rs: -------------------------------------------------------------------------------- 1 | pub fn draw_progress_bar(width: usize, current: f64, total: f64) -> String { 2 | let progress_percentage = (current / total) * 100.0; 3 | let formatted_percentage = if progress_percentage.is_nan() { 4 | "0.00%" 5 | } else { 6 | &format!("{:.2}%", progress_percentage) 7 | }; 8 | 9 | let completed_width = std::cmp::min( 10 | (progress_percentage / 100.0 * width as f64).round() as usize, 11 | width, 12 | ); 13 | let remaining_width = width - completed_width; 14 | 15 | let bar = if completed_width == width { 16 | "=".repeat(width) 17 | } else { 18 | format!( 19 | "{}{}{}", 20 | "=".repeat(completed_width), 21 | ">", 22 | " ".repeat(remaining_width.saturating_sub(1)) 23 | ) 24 | }; 25 | 26 | format!("[{bar}] {formatted_percentage}") 27 | } 28 | 29 | #[inline] 30 | pub fn is_valid_utf8_slice(s: &[u8]) -> bool { 31 | let mut idx = s.len(); 32 | while idx > s.len().saturating_sub(4) { 33 | if str::from_utf8(&s[..idx]).is_ok() { 34 | return true; 35 | } 36 | 37 | idx -= 1; 38 | } 39 | 40 | false 41 | } 42 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/system.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SYSTEM_ 2 | #define _RAR_SYSTEM_ 3 | 4 | #ifdef _WIN_ALL 5 | #ifndef BELOW_NORMAL_PRIORITY_CLASS 6 | #define BELOW_NORMAL_PRIORITY_CLASS 0x00004000 7 | #define ABOVE_NORMAL_PRIORITY_CLASS 0x00008000 8 | #endif 9 | #ifndef PROCESS_MODE_BACKGROUND_BEGIN 10 | #define PROCESS_MODE_BACKGROUND_BEGIN 0x00100000 11 | #define PROCESS_MODE_BACKGROUND_END 0x00200000 12 | #endif 13 | #ifndef SHTDN_REASON_MAJOR_APPLICATION 14 | #define SHTDN_REASON_MAJOR_APPLICATION 0x00040000 15 | #define SHTDN_REASON_FLAG_PLANNED 0x80000000 16 | #define SHTDN_REASON_MINOR_MAINTENANCE 0x00000001 17 | #endif 18 | #endif 19 | 20 | void InitSystemOptions(int SleepTime); 21 | void SetPriority(int Priority); 22 | clock_t MonoClock(); 23 | void Wait(); 24 | bool EmailFile(const std::wstring &FileName,std::wstring MailToW); 25 | void Shutdown(POWER_MODE Mode); 26 | bool ShutdownCheckAnother(bool Open); 27 | 28 | #ifdef _WIN_ALL 29 | HMODULE WINAPI LoadSysLibrary(const wchar *Name); 30 | bool IsUserAdmin(); 31 | #endif 32 | 33 | #ifdef USE_SSE 34 | enum SSE_VERSION {SSE_NONE,SSE_SSE,SSE_SSE2,SSE_SSSE3,SSE_SSE41,SSE_AVX2}; 35 | SSE_VERSION GetSSEVersion(); 36 | extern SSE_VERSION _SSE_Version; 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rawread.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RAWREAD_ 2 | #define _RAR_RAWREAD_ 3 | 4 | class RawRead 5 | { 6 | private: 7 | std::vector Data; 8 | File *SrcFile; 9 | size_t DataSize; 10 | size_t ReadPos; 11 | CryptData *Crypt; 12 | public: 13 | RawRead(); 14 | RawRead(File *SrcFile); 15 | void Reset(); 16 | size_t Read(size_t Size); 17 | void Read(byte *SrcData,size_t Size); 18 | byte Get1(); 19 | ushort Get2(); 20 | uint Get4(); 21 | uint64 Get8(); 22 | uint64 GetV(); 23 | uint GetVSize(size_t Pos); 24 | size_t GetB(void *Field,size_t Size); 25 | void GetW(wchar *Field,size_t Size); 26 | uint GetCRC15(bool ProcessedOnly); 27 | uint GetCRC50(); 28 | byte* GetDataPtr() {return &Data[0];} 29 | size_t Size() {return DataSize;} 30 | size_t PaddedSize() {return Data.size()-DataSize;} 31 | size_t DataLeft() {return DataSize-ReadPos;} 32 | size_t GetPos() {return ReadPos;} 33 | void SetPos(size_t Pos) {ReadPos=Pos;} 34 | void Skip(size_t Size) {ReadPos+=Size;} 35 | void Rewind() {SetPos(0);} 36 | void SetCrypt(CryptData *Crypt) {RawRead::Crypt=Crypt;} 37 | }; 38 | 39 | uint64 RawGetV(const byte *Data,uint &ReadPos,uint DataSize,bool &Overflow); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /application/src/server/filesystem/limiter/none.rs: -------------------------------------------------------------------------------- 1 | pub async fn setup( 2 | filesystem: &crate::server::filesystem::Filesystem, 3 | ) -> Result<(), std::io::Error> { 4 | tracing::debug!( 5 | path = %filesystem.base_path.display(), 6 | "setting up no disk limiter for volume" 7 | ); 8 | 9 | tokio::fs::create_dir_all(&filesystem.base_path).await?; 10 | 11 | Ok(()) 12 | } 13 | 14 | pub async fn attach( 15 | filesystem: &crate::server::filesystem::Filesystem, 16 | ) -> Result<(), std::io::Error> { 17 | tracing::debug!( 18 | path = %filesystem.base_path.display(), 19 | "attaching no disk limiter for volume" 20 | ); 21 | 22 | Ok(()) 23 | } 24 | 25 | pub async fn disk_usage( 26 | filesystem: &crate::server::filesystem::Filesystem, 27 | ) -> Result { 28 | Ok(filesystem 29 | .disk_usage_cached 30 | .load(std::sync::atomic::Ordering::Relaxed)) 31 | } 32 | 33 | pub async fn update_disk_limit( 34 | _filesystem: &crate::server::filesystem::Filesystem, 35 | _limit: u64, 36 | ) -> Result<(), std::io::Error> { 37 | Ok(()) 38 | } 39 | 40 | pub async fn destroy( 41 | filesystem: &crate::server::filesystem::Filesystem, 42 | ) -> Result<(), std::io::Error> { 43 | tokio::fs::remove_dir_all(&filesystem.base_path).await 44 | } 45 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/files/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::router::OpenApiRouter; 3 | 4 | mod chmod; 5 | mod compress; 6 | mod contents; 7 | mod copy; 8 | mod create_directory; 9 | mod decompress; 10 | mod delete; 11 | mod fingerprints; 12 | mod list; 13 | mod list_directory; 14 | mod operations; 15 | mod pull; 16 | mod rename; 17 | mod search; 18 | mod write; 19 | 20 | pub fn router(state: &State) -> OpenApiRouter { 21 | OpenApiRouter::new() 22 | .nest("/contents", contents::router(state)) 23 | .nest("/list-directory", list_directory::router(state)) 24 | .nest("/list", list::router(state)) 25 | .nest("/rename", rename::router(state)) 26 | .nest("/copy", copy::router(state)) 27 | .nest("/write", write::router(state)) 28 | .nest("/create-directory", create_directory::router(state)) 29 | .nest("/delete", delete::router(state)) 30 | .nest("/chmod", chmod::router(state)) 31 | .nest("/search", search::router(state)) 32 | .nest("/fingerprints", fingerprints::router(state)) 33 | .nest("/pull", pull::router(state)) 34 | .nest("/compress", compress::router(state)) 35 | .nest("/decompress", decompress::router(state)) 36 | .nest("/operations", operations::router(state)) 37 | .with_state(state.clone()) 38 | } 39 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/getbits.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | BitInput::BitInput(bool AllocBuffer) 4 | { 5 | ExternalBuffer=false; 6 | if (AllocBuffer) 7 | { 8 | // getbits*() attempt to read data from InAddr, ... InAddr+8 positions. 9 | // So let's allocate 8 additional bytes for situation, when we need to 10 | // read only 1 byte from the last position of buffer and avoid a crash 11 | // from access to next 8 bytes, which contents we do not need. 12 | size_t BufSize=MAX_SIZE+8; 13 | InBuf=new byte[BufSize]; 14 | 15 | // Ensure that we get predictable results when accessing bytes in area 16 | // not filled with read data. 17 | memset(InBuf,0,BufSize); 18 | } 19 | else 20 | InBuf=nullptr; 21 | } 22 | 23 | 24 | BitInput::~BitInput() 25 | { 26 | if (!ExternalBuffer) 27 | delete[] InBuf; 28 | } 29 | 30 | 31 | void BitInput::faddbits(uint Bits) 32 | { 33 | // Function wrapped version of inline addbits to reduce the code size. 34 | addbits(Bits); 35 | } 36 | 37 | 38 | uint BitInput::fgetbits() 39 | { 40 | // Function wrapped version of inline getbits to reduce the code size. 41 | return getbits(); 42 | } 43 | 44 | 45 | void BitInput::SetExternalBuffer(byte *Buf) 46 | { 47 | if (InBuf!=NULL && !ExternalBuffer) 48 | delete[] InBuf; 49 | InBuf=Buf; 50 | ExternalBuffer=true; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/ws/deny.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::GetState, 8 | }; 9 | use serde::{Deserialize, Serialize}; 10 | use utoipa::ToSchema; 11 | 12 | #[derive(ToSchema, Deserialize)] 13 | pub struct Payload { 14 | jtis: Vec, 15 | } 16 | 17 | #[derive(ToSchema, Serialize)] 18 | struct Response {} 19 | 20 | #[utoipa::path(post, path = "/", responses( 21 | (status = OK, body = inline(Response)), 22 | ), params( 23 | ( 24 | "server" = uuid::Uuid, 25 | description = "The server uuid", 26 | example = "123e4567-e89b-12d3-a456-426614174000", 27 | ), 28 | ), request_body = inline(Payload))] 29 | pub async fn route( 30 | state: GetState, 31 | axum::Json(data): axum::Json, 32 | ) -> ApiResponseResult { 33 | for jti in data.jtis { 34 | state.config.jwt.deny(jti).await; 35 | } 36 | 37 | ApiResponse::json(Response {}).ok() 38 | } 39 | } 40 | 41 | pub fn router(state: &State) -> OpenApiRouter { 42 | OpenApiRouter::new() 43 | .routes(routes!(post::route)) 44 | .with_state(state.clone()) 45 | } 46 | -------------------------------------------------------------------------------- /application/src/routes/mod.rs: -------------------------------------------------------------------------------- 1 | use bollard::Docker; 2 | use serde::Serialize; 3 | use std::{sync::Arc, time::Instant}; 4 | use utoipa::ToSchema; 5 | use utoipa_axum::router::OpenApiRouter; 6 | 7 | pub mod api; 8 | mod download; 9 | mod upload; 10 | 11 | pub struct AppState { 12 | pub config: Arc, 13 | pub start_time: Instant, 14 | pub version: String, 15 | 16 | pub docker: Arc, 17 | pub stats_manager: Arc, 18 | pub server_manager: Arc, 19 | pub backup_manager: Arc, 20 | } 21 | 22 | #[derive(ToSchema, Serialize)] 23 | pub struct ApiError<'a> { 24 | pub error: &'a str, 25 | } 26 | 27 | impl<'a> ApiError<'a> { 28 | #[inline] 29 | pub fn new(error: &'a str) -> Self { 30 | Self { error } 31 | } 32 | 33 | #[inline] 34 | pub fn to_json(&self) -> serde_json::Value { 35 | serde_json::to_value(self).unwrap() 36 | } 37 | } 38 | 39 | pub type State = Arc; 40 | pub type GetState = axum::extract::State; 41 | 42 | pub fn router(state: &State) -> OpenApiRouter { 43 | OpenApiRouter::new() 44 | .nest("/download", download::router(state)) 45 | .nest("/upload", upload::router(state)) 46 | .nest("/api", api::router(state)) 47 | .with_state(state.clone()) 48 | } 49 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | resolver = "3" 3 | members = ["application", "unrar-rs"] 4 | default-members = ["application"] 5 | 6 | [workspace.dependencies] 7 | anyhow = "1.0.98" 8 | axum = { version = "0.8.1", features = ["http2", "ws", "multipart"] } 9 | axum-server = { version = "0.8.0", features = ["tls-rustls"] } 10 | axum-extra = { version = "0.12.1", features = ["query", "typed-header"] } 11 | bollard = "0.18.1" 12 | serde = { version = "1.0.138", features = ["derive"] } 13 | serde_json = { version = "1.0.139", features = ["preserve_order"] } 14 | utoipa = { version = "5.4.0", features = ["axum_extras", "preserve_order", "chrono", "indexmap", "uuid"] } 15 | utoipa-axum = "0.2.0" 16 | reqwest = { version = "0.12.12", default-features = false, features = ["hickory-dns", "rustls-tls", "json", "multipart", "stream"] } 17 | tokio = { version = "1.43.0", features = ["full"] } 18 | chrono = { version = "0.4.40", features = ["serde"] } 19 | futures-util = "0.3.31" 20 | tokio-util = { version = "0.7.15", features = ["full"] } 21 | uuid = { version = "1.16.0", features = ["serde", "v4"] } 22 | rand = "0.9.1" 23 | 24 | [profile.dev.package."*"] 25 | opt-level = 3 26 | 27 | [profile.dev] 28 | debug = false 29 | 30 | [profile.release.package."*"] 31 | opt-level = "s" 32 | codegen-units = 1 33 | strip = "symbols" 34 | 35 | [profile.release] 36 | opt-level = "s" 37 | lto = "fat" 38 | codegen-units = 1 39 | strip = "symbols" 40 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/Introduction.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

UnRAR.dll is Windows dynamic-link library, which provides file extraction. 11 | from RAR archives. It is available both as 32-bit (unrar.dll) and 64-bit x64 12 | (unrar64.dll) versions.

13 | 14 |

You can find samples of UnRAR.dll use in "Examples" folder. 15 | All samples except C sample (UnRDLL.c) are contributed by unrar.dll users. 16 | We at rarlab.com created and tested only UnRDLL.c sample.

17 | 18 |

Brief scenario of unrar.dll use includes the call of 19 | RAROpenArchiveEx to open an archive, 20 | RARReadHeaderEx to read archive headers, 21 | RARProcessFileW to process read header 22 | and RARCloseArchive to close the archive 23 | and free all previously allocated objects.

24 | 25 |

If you use this library in Unix, you may need to call 26 | setlocale(LC_CTYPE, "") in your application, so Unicode conversion functions 27 | work properly. 28 | 29 |

Please read the functions description 30 | and look into source code in "Examples" folder for more details.

31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARReadHeaderEx.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

int PASCAL RARReadHeaderEx(HANDLE hArcData,struct RARHeaderDataEx *HeaderData)

11 | 12 |

Description

13 |

Read a file header from archive.

14 | 15 | 16 |

Parameters

17 | 18 | hArcData 19 |
20 | This parameter should contain the archive handle obtained from 21 | RAROpenArchive or 22 | RAROpenArchiveEx function call. 23 |
24 | 25 | HeaderData 26 |
27 | Points to RARHeaderDataEx structure. 28 |
29 | 30 |

Return values

31 |
32 | 33 | 34 | 35 | 36 | 38 | 39 |
0Success
ERAR_END_ARCHIVEEnd of archive
ERAR_BAD_DATAFile header broken
ERAR_MISSING_PASSWORDPassword was not provided 37 | for encrypted file header
ERAR_EOPEN Volume open error
40 |
41 | 42 |

See also

43 |
44 | RARHeaderDataEx structure. 45 |
46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rartypes.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_TYPES_ 2 | #define _RAR_TYPES_ 3 | 4 | #include 5 | 6 | typedef uint8_t byte; // Unsigned 8 bits. 7 | typedef uint16_t ushort; // Preferably 16 bits, but can be more. 8 | typedef unsigned int uint; // Preferably 32 bits, likely can be more. 9 | typedef uint32_t uint32; // 32 bits exactly. 10 | typedef int32_t int32; // Signed 32 bits exactly. 11 | typedef uint64_t uint64; // 64 bits exactly. 12 | typedef int64_t int64; // Signed 64 bits exactly. 13 | typedef wchar_t wchar; // Unicode character 14 | 15 | // Get lowest 16 bits. 16 | #define GET_SHORT16(x) (sizeof(ushort)==2 ? (ushort)(x):((x)&0xffff)) 17 | 18 | // Make 64 bit integer from two 32 bit. 19 | #define INT32TO64(high,low) ((((uint64)(high))<<32)+((uint64)low)) 20 | 21 | // Maximum int64 value. 22 | #define MAX_INT64 int64(INT32TO64(0x7fffffff,0xffffffff)) 23 | 24 | // Special int64 value, large enough to never be found in real life 25 | // and small enough to fit to both signed and unsigned 64-bit ints. 26 | // We use it in situations, when we need to indicate that parameter 27 | // is not defined and probably should be calculated inside of function. 28 | // Lower part is intentionally 0x7fffffff, not 0xffffffff, to make it 29 | // compatible with 32 bit int64 if 64 bit type is not supported. 30 | #define INT64NDF INT32TO64(0x7fffffff,0x7fffffff) 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARSetPassword.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

void PASCAL RARSetPassword(HANDLE hArcData,char *Password)

11 | 12 |

Description

13 | 14 |

Set a password to decrypt files.

15 | 16 |

This function does not allow to process archives with encrypted headers. 17 | It can be used only for archives with encrypted file data and unencrypted 18 | headers. So the recommended way to set a password is UCM_NEEDPASSWORDW 19 | message in user defined callback function. 20 | Unlike RARSetPassword, UCM_NEEDPASSWORDW can be used for all types of 21 | encrypted RAR archives.

22 | 23 |

Parameters

24 | 25 | hArcData 26 |
27 | This parameter should contain the archive handle obtained from 28 | RAROpenArchive or 29 | RAROpenArchiveEx function call. 30 |
31 | 32 | Password 33 |
34 | Zero terminated string containing a password. 35 |
36 | 37 |

Return values

38 |
39 | None. 40 |
41 | 42 |

See also

43 |
44 | User defined callback function 45 |
46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/coder.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | inline byte RangeCoder::GetChar() 4 | { 5 | return UnpackRead->GetChar(); 6 | } 7 | 8 | 9 | void RangeCoder::InitDecoder(Unpack *UnpackRead) 10 | { 11 | RangeCoder::UnpackRead=UnpackRead; 12 | 13 | low=code=0; 14 | range=0xffffffff; 15 | for (uint i = 0; i < 4; i++) 16 | code=(code << 8) | GetChar(); 17 | } 18 | 19 | 20 | // (int) cast before "low" added only to suppress compiler warnings. 21 | #define ARI_DEC_NORMALIZE(code,low,range,read) \ 22 | { \ 23 | while ((low^(low+range))GetChar(); \ 26 | range <<= 8; \ 27 | low <<= 8; \ 28 | } \ 29 | } 30 | 31 | 32 | inline int RangeCoder::GetCurrentCount() 33 | { 34 | return (code-low)/(range /= SubRange.scale); 35 | } 36 | 37 | 38 | inline uint RangeCoder::GetCurrentShiftCount(uint SHIFT) 39 | { 40 | return (code-low)/(range >>= SHIFT); 41 | } 42 | 43 | 44 | inline void RangeCoder::Decode() 45 | { 46 | low += range*SubRange.LowCount; 47 | range *= SubRange.HighCount-SubRange.LowCount; 48 | } 49 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/logs.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod get { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{GetState, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::extract::Query; 10 | use serde::{Deserialize, Serialize}; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Deserialize)] 14 | pub struct Params { 15 | size: Option, 16 | } 17 | 18 | #[derive(ToSchema, Serialize)] 19 | struct Response { 20 | data: String, 21 | } 22 | 23 | #[utoipa::path(get, path = "/", responses( 24 | (status = OK, body = inline(Response)), 25 | ), params( 26 | ( 27 | "server" = uuid::Uuid, 28 | description = "The server uuid", 29 | example = "123e4567-e89b-12d3-a456-426614174000", 30 | ), 31 | ))] 32 | pub async fn route( 33 | state: GetState, 34 | server: GetServer, 35 | Query(data): Query, 36 | ) -> ApiResponseResult { 37 | let size = data.size.unwrap_or(100).min(100); 38 | let log = server.read_log(&state.docker, size).await?; 39 | 40 | ApiResponse::json(Response { data: log }).ok() 41 | } 42 | } 43 | 44 | pub fn router(state: &State) -> OpenApiRouter { 45 | OpenApiRouter::new() 46 | .routes(routes!(get::route)) 47 | .with_state(state.clone()) 48 | } 49 | -------------------------------------------------------------------------------- /unrar-rs/examples/read_named.rs: -------------------------------------------------------------------------------- 1 | use unrar::{Archive, UnrarResult}; 2 | 3 | fn main() -> UnrarResult<()> { 4 | // Basic args parsing 5 | // Usage: cargo run --example extract_named 6 | let mut args = std::env::args_os().skip(1); 7 | let file = args.next().unwrap_or("archive.rar".into()); 8 | let name = args.next().unwrap_or("README.md".into()); 9 | 10 | let mut archive = Archive::new(&file).open_for_processing().unwrap(); 11 | while let Some(header) = archive.read_header()? { 12 | archive = if header.entry().filename.as_os_str() == name { 13 | let (data, rest) = header.read()?; 14 | drop(rest); // close the archive 15 | match std::str::from_utf8(&data) { 16 | Ok(content) => { 17 | if content.len() <= 10000 { 18 | print!("{content}"); 19 | std::process::exit(0); 20 | } else { 21 | eprintln!( 22 | "error: file too long for this example (is: {}, max: 10000)", 23 | content.len() 24 | ); 25 | std::process::exit(1); 26 | } 27 | } 28 | Err(_) => { 29 | eprintln!("error: non-utf8 content"); 30 | std::process::exit(1); 31 | } 32 | } 33 | } else { 34 | header.skip()? 35 | } 36 | } 37 | Ok(()) 38 | } 39 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/crypt1.cpp: -------------------------------------------------------------------------------- 1 | void CryptData::SetKey13(const char *Password) 2 | { 3 | Key13[0]=Key13[1]=Key13[2]=0; 4 | for (size_t I=0;Password[I]!=0;I++) 5 | { 6 | byte P=Password[I]; 7 | Key13[0]+=P; 8 | Key13[1]^=P; 9 | Key13[2]+=P; 10 | Key13[2]=(byte)rotls(Key13[2],1,8); 11 | } 12 | } 13 | 14 | 15 | void CryptData::SetKey15(const char *Password) 16 | { 17 | InitCRC32(CRCTab); 18 | uint PswCRC=CRC32(0xffffffff,Password,strlen(Password)); 19 | Key15[0]=PswCRC&0xffff; 20 | Key15[1]=(PswCRC>>16)&0xffff; 21 | Key15[2]=Key15[3]=0; 22 | for (size_t I=0;Password[I]!=0;I++) 23 | { 24 | byte P=Password[I]; 25 | Key15[2]^=P^CRCTab[P]; 26 | Key15[3]+=ushort(P+(CRCTab[P]>>16)); 27 | } 28 | } 29 | 30 | 31 | void CryptData::SetCmt13Encryption() 32 | { 33 | Method=CRYPT_RAR13; 34 | Key13[0]=0; 35 | Key13[1]=7; 36 | Key13[2]=77; 37 | } 38 | 39 | 40 | void CryptData::Decrypt13(byte *Data,size_t Count) 41 | { 42 | while (Count--) 43 | { 44 | Key13[1]+=Key13[2]; 45 | Key13[0]+=Key13[1]; 46 | *Data-=Key13[0]; 47 | Data++; 48 | } 49 | } 50 | 51 | 52 | void CryptData::Crypt15(byte *Data,size_t Count) 53 | { 54 | while (Count--) 55 | { 56 | Key15[0]+=0x1234; 57 | Key15[1]^=CRCTab[(Key15[0] & 0x1fe)>>1]; 58 | Key15[2]-=ushort(CRCTab[(Key15[0] & 0x1fe)>>1]>>16); 59 | Key15[0]^=Key15[2]; 60 | Key15[3]=rotrs(Key15[3]&0xffff,1,16)^Key15[1]; 61 | Key15[3]=rotrs(Key15[3]&0xffff,1,16); 62 | Key15[0]^=Key15[3]; 63 | *Data^=(byte)(Key15[0]>>8); 64 | Data++; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/index.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 |

UnRAR.dll decompression library

10 | 11 |

Introduction

12 | 13 | 14 |

Functions

15 |
16 | RAROpenArchive
17 | RAROpenArchiveEx
18 | RARCloseArchive
19 | RARReadHeader
20 | RARReadHeaderEx
21 | RARProcessFile
22 | RARProcessFileW
23 | RARSetCallback
24 | RARSetChangeVolProc
25 | RARSetProcessDataProc
26 | RARSetPassword
27 | RARGetDllVersion
28 |
29 | 30 |

Structures

31 |
32 | RAROpenArchiveData
33 | RAROpenArchiveDataEx
34 | RARHeaderData
35 | RARHeaderDataEx
36 |
37 | 38 |

Format

39 |
40 | RAR5Format
41 |
42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/install/abort.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::http::StatusCode; 10 | use serde::Serialize; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Serialize)] 14 | struct Response {} 15 | 16 | #[utoipa::path(post, path = "/", responses( 17 | (status = ACCEPTED, body = inline(Response)), 18 | (status = CONFLICT, body = ApiError), 19 | ), params( 20 | ( 21 | "server" = uuid::Uuid, 22 | description = "The server uuid", 23 | example = "123e4567-e89b-12d3-a456-426614174000", 24 | ), 25 | ))] 26 | pub async fn route(server: GetServer) -> ApiResponseResult { 27 | let installer = match server.installer.write().await.take() { 28 | Some(installer) => installer, 29 | None => { 30 | return ApiResponse::error("server is not installing") 31 | .with_status(StatusCode::CONFLICT) 32 | .ok(); 33 | } 34 | }; 35 | 36 | installer.abort(); 37 | 38 | ApiResponse::json(Response {}) 39 | .with_status(StatusCode::ACCEPTED) 40 | .ok() 41 | } 42 | } 43 | 44 | pub fn router(state: &State) -> OpenApiRouter { 45 | OpenApiRouter::new() 46 | .routes(routes!(post::route)) 47 | .with_state(state.clone()) 48 | } 49 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARReadHeader.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

int PASCAL RARReadHeader(HANDLE hArcData,struct RARHeaderData *HeaderData)

11 | 12 |

Description

13 |

Read a file header from archive.

14 |

This function is obsolete. It does not support Unicode names 15 | and 64 bit file sizes. It is recommended to use 16 | RARReadHeaderEx instead.

17 | 18 | 19 |

Parameters

20 | 21 | hArcData 22 |
23 | This parameter should contain the archive handle obtained from 24 | RAROpenArchive or 25 | RAROpenArchiveEx function call. 26 |
27 | 28 | HeaderData 29 |
30 | Points to RARHeaderData structure. 31 |
32 | 33 |

Return values

34 |
35 | 36 | 37 | 38 | 39 | 41 | 42 |
0Success
ERAR_END_ARCHIVEEnd of archive
ERAR_BAD_DATAFile header broken
ERAR_MISSING_PASSWORDPassword was not provided 40 | for encrypted file header
ERAR_EOPEN Volume open error
43 |
44 | 45 |

See also

46 |
47 | RARHeaderData structure. 48 |
49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /unrar-rs/examples/lister.rs: -------------------------------------------------------------------------------- 1 | use std::io::Write; 2 | use unrar::{Archive, ListSplit}; 3 | 4 | fn main() { 5 | // Basic args parsing 6 | // Usage: cargo run --example lister path/to/archive.rar 7 | let args = std::env::args(); 8 | let mut stderr = std::io::stderr(); 9 | let file = args.skip(1).next().unwrap_or_else(|| { 10 | writeln!(&mut stderr, "Please pass an archive as argument!").unwrap(); 11 | std::process::exit(1) 12 | }); 13 | 14 | let mut possible_error = None; 15 | 16 | match Archive::new(&file).break_open::(Some(&mut possible_error)) { 17 | Ok(archive) => { 18 | if let Some(error) = possible_error { 19 | // If the error's data field holds an OpenArchive, an error occurred while opening, 20 | // the archive is partly broken (e.g. broken header), but is still readable from. 21 | // In this example, we are still going to use the archive and list its contents. 22 | writeln!(&mut stderr, "Error: {}, continuing.", error).unwrap(); 23 | } 24 | let mut stderr = std::io::stderr(); 25 | for entry in archive { 26 | match entry { 27 | Ok(e) => println!("{}", e), 28 | Err(err) => writeln!(&mut stderr, "Error: {}", err).unwrap(), 29 | } 30 | } 31 | } 32 | Err(e) => { 33 | // the error we passed in is always None 34 | // if the archive could not be read at all 35 | debug_assert_eq!(possible_error, None); 36 | writeln!(&mut stderr, "Error: {}", e).unwrap(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /application/src/server/filesystem/archive/multi_reader.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | fs::File, 3 | io::{Read, Seek, SeekFrom}, 4 | os::unix::fs::FileExt, 5 | sync::Arc, 6 | }; 7 | 8 | #[derive(Clone)] 9 | pub struct MultiReader { 10 | file: Arc, 11 | file_size: u64, 12 | offset: u64, 13 | } 14 | 15 | impl MultiReader { 16 | pub fn new(file: Arc) -> std::io::Result { 17 | let file_size = file.metadata()?.len(); 18 | 19 | Ok(MultiReader { 20 | file, 21 | file_size, 22 | offset: 0, 23 | }) 24 | } 25 | } 26 | 27 | impl Read for MultiReader { 28 | fn read(&mut self, buf: &mut [u8]) -> std::io::Result { 29 | let bytes_read = self.file.read_at(buf, self.offset)?; 30 | self.offset += bytes_read as u64; 31 | 32 | Ok(bytes_read) 33 | } 34 | } 35 | 36 | impl Seek for MultiReader { 37 | fn seek(&mut self, pos: SeekFrom) -> std::io::Result { 38 | self.offset = match pos { 39 | SeekFrom::Start(offset) => offset, 40 | SeekFrom::End(offset) => { 41 | if offset >= 0 { 42 | self.file_size.saturating_add(offset as u64) 43 | } else { 44 | self.file_size.saturating_sub((-offset) as u64) 45 | } 46 | } 47 | SeekFrom::Current(offset) => { 48 | if offset >= 0 { 49 | self.offset.saturating_add(offset as u64) 50 | } else { 51 | self.offset.saturating_sub((-offset) as u64) 52 | } 53 | } 54 | }; 55 | 56 | Ok(self.offset) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rardefs.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_DEFS_ 2 | #define _RAR_DEFS_ 3 | 4 | #define Min(x,y) (((x)<(y)) ? (x):(y)) 5 | #define Max(x,y) (((x)>(y)) ? (x):(y)) 6 | 7 | // Universal replacement of abs function. 8 | #define Abs(x) (((x)<0) ? -(x):(x)) 9 | 10 | #define ASIZE(x) (sizeof(x)/sizeof(x[0])) 11 | 12 | // MAXPASSWORD and MAXPASSWORD_RAR are expected to be multiple of 13 | // CRYPTPROTECTMEMORY_BLOCK_SIZE (16) for CryptProtectMemory in SecPassword. 14 | // We allow a larger MAXPASSWORD to unpack archives with lengthy passwords 15 | // in non-RAR formats in GUI versions. For RAR format we set MAXPASSWORD_RAR 16 | // to 128 for compatibility and because it is enough for AES-256. 17 | #define MAXPASSWORD 512 18 | #define MAXPASSWORD_RAR 128 19 | 20 | // Set some arbitrary sensible limit to maximum path length to prevent 21 | // the excessive memory allocation for dynamically allocated strings. 22 | #define MAXPATHSIZE 0x10000 23 | 24 | #define MAXSFXSIZE 0x200000 25 | 26 | #define MAXCMTSIZE 0x40000 27 | 28 | #ifdef _WIN_32 29 | #define DefSFXName L"default32.sfx" 30 | #else 31 | #define DefSFXName L"default.sfx" 32 | #endif 33 | #define DefSortListName L"rarfiles.lst" 34 | 35 | // Maximum dictionary allowed by compression. Can be less than 36 | // maximum dictionary supported by decompression. 37 | #define PACK_MAX_DICT 0x1000000000ULL // 64 GB. 38 | 39 | // Maximum dictionary allowed by decompression. 40 | #define UNPACK_MAX_DICT 0x1000000000ULL // 64 GB. 41 | 42 | 43 | #ifndef SFX_MODULE 44 | #define USE_QOPEN 45 | #endif 46 | 47 | // Produce the value, which is equal or larger than 'v' and aligned to 'a'. 48 | #define ALIGN_VALUE(v,a) (size_t(v) + ( (~size_t(v) + 1) & (a - 1) ) ) 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/uisilent.cpp: -------------------------------------------------------------------------------- 1 | // Purely user interface function. Gets and returns user input. 2 | UIASKREP_RESULT uiAskReplace(std::wstring &Name,int64 FileSize,RarTime *FileTime,uint Flags) 3 | { 4 | return UIASKREP_R_REPLACE; 5 | } 6 | 7 | 8 | 9 | 10 | void uiStartArchiveExtract(bool Extract,const std::wstring &ArcName) 11 | { 12 | } 13 | 14 | 15 | bool uiStartFileExtract(const std::wstring &FileName,bool Extract,bool Test,bool Skip) 16 | { 17 | return true; 18 | } 19 | 20 | 21 | void uiExtractProgress(int64 CurFileSize,int64 TotalFileSize,int64 CurSize,int64 TotalSize) 22 | { 23 | } 24 | 25 | 26 | void uiProcessProgress(const char *Command,int64 CurSize,int64 TotalSize) 27 | { 28 | } 29 | 30 | 31 | void uiMsgStore::Msg() 32 | { 33 | } 34 | 35 | 36 | bool uiGetPassword(UIPASSWORD_TYPE Type,const std::wstring &FileName, 37 | SecPassword *Password,CheckPassword *CheckPwd) 38 | { 39 | return false; 40 | } 41 | 42 | 43 | bool uiIsGlobalPasswordSet() 44 | { 45 | return false; 46 | } 47 | 48 | 49 | void uiAlarm(UIALARM_TYPE Type) 50 | { 51 | } 52 | 53 | 54 | bool uiIsAborted() 55 | { 56 | return false; 57 | } 58 | 59 | 60 | void uiGiveTick() 61 | { 62 | } 63 | 64 | 65 | bool uiDictLimit(CommandData *Cmd,const std::wstring &FileName,uint64 DictSize,uint64 MaxDictSize) 66 | { 67 | #ifdef RARDLL 68 | if (Cmd->Callback!=nullptr && 69 | Cmd->Callback(UCM_LARGEDICT,Cmd->UserData,(LPARAM)(DictSize/1024),(LPARAM)(MaxDictSize/1024))==1) 70 | return true; // Continue extracting if unrar.dll callback permits it. 71 | #endif 72 | return false; // Stop extracting. 73 | } 74 | 75 | 76 | #ifndef SFX_MODULE 77 | const wchar *uiGetMonthName(uint Month) 78 | { 79 | return L""; 80 | } 81 | #endif 82 | 83 | 84 | void uiEolAfterMsg() 85 | { 86 | } 87 | -------------------------------------------------------------------------------- /application/src/routes/api/system/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod config; 5 | mod logs; 6 | mod stats; 7 | mod upgrade; 8 | 9 | mod get { 10 | use crate::{ 11 | response::{ApiResponse, ApiResponseResult}, 12 | routes::GetState, 13 | }; 14 | use serde::Serialize; 15 | use std::sync::LazyLock; 16 | use utoipa::ToSchema; 17 | 18 | #[derive(ToSchema, Serialize)] 19 | struct Response<'a> { 20 | architecture: &'static str, 21 | cpu_count: usize, 22 | kernel_version: &'a str, 23 | os: &'static str, 24 | version: &'a str, 25 | } 26 | 27 | #[utoipa::path(get, path = "/", responses( 28 | (status = OK, body = inline(Response)), 29 | ))] 30 | pub async fn route(state: GetState) -> ApiResponseResult { 31 | static KERNEL_VERSION: LazyLock = LazyLock::new(|| { 32 | rustix::system::uname() 33 | .release() 34 | .to_string_lossy() 35 | .to_string() 36 | }); 37 | 38 | ApiResponse::json(Response { 39 | architecture: std::env::consts::ARCH, 40 | cpu_count: rayon::current_num_threads(), 41 | kernel_version: &KERNEL_VERSION, 42 | os: std::env::consts::OS, 43 | version: &state.version, 44 | }) 45 | .ok() 46 | } 47 | } 48 | 49 | pub fn router(state: &State) -> OpenApiRouter { 50 | OpenApiRouter::new() 51 | .routes(routes!(get::route)) 52 | .nest("/logs", logs::router(state)) 53 | .nest("/upgrade", upgrade::router(state)) 54 | .nest("/config", config::router(state)) 55 | .nest("/stats", stats::router(state)) 56 | .with_state(state.clone()) 57 | } 58 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rs16.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RS16_ 2 | #define _RAR_RS16_ 3 | 4 | class RSCoder16 5 | { 6 | private: 7 | static const uint gfSize=65535; // Galois field size. 8 | void gfInit(); // Galois field inititalization. 9 | inline uint gfAdd(uint a,uint b); // Addition in Galois field. 10 | inline uint gfMul(uint a,uint b); // Multiplication in Galois field. 11 | inline uint gfInv(uint a); // Inverse element in Galois field. 12 | uint *gfExp; // Galois field exponents. 13 | uint *gfLog; // Galois field logarithms. 14 | 15 | void MakeEncoderMatrix(); 16 | void MakeDecoderMatrix(); 17 | void InvertDecoderMatrix(); 18 | 19 | #ifdef USE_SSE 20 | #if defined(USE_SSE) && defined(__GNUC__) 21 | __attribute__((target("ssse3"))) 22 | #endif 23 | bool SSE_UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize); 24 | #endif 25 | 26 | bool Decoding; // If we are decoding or encoding data. 27 | uint ND; // Number of data units. 28 | uint NR; // Number of Reed-Solomon code units. 29 | uint NE; // Number of erasures. 30 | bool *ValidFlags; // Validity flags for data and ECC units. 31 | uint *MX; // Cauchy based coding or decoding matrix. 32 | 33 | uint *DataLog; // Buffer to store data logarithms for UpdateECC. 34 | size_t DataLogSize; 35 | 36 | public: 37 | RSCoder16(); 38 | ~RSCoder16(); 39 | 40 | bool Init(uint DataCount, uint RecCount, bool *ValidityFlags); 41 | #if 0 // We use only UpdateECC now. 42 | void Process(const uint *Data, uint *Out); 43 | #endif 44 | void UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/files/operations/_operation_.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod delete { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::{extract::Path, http::StatusCode}; 10 | use serde::Serialize; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Serialize)] 14 | struct Response {} 15 | 16 | #[utoipa::path(delete, path = "/", responses( 17 | (status = OK, body = inline(Response)), 18 | (status = NOT_FOUND, body = ApiError), 19 | ), params( 20 | ( 21 | "server" = uuid::Uuid, 22 | description = "The server uuid", 23 | example = "123e4567-e89b-12d3-a456-426614174000", 24 | ), 25 | ( 26 | "operation" = uuid::Uuid, 27 | description = "The operation uuid", 28 | example = "123e4567-e89b-12d3-a456-426614174000", 29 | ), 30 | ))] 31 | pub async fn route( 32 | server: GetServer, 33 | Path((_server, operation_id)): Path<(uuid::Uuid, uuid::Uuid)>, 34 | ) -> ApiResponseResult { 35 | if !server 36 | .filesystem 37 | .operations 38 | .abort_operation(operation_id) 39 | .await 40 | { 41 | return ApiResponse::error("operation not found") 42 | .with_status(StatusCode::NOT_FOUND) 43 | .ok(); 44 | } 45 | 46 | ApiResponse::json(Response {}).ok() 47 | } 48 | } 49 | 50 | pub fn router(state: &State) -> OpenApiRouter { 51 | OpenApiRouter::new() 52 | .routes(routes!(delete::route)) 53 | .with_state(state.clone()) 54 | } 55 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/qopen.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_QOPEN_ 2 | #define _RAR_QOPEN_ 3 | 4 | struct QuickOpenItem 5 | { 6 | byte *Header; 7 | size_t HeaderSize; 8 | uint64 ArcPos; 9 | QuickOpenItem *Next; 10 | }; 11 | 12 | 13 | class Archive; 14 | class RawRead; 15 | 16 | class QuickOpen 17 | { 18 | private: 19 | void Close(); 20 | 21 | 22 | uint ReadBuffer(); 23 | bool ReadRaw(RawRead &Raw); 24 | bool ReadNext(); 25 | 26 | Archive *Arc; 27 | bool WriteMode; 28 | 29 | QuickOpenItem *ListStart; 30 | QuickOpenItem *ListEnd; 31 | 32 | byte *Buf; // Read quick open data here. 33 | static const size_t MaxBufSize=0x10000; // Buf size, must be multiple of CRYPT_BLOCK_SIZE. 34 | size_t CurBufSize; // Current size of buffered data in write mode. 35 | #ifndef RAR_NOCRYPT // For shell extension. 36 | CryptData Crypt; 37 | #endif 38 | 39 | bool Loaded; 40 | uint64 QOHeaderPos; // Main QO header position. 41 | uint64 RawDataStart; // Start of QO data, just after the main header. 42 | uint64 RawDataSize; // Size of entire QO data. 43 | uint64 RawDataPos; // Current read position in QO data. 44 | size_t ReadBufSize; // Size of Buf data currently read from QO. 45 | size_t ReadBufPos; // Current read position in Buf data. 46 | std::vector LastReadHeader; 47 | uint64 LastReadHeaderPos; 48 | uint64 SeekPos; 49 | bool UnsyncSeekPos; // QOpen SeekPos does not match an actual file pointer. 50 | public: 51 | QuickOpen(); 52 | ~QuickOpen(); 53 | void Init(Archive *Arc,bool WriteMode); 54 | void Load(uint64 BlockPos); 55 | void Unload() { Loaded=false; } 56 | bool Read(void *Data,size_t Size,size_t &Result); 57 | bool Seek(int64 Offset,int Method); 58 | bool Tell(int64 *Pos); 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/match.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_MATCH_ 2 | #define _RAR_MATCH_ 3 | 4 | enum { 5 | MATCH_NAMES, // Paths are ignored. 6 | // Compares names only using wildcards. 7 | 8 | MATCH_SUBPATHONLY, // Paths must match either exactly or path in wildcard 9 | // must be present in the beginning of file path. 10 | // For example, "c:\path1\*" or "c:\path1" will match 11 | // "c:\path1\path2\file". 12 | // Names are not compared. 13 | 14 | MATCH_EXACT, // Paths must match exactly. 15 | // Names must match exactly. 16 | 17 | MATCH_ALLWILD, // Paths and names are compared using wildcards. 18 | // Unlike MATCH_SUBPATH, paths do not match subdirs 19 | // unless a wildcard tells so. 20 | 21 | MATCH_EXACTPATH, // Paths must match exactly. 22 | // Names are compared using wildcards. 23 | 24 | MATCH_SUBPATH, // Names must be the same, but path in mask is allowed 25 | // to be only a part of name path. In other words, 26 | // we match all files matching the file mask 27 | // in current folder and subfolders. 28 | 29 | MATCH_WILDSUBPATH // Works as MATCH_SUBPATH if file mask contains 30 | // wildcards and as MATCH_EXACTPATH otherwise. 31 | }; 32 | 33 | #define MATCH_MODEMASK 0x0000ffff 34 | #define MATCH_FORCECASESENSITIVE 0x80000000 35 | 36 | bool CmpName(const wchar *Wildcard,const wchar *Name,uint CmpMode); 37 | 38 | inline bool CmpName(const std::wstring &Wildcard,const std::wstring &Name,uint CmpMode) 39 | { 40 | return CmpName(Wildcard.c_str(),Name.c_str(),CmpMode); 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rar.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RARCOMMON_ 2 | #define _RAR_RARCOMMON_ 3 | 4 | #include "raros.hpp" 5 | #include "rartypes.hpp" 6 | #include "os.hpp" 7 | 8 | #ifdef RARDLL 9 | #include "dll.hpp" 10 | #endif 11 | 12 | #include "version.hpp" 13 | #include "rardefs.hpp" 14 | #include "rarlang.hpp" 15 | #include "rawint.hpp" 16 | #include "unicode.hpp" 17 | #include "errhnd.hpp" 18 | #include "secpassword.hpp" 19 | #include "strlist.hpp" 20 | #include "timefn.hpp" 21 | #include "sha1.hpp" 22 | #include "sha256.hpp" 23 | #include "blake2s.hpp" 24 | #include "hash.hpp" 25 | #include "options.hpp" 26 | #include "rijndael.hpp" 27 | #include "crypt.hpp" 28 | #include "headers5.hpp" 29 | #include "headers.hpp" 30 | #include "pathfn.hpp" 31 | #include "strfn.hpp" 32 | #ifdef _WIN_ALL 33 | #include "isnt.hpp" 34 | #endif 35 | #include "file.hpp" 36 | #include "crc.hpp" 37 | #include "filefn.hpp" 38 | #include "filestr.hpp" 39 | #include "find.hpp" 40 | #include "scantree.hpp" 41 | #include "getbits.hpp" 42 | #include "rdwrfn.hpp" 43 | #ifdef USE_QOPEN 44 | #include "qopen.hpp" 45 | #endif 46 | #include "archive.hpp" 47 | #include "match.hpp" 48 | #include "cmddata.hpp" 49 | #include "ui.hpp" 50 | #include "filcreat.hpp" 51 | #include "consio.hpp" 52 | #include "system.hpp" 53 | #include "log.hpp" 54 | #include "rawread.hpp" 55 | #include "encname.hpp" 56 | #include "resource.hpp" 57 | #include "compress.hpp" 58 | 59 | #include "rarvm.hpp" 60 | #include "model.hpp" 61 | 62 | #include "threadpool.hpp" 63 | 64 | #include "unpack.hpp" 65 | 66 | 67 | 68 | #include "extinfo.hpp" 69 | #include "extract.hpp" 70 | 71 | 72 | 73 | #include "list.hpp" 74 | 75 | 76 | #include "rs.hpp" 77 | #include "rs16.hpp" 78 | 79 | 80 | 81 | #include "recvol.hpp" 82 | #include "volume.hpp" 83 | #include "smallfn.hpp" 84 | 85 | #include "global.hpp" 86 | 87 | 88 | 89 | 90 | 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/files/pull/_pull_.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod delete { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::{extract::Path, http::StatusCode}; 10 | use serde::Serialize; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Serialize)] 14 | struct Response {} 15 | 16 | #[utoipa::path(delete, path = "/", responses( 17 | (status = OK, body = inline(Response)), 18 | (status = NOT_FOUND, body = ApiError), 19 | ), params( 20 | ( 21 | "server" = uuid::Uuid, 22 | description = "The server uuid", 23 | example = "123e4567-e89b-12d3-a456-426614174000", 24 | ), 25 | ( 26 | "pull" = uuid::Uuid, 27 | description = "The pull uuid", 28 | example = "123e4567-e89b-12d3-a456-426614174000", 29 | ), 30 | ))] 31 | #[deprecated( 32 | note = "This endpoint is purely for pterodactyl compatibility. Use the operations system instead." 33 | )] 34 | pub async fn route( 35 | server: GetServer, 36 | Path((_server, pull_id)): Path<(uuid::Uuid, uuid::Uuid)>, 37 | ) -> ApiResponseResult { 38 | if !server.filesystem.operations.abort_operation(pull_id).await { 39 | return ApiResponse::error("pull not found") 40 | .with_status(StatusCode::NOT_FOUND) 41 | .ok(); 42 | } 43 | 44 | server.filesystem.pulls.write().await.remove(&pull_id); 45 | 46 | ApiResponse::json(Response {}).ok() 47 | } 48 | } 49 | 50 | #[allow(deprecated)] 51 | pub fn router(state: &State) -> OpenApiRouter { 52 | OpenApiRouter::new() 53 | .routes(routes!(delete::route)) 54 | .with_state(state.clone()) 55 | } 56 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/script.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{GetState, api::servers::_server_::GetServer}, 8 | server::installation::InstallationScript, 9 | }; 10 | use axum::http::StatusCode; 11 | use serde::Serialize; 12 | use utoipa::ToSchema; 13 | 14 | #[derive(ToSchema, Serialize)] 15 | struct Response { 16 | stdout: String, 17 | stderr: String, 18 | } 19 | 20 | #[utoipa::path(post, path = "/", responses( 21 | (status = OK, body = inline(Response)), 22 | ), params( 23 | ( 24 | "server" = uuid::Uuid, 25 | description = "The server uuid", 26 | example = "123e4567-e89b-12d3-a456-426614174000", 27 | ), 28 | ), request_body = InstallationScript)] 29 | pub async fn route( 30 | state: GetState, 31 | server: GetServer, 32 | axum::Json(data): axum::Json, 33 | ) -> ApiResponseResult { 34 | match crate::server::script::script_server(&server, &state.docker, data).await { 35 | Ok((stdout, stderr)) => ApiResponse::json(Response { stdout, stderr }).ok(), 36 | Err(err) => { 37 | tracing::error!( 38 | server = %server.uuid, 39 | "failed to run server script: {:#?}", 40 | err 41 | ); 42 | 43 | ApiResponse::error("failed to run server script") 44 | .with_status(StatusCode::INTERNAL_SERVER_ERROR) 45 | .ok() 46 | } 47 | } 48 | } 49 | } 50 | 51 | pub fn router(state: &State) -> OpenApiRouter { 52 | OpenApiRouter::new() 53 | .routes(routes!(post::route)) 54 | .with_state(state.clone()) 55 | } 56 | -------------------------------------------------------------------------------- /application/src/server/configuration/process/yaml.rs: -------------------------------------------------------------------------------- 1 | use super::ServerConfigurationFile; 2 | 3 | pub struct YamlFileParser; 4 | 5 | #[async_trait::async_trait] 6 | impl super::ProcessConfigurationFileParser for YamlFileParser { 7 | async fn process_file( 8 | content: &str, 9 | config: &ServerConfigurationFile, 10 | server: &crate::server::Server, 11 | ) -> Result, anyhow::Error> { 12 | tracing::debug!( 13 | server = %server.uuid, 14 | "processing yaml file" 15 | ); 16 | 17 | let mut json: serde_json::Value = if content.trim().is_empty() { 18 | serde_json::Value::Object(serde_json::Map::new()) 19 | } else { 20 | serde_yml::from_str(content) 21 | .unwrap_or_else(|_| serde_json::Value::Object(serde_json::Map::new())) 22 | }; 23 | 24 | for replacement in &config.replace { 25 | let path_parts: Vec<&str> = replacement.r#match.split('.').collect(); 26 | 27 | let value = match &replacement.replace_with { 28 | serde_json::Value::String(_) => { 29 | let resolved = ServerConfigurationFile::replace_all_placeholders( 30 | server, 31 | &replacement.replace_with, 32 | ) 33 | .await?; 34 | serde_json::from_str(&resolved) 35 | .unwrap_or(serde_json::Value::String(resolved.into())) 36 | } 37 | other => other.clone(), 38 | }; 39 | 40 | super::json::set_nested_value( 41 | &mut json, 42 | &path_parts, 43 | value, 44 | replacement.insert_new.unwrap_or(true), 45 | replacement.update_existing, 46 | ); 47 | } 48 | 49 | Ok(serde_yml::to_string(&json)?.into_bytes()) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /application/src/server/filesystem/pull/resolver.rs: -------------------------------------------------------------------------------- 1 | use hickory_resolver::{TokioResolver, config::LookupIpStrategy, lookup_ip::LookupIpIntoIter}; 2 | use reqwest::dns::{Addrs, Name, Resolve, Resolving}; 3 | use std::{net::SocketAddr, sync::Arc}; 4 | 5 | #[derive(Clone)] 6 | pub struct DnsResolver { 7 | config: Arc, 8 | state: Arc, 9 | } 10 | 11 | impl DnsResolver { 12 | pub fn new(config: &Arc) -> Self { 13 | let mut builder = TokioResolver::builder_tokio().unwrap(); 14 | builder.options_mut().ip_strategy = LookupIpStrategy::Ipv4AndIpv6; 15 | 16 | Self { 17 | config: Arc::clone(config), 18 | state: Arc::new(builder.build()), 19 | } 20 | } 21 | } 22 | 23 | impl Resolve for DnsResolver { 24 | fn resolve(&self, name: Name) -> Resolving { 25 | let resolver = self.clone(); 26 | 27 | Box::pin(async move { 28 | let lookup = resolver.state.lookup_ip(name.as_str()).await?; 29 | let addrs: Addrs = Box::new(SocketAddrs { 30 | config: Arc::clone(&resolver.config), 31 | iter: lookup.into_iter(), 32 | }); 33 | 34 | Ok(addrs) 35 | }) 36 | } 37 | } 38 | 39 | struct SocketAddrs { 40 | config: Arc, 41 | iter: LookupIpIntoIter, 42 | } 43 | 44 | impl Iterator for SocketAddrs { 45 | type Item = SocketAddr; 46 | 47 | fn next(&mut self) -> Option { 48 | let next = self 49 | .iter 50 | .next() 51 | .map(|ip_addr| SocketAddr::new(ip_addr, 0))?; 52 | 53 | for cidr in self.config.api.remote_download_blocked_cidrs.iter() { 54 | if cidr.contains(&next.ip()) { 55 | tracing::warn!("blocking internal IP address in pull: {}", next.ip()); 56 | return self.next(); 57 | } 58 | } 59 | 60 | Some(next) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Portable UnRAR version 3 | 4 | 5 | 1. General 6 | 7 | This package includes freeware Unrar C++ source and makefile for 8 | several Unix compilers. 9 | 10 | Unrar source is subset of RAR and generated from RAR source automatically, 11 | by a small program removing blocks like '#ifndef UNRAR ... #endif'. 12 | Such method is not perfect and you may find some RAR related stuff 13 | unnecessary in Unrar, especially in header files. 14 | 15 | If you wish to port Unrar to a new platform, you may need to edit 16 | '#define LITTLE_ENDIAN' in os.hpp and data type definitions 17 | in rartypes.hpp. 18 | 19 | if computer architecture does not allow not aligned data access, 20 | you need to undefine ALLOW_NOT_ALIGNED_INT and define 21 | STRICT_ALIGNMENT_REQUIRED in os.h. 22 | 23 | UnRAR.vcproj and UnRARDll.vcproj are projects for Microsoft Visual C++. 24 | UnRARDll.vcproj lets to build unrar.dll library. 25 | 26 | 27 | 2. Unrar binaries 28 | 29 | If you compiled Unrar for OS, which is not present in "Downloads" 30 | and "RAR extras" on www.rarlab.com, we will appreciate if you send 31 | us the compiled executable to place it to our site. 32 | 33 | 34 | 3. Acknowledgements 35 | 36 | This source includes parts of code written by other authors. 37 | Please see acknow.txt file for details. 38 | 39 | 40 | 4. Legal stuff 41 | 42 | Unrar source may be used in any software to handle RAR archives 43 | without limitations free of charge, but cannot be used to re-create 44 | the RAR compression algorithm, which is proprietary. Distribution 45 | of modified Unrar source in separate form or as a part of other 46 | software is permitted, provided that it is clearly stated in 47 | the documentation and source comments that the code may not be used 48 | to develop a RAR (WinRAR) compatible archiver. 49 | 50 | More detailed license text is available in license.txt. 51 | -------------------------------------------------------------------------------- /application/src/routes/api/system/logs/_file_.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod get { 5 | use crate::{ 6 | io::compression::reader::AsyncCompressionReader, 7 | response::{ApiResponse, ApiResponseResult}, 8 | routes::{ApiError, GetState}, 9 | }; 10 | use axum::extract::Path; 11 | use tokio::io::AsyncRead; 12 | 13 | #[utoipa::path(get, path = "/", responses( 14 | (status = OK, body = String), 15 | (status = NOT_FOUND, body = ApiError) 16 | ), params( 17 | ( 18 | "file" = String, 19 | description = "The log file name", 20 | example = "wings.log", 21 | ), 22 | ))] 23 | pub async fn route( 24 | state: GetState, 25 | Path(file_path): Path, 26 | ) -> ApiResponseResult { 27 | if file_path.contains("..") { 28 | return ApiResponse::error("log file not found").ok(); 29 | } 30 | 31 | let file = match tokio::fs::File::open( 32 | std::path::Path::new(&state.config.system.log_directory).join(&file_path), 33 | ) 34 | .await 35 | { 36 | Ok(file) => file, 37 | Err(_) => return ApiResponse::error("log file not found").ok(), 38 | }; 39 | 40 | let reader: Box = if file_path.ends_with(".gz") { 41 | Box::new(AsyncCompressionReader::new( 42 | file.into_std().await, 43 | crate::io::compression::CompressionType::Gz, 44 | )) 45 | } else { 46 | Box::new(file) 47 | }; 48 | 49 | ApiResponse::new_stream(reader) 50 | .with_header("Content-Type", "text/plain") 51 | .ok() 52 | } 53 | } 54 | 55 | pub fn router(state: &State) -> OpenApiRouter { 56 | OpenApiRouter::new() 57 | .routes(routes!(get::route)) 58 | .with_state(state.clone()) 59 | } 60 | -------------------------------------------------------------------------------- /application/src/routes/api/transfers/_server_.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod delete { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, GetState}, 8 | }; 9 | use axum::{extract::Path, http::StatusCode}; 10 | use serde::Serialize; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Serialize)] 14 | struct Response {} 15 | 16 | #[utoipa::path(delete, path = "/", responses( 17 | (status = OK, body = inline(Response)), 18 | (status = NOT_FOUND, body = ApiError), 19 | ), params( 20 | ( 21 | "server" = uuid::Uuid, 22 | description = "The server uuid", 23 | example = "123e4567-e89b-12d3-a456-426614174000", 24 | ), 25 | ))] 26 | pub async fn route(state: GetState, Path(server): Path) -> ApiResponseResult { 27 | let server = state 28 | .server_manager 29 | .get_servers() 30 | .await 31 | .iter() 32 | .find(|s| s.uuid == server) 33 | .cloned(); 34 | 35 | let server = match server { 36 | Some(server) => server, 37 | None => { 38 | return ApiResponse::error("server not found") 39 | .with_status(StatusCode::NOT_FOUND) 40 | .ok(); 41 | } 42 | }; 43 | 44 | server 45 | .transferring 46 | .store(false, std::sync::atomic::Ordering::SeqCst); 47 | server.incoming_transfer.write().await.take(); 48 | 49 | ApiResponse::json(Response {}).ok() 50 | } 51 | } 52 | 53 | pub fn router(state: &State) -> OpenApiRouter { 54 | OpenApiRouter::new() 55 | .routes(routes!(delete::route)) 56 | .route_layer(axum::middleware::from_fn_with_state( 57 | state.clone(), 58 | crate::routes::api::auth, 59 | )) 60 | .with_state(state.clone()) 61 | } 62 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/schedules/_schedule_/abort.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::{extract::Path, http::StatusCode}; 10 | use serde::Serialize; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Serialize)] 14 | struct Response {} 15 | 16 | #[utoipa::path(post, path = "/", responses( 17 | (status = OK, body = inline(Response)), 18 | (status = NOT_FOUND, body = ApiError), 19 | ), params( 20 | ( 21 | "server" = uuid::Uuid, 22 | description = "The server uuid", 23 | example = "123e4567-e89b-12d3-a456-426614174000", 24 | ), 25 | ( 26 | "schedule" = uuid::Uuid, 27 | description = "The schedule uuid", 28 | example = "123e4567-e89b-12d3-a456-426614174000", 29 | ), 30 | ))] 31 | pub async fn route( 32 | server: GetServer, 33 | Path((_server, schedule_id)): Path<(uuid::Uuid, uuid::Uuid)>, 34 | ) -> ApiResponseResult { 35 | let mut schedules = server.schedules.get_mut_schedules().await; 36 | 37 | let schedule = match schedules.iter_mut().find(|s| s.uuid == schedule_id) { 38 | Some(schedule) => schedule, 39 | None => { 40 | return ApiResponse::error("schedule not found") 41 | .with_status(StatusCode::NOT_FOUND) 42 | .ok(); 43 | } 44 | }; 45 | 46 | schedule.recreate_executor(server.0.clone()).await; 47 | 48 | ApiResponse::json(Response {}) 49 | .with_status(StatusCode::OK) 50 | .ok() 51 | } 52 | } 53 | 54 | pub fn router(state: &State) -> OpenApiRouter { 55 | OpenApiRouter::new() 56 | .routes(routes!(post::route)) 57 | .with_state(state.clone()) 58 | } 59 | -------------------------------------------------------------------------------- /application/src/io/counting_reader.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | pin::Pin, 3 | sync::{ 4 | Arc, 5 | atomic::{AtomicU64, Ordering}, 6 | }, 7 | task::{Context, Poll}, 8 | }; 9 | use tokio::io::AsyncRead; 10 | 11 | pub struct CountingReader { 12 | inner: R, 13 | pub bytes_read: Arc, 14 | } 15 | 16 | impl CountingReader { 17 | pub fn new_with_bytes_read(inner: R, bytes_read: Arc) -> Self { 18 | Self { inner, bytes_read } 19 | } 20 | 21 | #[inline] 22 | pub fn into_inner(self) -> R { 23 | self.inner 24 | } 25 | } 26 | 27 | impl std::io::Read for CountingReader { 28 | #[inline] 29 | fn read(&mut self, buf: &mut [u8]) -> std::io::Result { 30 | let bytes_read = self.inner.read(buf)?; 31 | self.bytes_read 32 | .fetch_add(bytes_read as u64, Ordering::Relaxed); 33 | 34 | Ok(bytes_read) 35 | } 36 | } 37 | 38 | pub struct AsyncCountingReader { 39 | inner: R, 40 | pub bytes_read: Arc, 41 | } 42 | 43 | impl AsyncCountingReader { 44 | pub fn new_with_bytes_read(inner: R, bytes_read: Arc) -> Self { 45 | Self { inner, bytes_read } 46 | } 47 | } 48 | 49 | impl AsyncRead for AsyncCountingReader { 50 | fn poll_read( 51 | mut self: Pin<&mut Self>, 52 | cx: &mut Context<'_>, 53 | buf: &mut tokio::io::ReadBuf<'_>, 54 | ) -> Poll> { 55 | let filled_before = buf.filled().len(); 56 | 57 | let poll_result = Pin::new(&mut self.inner).poll_read(cx, buf); 58 | 59 | if let Poll::Ready(Ok(())) = &poll_result { 60 | let filled_after = buf.filled().len(); 61 | let bytes_read = filled_after - filled_before; 62 | 63 | self.bytes_read 64 | .fetch_add(bytes_read as u64, Ordering::Relaxed); 65 | } 66 | 67 | poll_result 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /application/src/io/hash_reader.rs: -------------------------------------------------------------------------------- 1 | use sha1::{Digest, digest::Output}; 2 | use std::{ 3 | io::Read, 4 | pin::Pin, 5 | sync::Arc, 6 | task::{Context, Poll}, 7 | }; 8 | use tokio::{ 9 | io::{AsyncRead, ReadBuf}, 10 | sync::{Mutex, OwnedMutexGuard}, 11 | }; 12 | 13 | pub struct HashReader { 14 | inner: R, 15 | hasher: H, 16 | } 17 | 18 | impl HashReader { 19 | pub fn new_with_hasher(inner: R, hasher: H) -> Self { 20 | Self { inner, hasher } 21 | } 22 | 23 | pub fn finish(self) -> Output { 24 | self.hasher.finalize() 25 | } 26 | } 27 | 28 | impl Read for HashReader { 29 | fn read(&mut self, buf: &mut [u8]) -> std::io::Result { 30 | let bytes_read = self.inner.read(buf)?; 31 | 32 | self.hasher.update(&buf[..bytes_read]); 33 | 34 | Ok(bytes_read) 35 | } 36 | } 37 | 38 | pub struct AsyncHashReader { 39 | inner: R, 40 | hasher: OwnedMutexGuard, 41 | } 42 | 43 | impl AsyncHashReader { 44 | pub async fn new_with_hasher(inner: R, hasher: Arc>) -> Self { 45 | Self { 46 | inner, 47 | hasher: hasher.lock_owned().await, 48 | } 49 | } 50 | } 51 | 52 | impl AsyncRead for AsyncHashReader { 53 | fn poll_read( 54 | mut self: Pin<&mut Self>, 55 | cx: &mut Context<'_>, 56 | buf: &mut ReadBuf<'_>, 57 | ) -> Poll> { 58 | let filled_before = buf.filled().len(); 59 | 60 | let poll_result = Pin::new(&mut self.inner).poll_read(cx, buf); 61 | 62 | if let Poll::Ready(Ok(())) = &poll_result { 63 | let filled_after = buf.filled().len(); 64 | let newly_filled = &buf.filled()[filled_before..filled_after]; 65 | 66 | self.hasher.update(newly_filled); 67 | } 68 | 69 | poll_result 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/hash.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_DATAHASH_ 2 | #define _RAR_DATAHASH_ 3 | 4 | enum HASH_TYPE {HASH_NONE,HASH_RAR14,HASH_CRC32,HASH_BLAKE2}; 5 | 6 | struct HashValue 7 | { 8 | void Init(HASH_TYPE Type); 9 | 10 | // Use the const member, so types on both sides of "==" match. 11 | // Otherwise clang -std=c++20 issues "ambiguity is between a regular call 12 | // to this operator and a call with the argument order reversed" warning. 13 | bool operator == (const HashValue &cmp) const; 14 | 15 | // Not actually used now. Const member for same reason as operator == above. 16 | bool operator != (const HashValue &cmp) const {return !(*this==cmp);} 17 | 18 | HASH_TYPE Type; 19 | union 20 | { 21 | uint CRC32; 22 | byte Digest[SHA256_DIGEST_SIZE]; 23 | }; 24 | }; 25 | 26 | 27 | #ifdef RAR_SMP 28 | class ThreadPool; 29 | class DataHash; 30 | #endif 31 | 32 | 33 | class DataHash 34 | { 35 | public: 36 | struct CRC32ThreadData 37 | { 38 | void *Data; 39 | size_t DataSize; 40 | uint DataCRC; 41 | }; 42 | private: 43 | void UpdateCRC32MT(const void *Data,size_t DataSize); 44 | uint BitReverse32(uint N); 45 | uint gfMulCRC(uint A, uint B); 46 | uint gfExpCRC(uint N); 47 | 48 | // Speed gain seems to vanish above 8 CRC32 threads. 49 | static const uint CRC32_POOL_THREADS=8; 50 | // Thread pool must allow at least BLAKE2_THREADS_NUMBER threads. 51 | static const uint HASH_POOL_THREADS=Max(BLAKE2_THREADS_NUMBER,CRC32_POOL_THREADS); 52 | 53 | HASH_TYPE HashType; 54 | uint CurCRC32; 55 | blake2sp_state *blake2ctx; 56 | 57 | #ifdef RAR_SMP 58 | ThreadPool *ThPool; 59 | 60 | uint MaxThreads; 61 | #endif 62 | public: 63 | DataHash(); 64 | ~DataHash(); 65 | void Init(HASH_TYPE Type,uint MaxThreads); 66 | void Update(const void *Data,size_t DataSize); 67 | void Result(HashValue *Result); 68 | uint GetCRC32(); 69 | bool Cmp(HashValue *CmpValue,byte *Key); 70 | HASH_TYPE Type() {return HashType;} 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/ws/permissions.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::api::servers::_server_::GetServer, 8 | server::permissions::Permissions, 9 | }; 10 | use serde::{Deserialize, Serialize}; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Deserialize)] 14 | pub struct PayloadPermissions { 15 | user: uuid::Uuid, 16 | 17 | #[schema(value_type = Vec)] 18 | permissions: Permissions, 19 | #[serde(default)] 20 | ignored_files: Vec, 21 | } 22 | 23 | #[derive(ToSchema, Deserialize)] 24 | pub struct Payload { 25 | #[schema(inline)] 26 | user_permissions: Vec, 27 | } 28 | 29 | #[derive(ToSchema, Serialize)] 30 | struct Response {} 31 | 32 | #[utoipa::path(post, path = "/", responses( 33 | (status = OK, body = inline(Response)), 34 | ), params( 35 | ( 36 | "server" = uuid::Uuid, 37 | description = "The server uuid", 38 | example = "123e4567-e89b-12d3-a456-426614174000", 39 | ), 40 | ), request_body = inline(Payload))] 41 | pub async fn route( 42 | server: GetServer, 43 | axum::Json(data): axum::Json, 44 | ) -> ApiResponseResult { 45 | for user_permission in data.user_permissions { 46 | server 47 | .user_permissions 48 | .set_permissions( 49 | user_permission.user, 50 | user_permission.permissions, 51 | &user_permission.ignored_files, 52 | ) 53 | .await; 54 | } 55 | 56 | ApiResponse::json(Response {}).ok() 57 | } 58 | } 59 | 60 | pub fn router(state: &State) -> OpenApiRouter { 61 | OpenApiRouter::new() 62 | .routes(routes!(post::route)) 63 | .with_state(state.clone()) 64 | } 65 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/filefn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_FILEFN_ 2 | #define _RAR_FILEFN_ 3 | 4 | enum MKDIR_CODE {MKDIR_SUCCESS,MKDIR_ERROR,MKDIR_BADPATH}; 5 | 6 | MKDIR_CODE MakeDir(const std::wstring &Name,bool SetAttr,uint Attr); 7 | bool CreateDir(const std::wstring &Name); 8 | bool CreatePath(const std::wstring &Path,bool SkipLastName,bool Silent); 9 | void SetDirTime(const std::wstring &Name,RarTime *ftm,RarTime *ftc,RarTime *fta); 10 | bool IsRemovable(const std::wstring &Name); 11 | 12 | #ifndef SFX_MODULE 13 | int64 GetFreeDisk(const std::wstring &Name); 14 | #endif 15 | 16 | #if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SILENT) 17 | bool IsFAT(const std::wstring &Root); 18 | #endif 19 | 20 | bool FileExist(const std::wstring &Name); 21 | bool WildFileExist(const std::wstring &Name); 22 | bool IsDir(uint Attr); 23 | bool IsUnreadable(uint Attr); 24 | bool IsLink(uint Attr); 25 | void SetSFXMode(const std::wstring &FileName); 26 | void EraseDiskContents(const std::wstring &FileName); 27 | bool IsDeleteAllowed(uint FileAttr); 28 | void PrepareToDelete(const std::wstring &Name); 29 | uint GetFileAttr(const std::wstring &Name); 30 | bool SetFileAttr(const std::wstring &Name,uint Attr); 31 | wchar* MkTemp(wchar *Name,size_t MaxSize); 32 | bool MkTemp(std::wstring &Name); 33 | 34 | enum CALCFSUM_FLAGS {CALCFSUM_SHOWTEXT=1,CALCFSUM_SHOWPERCENT=2,CALCFSUM_SHOWPROGRESS=4,CALCFSUM_CURPOS=8}; 35 | 36 | void CalcFileSum(File *SrcFile,uint *CRC32,byte *Blake2,uint Threads,int64 Size=INT64NDF,uint Flags=0); 37 | 38 | bool RenameFile(const std::wstring &SrcName,const std::wstring &DestName); 39 | bool DelFile(const std::wstring &Name); 40 | bool DelDir(const std::wstring &Name); 41 | 42 | #if defined(_WIN_ALL) && !defined(SFX_MODULE) 43 | bool SetFileCompression(const std::wstring &Name,bool State); 44 | void ResetFileCache(const std::wstring &Name); 45 | #endif 46 | 47 | 48 | 49 | 50 | 51 | // Keep it here and not in extinfo.cpp, because it is invoked from Zip.SFX too. 52 | bool LinksToDirs(const std::wstring &SrcName,const std::wstring &SkipPart,std::wstring &LastChecked); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rijndael.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RIJNDAEL_H_ 2 | #define _RIJNDAEL_H_ 3 | 4 | /************************************************************************** 5 | * This code is based on Szymon Stefanek public domain AES implementation * 6 | **************************************************************************/ 7 | 8 | #define _MAX_KEY_COLUMNS (256/32) 9 | #define _MAX_ROUNDS 14 10 | #define MAX_IV_SIZE 16 11 | 12 | class Rijndael 13 | { 14 | private: 15 | 16 | #ifdef USE_SSE 17 | #ifdef __GNUC__ 18 | __attribute__((target("aes"))) 19 | #endif 20 | void blockEncryptSSE(const byte *input,size_t numBlocks,byte *outBuffer); 21 | #ifdef __GNUC__ 22 | __attribute__((target("aes"))) 23 | #endif 24 | void blockDecryptSSE(const byte *input, size_t numBlocks, byte *outBuffer); 25 | 26 | bool AES_NI; 27 | #endif 28 | 29 | #ifdef USE_NEON_AES 30 | // In Android we must specify -march=armv8-a+crypto compiler switch 31 | // to support Neon AES commands, "crypto" attribute seems to be optional. 32 | __attribute__((target("+crypto"))) 33 | void blockEncryptNeon(const byte *input,size_t numBlocks,byte *outBuffer); 34 | __attribute__((target("+crypto"))) 35 | void blockDecryptNeon(const byte *input, size_t numBlocks, byte *outBuffer); 36 | 37 | bool AES_Neon; 38 | #endif 39 | 40 | void keySched(byte key[_MAX_KEY_COLUMNS][4]); 41 | void keyEncToDec(); 42 | void GenerateTables(); 43 | 44 | // RAR always uses CBC, but we may need to turn it off when calling 45 | // this code from other archive formats with CTR and other modes. 46 | bool CBCMode; 47 | 48 | int m_uRounds; 49 | byte m_initVector[MAX_IV_SIZE]; 50 | byte m_expandedKey[_MAX_ROUNDS+1][4][4]; 51 | public: 52 | Rijndael(); 53 | void Init(bool Encrypt,const byte *key,uint keyLen,const byte *initVector); 54 | void blockEncrypt(const byte *input, size_t inputLen, byte *outBuffer); 55 | void blockDecrypt(const byte *input, size_t inputLen, byte *outBuffer); 56 | void SetCBCMode(bool Mode) {CBCMode=Mode;} 57 | }; 58 | 59 | #endif // _RIJNDAEL_H_ 60 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/commands.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::http::StatusCode; 10 | use serde::{Deserialize, Serialize}; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Deserialize)] 14 | pub struct Payload { 15 | commands: Vec, 16 | } 17 | 18 | #[derive(ToSchema, Serialize)] 19 | struct Response {} 20 | 21 | #[utoipa::path(post, path = "/", responses( 22 | (status = OK, body = inline(Response)), 23 | (status = EXPECTATION_FAILED, body = ApiError), 24 | ), params( 25 | ( 26 | "server" = uuid::Uuid, 27 | description = "The server uuid", 28 | example = "123e4567-e89b-12d3-a456-426614174000", 29 | ), 30 | ), request_body = inline(Payload))] 31 | pub async fn route( 32 | server: GetServer, 33 | axum::Json(data): axum::Json, 34 | ) -> ApiResponseResult { 35 | if server.state.get_state() == crate::server::state::ServerState::Offline { 36 | return ApiResponse::error("server is offline") 37 | .with_status(StatusCode::EXPECTATION_FAILED) 38 | .ok(); 39 | } 40 | 41 | if let Some(stdin) = server.container_stdin().await { 42 | for mut command in data.commands { 43 | command.push('\n'); 44 | 45 | stdin.send(command).await.ok(); 46 | } 47 | } else { 48 | return ApiResponse::error("failed to get stdin (is server offline?)") 49 | .with_status(StatusCode::EXPECTATION_FAILED) 50 | .ok(); 51 | } 52 | 53 | ApiResponse::json(Response {}).ok() 54 | } 55 | } 56 | 57 | pub fn router(state: &State) -> OpenApiRouter { 58 | OpenApiRouter::new() 59 | .routes(routes!(post::route)) 60 | .with_state(state.clone()) 61 | } 62 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/Documentation/RARSetCallback.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UnRAR.dll Manual 6 | 7 | 8 | 9 | 10 |

void PASCAL RARSetCallback(HANDLE hArcData, 11 | int PASCAL (*Callback)(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2), 12 | LPARAM UserData)

13 | 14 |

Description

15 | 16 |

Set a user defined callback function 17 | to process UnRAR events.

18 | 19 |

RARSetCallback is obsolete and less preferable way to specify the callback 20 | function. Recommended approach is to set Callback and UserData 21 | fields in RAROpenArchiveDataEx 22 | structure, when calling RAROpenArchiveEx. 23 | If you use RARSetCallback, you will not be able to read the archive comment 24 | in archives with encrypted headers. If you do not need the archive comment, 25 | you can continue to use RARSetCallback.

26 | 27 |

Parameters

28 | 29 | hArcData 30 |
31 | This parameter should contain the archive handle obtained from 32 | RAROpenArchive or 33 | RAROpenArchiveEx function call. 34 |
35 | 36 | Callback 37 |
38 |

Address of user defined callback function 39 | to process UnRAR events.

40 |

Set it to NULL if you do not want to define the callback function. 41 | Callback function is required to process multivolume and encrypted 42 | archives properly.

43 |
44 | 45 | UserData 46 |
47 |

User defined value, which will be passed to 48 | callback function.

49 |
50 | 51 | 52 |

Return values

53 |
54 | None. 55 |
56 | 57 |

See also

58 |
59 | User defined callback function 60 |
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/license.txt: -------------------------------------------------------------------------------- 1 | ****** ***** ****** UnRAR - free utility for RAR archives 2 | ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | ****** ******* ****** License for use and distribution of 4 | ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 | ** ** ** ** ** ** FREE portable version 6 | ~~~~~~~~~~~~~~~~~~~~~ 7 | 8 | The source code of UnRAR utility is freeware. This means: 9 | 10 | 1. All copyrights to RAR and the utility UnRAR are exclusively 11 | owned by the author - Alexander Roshal. 12 | 13 | 2. UnRAR source code may be used in any software to handle 14 | RAR archives without limitations free of charge, but cannot be 15 | used to develop RAR (WinRAR) compatible archiver and to 16 | re-create RAR compression algorithm, which is proprietary. 17 | Distribution of modified UnRAR source code in separate form 18 | or as a part of other software is permitted, provided that 19 | full text of this paragraph, starting from "UnRAR source code" 20 | words, is included in license, or in documentation if license 21 | is not available, and in source code comments of resulting package. 22 | 23 | 3. The UnRAR utility may be freely distributed. It is allowed 24 | to distribute UnRAR inside of other software packages. 25 | 26 | 4. THE RAR ARCHIVER AND THE UnRAR UTILITY ARE DISTRIBUTED "AS IS". 27 | NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE AT 28 | YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, 29 | DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING 30 | OR MISUSING THIS SOFTWARE. 31 | 32 | 5. Installing and using the UnRAR utility signifies acceptance of 33 | these terms and conditions of the license. 34 | 35 | 6. If you don't agree with terms of the license you must remove 36 | UnRAR files from your storage devices and cease to use the 37 | utility. 38 | 39 | Thank you for your interest in RAR and UnRAR. 40 | 41 | 42 | Alexander L. Roshal 43 | -------------------------------------------------------------------------------- /application/src/server/configuration/process/plain.rs: -------------------------------------------------------------------------------- 1 | use super::ServerConfigurationFile; 2 | use std::{collections::HashSet, fmt::Write}; 3 | 4 | pub struct PlainFileParser; 5 | 6 | #[async_trait::async_trait] 7 | impl super::ProcessConfigurationFileParser for PlainFileParser { 8 | async fn process_file( 9 | content: &str, 10 | config: &ServerConfigurationFile, 11 | server: &crate::server::Server, 12 | ) -> Result, anyhow::Error> { 13 | tracing::debug!( 14 | server = %server.uuid, 15 | "processing plain file" 16 | ); 17 | 18 | let mut result = String::new(); 19 | let mut found_matches = HashSet::new(); 20 | 21 | for line in content.lines() { 22 | let mut replaced = false; 23 | 24 | for replacement in &config.replace { 25 | if !line.starts_with(&replacement.r#match) { 26 | continue; 27 | } 28 | 29 | let value = ServerConfigurationFile::replace_all_placeholders( 30 | server, 31 | &replacement.replace_with, 32 | ) 33 | .await?; 34 | 35 | if replacement.update_existing { 36 | writeln!(result, "{}", value)?; 37 | replaced = true; 38 | } 39 | found_matches.insert(&replacement.r#match); 40 | 41 | break; 42 | } 43 | 44 | if !replaced { 45 | writeln!(result, "{}", line)?; 46 | } 47 | } 48 | 49 | for replacement in &config.replace { 50 | let insert_new = replacement.insert_new.unwrap_or(false); 51 | 52 | if found_matches.contains(&replacement.r#match) || !insert_new { 53 | continue; 54 | } 55 | 56 | let value = ServerConfigurationFile::replace_all_placeholders( 57 | server, 58 | &replacement.replace_with, 59 | ) 60 | .await?; 61 | 62 | writeln!(result, "{}", value)?; 63 | } 64 | 65 | Ok(result.into_bytes()) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for UNIX - unrar 3 | 4 | # Linux using GCC 5 | CXX=c++ 6 | CXXFLAGS=-march=native -O2 -std=c++11 -Wno-logical-op-parentheses -Wno-switch -Wno-dangling-else 7 | LIBFLAGS=-fPIC 8 | DEFINES=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DRAR_SMP 9 | STRIP=strip 10 | AR=ar 11 | LDFLAGS=-pthread 12 | DESTDIR=/usr 13 | 14 | ########################## 15 | 16 | COMPILE=$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) 17 | LINK=$(CXX) 18 | 19 | WHAT=UNRAR 20 | 21 | UNRAR_OBJ=filestr.o recvol.o rs.o scantree.o qopen.o 22 | LIB_OBJ=filestr.o scantree.o dll.o qopen.o 23 | 24 | OBJECTS=rar.o strlist.o strfn.o pathfn.o smallfn.o global.o file.o filefn.o filcreat.o \ 25 | archive.o arcread.o unicode.o system.o crypt.o crc.o rawread.o encname.o \ 26 | resource.o match.o timefn.o rdwrfn.o consio.o options.o errhnd.o rarvm.o secpassword.o \ 27 | rijndael.o getbits.o sha1.o sha256.o blake2s.o hash.o extinfo.o extract.o volume.o \ 28 | list.o find.o unpack.o headers.o threadpool.o rs16.o cmddata.o ui.o 29 | 30 | .cpp.o: 31 | $(COMPILE) -D$(WHAT) -c $< 32 | 33 | all: unrar 34 | 35 | install: install-unrar 36 | 37 | uninstall: uninstall-unrar 38 | 39 | clean: 40 | @rm -f *.bak *~ 41 | @rm -f $(OBJECTS) $(UNRAR_OBJ) $(LIB_OBJ) 42 | @rm -f unrar libunrar.* 43 | 44 | # We removed 'clean' from dependencies, because it prevented parallel 45 | # 'make -Jn' builds. 46 | 47 | unrar: $(OBJECTS) $(UNRAR_OBJ) 48 | @rm -f unrar 49 | $(LINK) -o unrar $(LDFLAGS) $(OBJECTS) $(UNRAR_OBJ) $(LIBS) 50 | $(STRIP) unrar 51 | 52 | sfx: WHAT=SFX_MODULE 53 | sfx: $(OBJECTS) 54 | @rm -f default.sfx 55 | $(LINK) -o default.sfx $(LDFLAGS) $(OBJECTS) 56 | $(STRIP) default.sfx 57 | 58 | lib: WHAT=RARDLL 59 | lib: CXXFLAGS+=$(LIBFLAGS) 60 | lib: $(OBJECTS) $(LIB_OBJ) 61 | @rm -f libunrar.* 62 | $(LINK) -shared -o libunrar.so $(LDFLAGS) $(OBJECTS) $(LIB_OBJ) 63 | $(AR) rcs libunrar.a $(OBJECTS) $(LIB_OBJ) 64 | 65 | install-unrar: 66 | install -D unrar $(DESTDIR)/bin/unrar 67 | 68 | uninstall-unrar: 69 | rm -f $(DESTDIR)/bin/unrar 70 | 71 | install-lib: 72 | install libunrar.so $(DESTDIR)/lib 73 | install libunrar.a $(DESTDIR)/lib 74 | 75 | uninstall-lib: 76 | rm -f $(DESTDIR)/lib/libunrar.so 77 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/encname.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | EncodeFileName::EncodeFileName() 4 | { 5 | Flags=0; 6 | FlagBits=0; 7 | FlagsPos=0; 8 | DestSize=0; 9 | } 10 | 11 | 12 | 13 | 14 | void EncodeFileName::Decode(const char *Name,size_t NameSize, 15 | const byte *EncName,size_t EncSize, 16 | std::wstring &NameW) 17 | { 18 | size_t EncPos=0,DecPos=0; 19 | byte HighByte=EncPos>6) 28 | { 29 | case 0: 30 | if (EncPos>=EncSize) 31 | break; 32 | // We need DecPos also for ASCII "Name", so resize() instead of push_back(). 33 | NameW.resize(DecPos+1); 34 | NameW[DecPos++]=EncName[EncPos++]; 35 | break; 36 | case 1: 37 | if (EncPos>=EncSize) 38 | break; 39 | NameW.resize(DecPos+1); 40 | NameW[DecPos++]=EncName[EncPos++]+(HighByte<<8); 41 | break; 42 | case 2: 43 | if (EncPos+1>=EncSize) 44 | break; 45 | NameW.resize(DecPos+1); 46 | NameW[DecPos++]=EncName[EncPos]+(EncName[EncPos+1]<<8); 47 | EncPos+=2; 48 | break; 49 | case 3: 50 | { 51 | if (EncPos>=EncSize) 52 | break; 53 | int Length=EncName[EncPos++]; 54 | if ((Length & 0x80)!=0) 55 | { 56 | if (EncPos>=EncSize) 57 | break; 58 | byte Correction=EncName[EncPos++]; 59 | for (Length=(Length&0x7f)+2;Length>0 && DecPos0 && DecPos { 18 | status: &'a crate::server::schedule::ScheduleStatus, 19 | } 20 | 21 | #[utoipa::path(get, path = "/", responses( 22 | (status = OK, body = inline(Response)), 23 | (status = NOT_FOUND, body = ApiError), 24 | ), params( 25 | ( 26 | "server" = uuid::Uuid, 27 | description = "The server uuid", 28 | example = "123e4567-e89b-12d3-a456-426614174000", 29 | ), 30 | ( 31 | "schedule" = uuid::Uuid, 32 | description = "The schedule uuid", 33 | example = "123e4567-e89b-12d3-a456-426614174000", 34 | ), 35 | ))] 36 | pub async fn route( 37 | server: GetServer, 38 | Path((_server, schedule_id)): Path<(uuid::Uuid, uuid::Uuid)>, 39 | ) -> ApiResponseResult { 40 | let schedules = server.schedules.get_schedules().await; 41 | 42 | let schedule = match schedules.iter().find(|s| s.uuid == schedule_id) { 43 | Some(schedule) => schedule, 44 | None => { 45 | return ApiResponse::error("schedule not found") 46 | .with_status(StatusCode::NOT_FOUND) 47 | .ok(); 48 | } 49 | }; 50 | 51 | ApiResponse::json(Response { 52 | status: &*schedule.status.read().await, 53 | }) 54 | .with_status(StatusCode::ACCEPTED) 55 | .ok() 56 | } 57 | } 58 | 59 | pub fn router(state: &State) -> OpenApiRouter { 60 | OpenApiRouter::new() 61 | .nest("/abort", abort::router(state)) 62 | .nest("/trigger", trigger::router(state)) 63 | .routes(routes!(get::route)) 64 | .with_state(state.clone()) 65 | } 66 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/schedules/_schedule_/trigger.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::{extract::Path, http::StatusCode}; 10 | use serde::{Deserialize, Serialize}; 11 | use utoipa::ToSchema; 12 | 13 | #[derive(ToSchema, Deserialize)] 14 | pub struct Payload { 15 | #[serde(default)] 16 | skip_condition: bool, 17 | } 18 | 19 | #[derive(ToSchema, Serialize)] 20 | struct Response {} 21 | 22 | #[utoipa::path(post, path = "/", responses( 23 | (status = OK, body = inline(Response)), 24 | (status = NOT_FOUND, body = ApiError), 25 | ), params( 26 | ( 27 | "server" = uuid::Uuid, 28 | description = "The server uuid", 29 | example = "123e4567-e89b-12d3-a456-426614174000", 30 | ), 31 | ( 32 | "schedule" = uuid::Uuid, 33 | description = "The schedule uuid", 34 | example = "123e4567-e89b-12d3-a456-426614174000", 35 | ), 36 | ), request_body = inline(Payload))] 37 | pub async fn route( 38 | server: GetServer, 39 | Path((_server, schedule_id)): Path<(uuid::Uuid, uuid::Uuid)>, 40 | axum::Json(data): axum::Json, 41 | ) -> ApiResponseResult { 42 | let schedules = server.schedules.get_schedules().await; 43 | 44 | let schedule = match schedules.iter().find(|s| s.uuid == schedule_id) { 45 | Some(schedule) => schedule, 46 | None => { 47 | return ApiResponse::error("schedule not found") 48 | .with_status(StatusCode::NOT_FOUND) 49 | .ok(); 50 | } 51 | }; 52 | 53 | schedule.trigger(data.skip_condition); 54 | 55 | ApiResponse::json(Response {}) 56 | .with_status(StatusCode::OK) 57 | .ok() 58 | } 59 | } 60 | 61 | pub fn router(state: &State) -> OpenApiRouter { 62 | OpenApiRouter::new() 63 | .routes(routes!(post::route)) 64 | .with_state(state.clone()) 65 | } 66 | -------------------------------------------------------------------------------- /application/build.rs: -------------------------------------------------------------------------------- 1 | use std::process::Command; 2 | 3 | fn main() { 4 | println!("cargo:rerun-if-changed=build.rs"); 5 | 6 | let is_git_repo = Command::new("git") 7 | .args(["rev-parse", "--is-inside-work-tree"]) 8 | .output() 9 | .map(|output| output.status.success()) 10 | .unwrap_or(false); 11 | 12 | if is_git_repo { 13 | println!("cargo:rerun-if-changed=../.git/HEAD"); 14 | 15 | if let Ok(head) = std::fs::read_to_string("../.git/HEAD") 16 | && head.starts_with("ref: ") 17 | { 18 | let head_ref = head.trim_start_matches("ref: ").trim(); 19 | println!("cargo:rerun-if-changed=../.git/{head_ref}"); 20 | } 21 | 22 | println!("cargo:rerun-if-changed=../.git/index"); 23 | } 24 | 25 | let mut git_hash = "unknown".to_string(); 26 | 27 | if is_git_repo 28 | && let Ok(output) = Command::new("git") 29 | .args(["rev-parse", "--short", "HEAD"]) 30 | .output() 31 | && output.status.success() 32 | && let Ok(hash) = String::from_utf8(output.stdout) 33 | { 34 | git_hash = hash.trim().to_string(); 35 | } 36 | 37 | let target_arch = 38 | std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "unknown".to_string()); 39 | let target_env = 40 | std::env::var("CARGO_CFG_TARGET_ENV").unwrap_or_else(|_| "unknown".to_string()); 41 | 42 | println!("cargo:rustc-env=CARGO_GIT_COMMIT={git_hash}"); 43 | println!("cargo:rustc-env=CARGO_TARGET={target_arch}-{target_env}"); 44 | 45 | println!("cargo:rerun-if-changed=seccomp.json"); 46 | 47 | let seccomp_path = std::path::Path::new("seccomp.json"); 48 | if seccomp_path.exists() { 49 | let seccomp_min_path = std::path::Path::new("seccomp.min.json"); 50 | 51 | let seccomp = std::fs::read_to_string(seccomp_path).expect("Failed to read seccomp.json"); 52 | let seccomp_min = serde_json::to_string( 53 | &serde_json::from_str::(&seccomp) 54 | .expect("Failed to parse seccomp.json"), 55 | ) 56 | .expect("Failed to serialize seccomp.json"); 57 | 58 | std::fs::write(seccomp_min_path, seccomp_min).expect("Failed to write seccomp.min.json"); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/strfn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_STRFN_ 2 | #define _RAR_STRFN_ 3 | 4 | const char* NullToEmpty(const char *Str); 5 | const wchar* NullToEmpty(const wchar *Str); 6 | void IntToExt(const std::string &Src,std::string &Dest); 7 | 8 | enum ACTW_ENCODING { ACTW_DEFAULT, ACTW_OEM, ACTW_UTF8}; 9 | void ArcCharToWide(const char *Src,std::wstring &Dest,ACTW_ENCODING Encoding); 10 | 11 | 12 | int stricomp(const char *s1,const char *s2); 13 | int strnicomp(const char *s1,const char *s2,size_t n); 14 | wchar* RemoveEOL(wchar *Str); 15 | void RemoveEOL(std::wstring &Str); 16 | wchar* RemoveLF(wchar *Str); 17 | void RemoveLF(std::wstring &Str); 18 | 19 | void strncpyz(char *dest, const char *src, size_t maxlen); 20 | void wcsncpyz(wchar *dest, const wchar *src, size_t maxlen); 21 | void strncatz(char* dest, const char* src, size_t maxlen); 22 | void wcsncatz(wchar* dest, const wchar* src, size_t maxlen); 23 | 24 | #if defined(SFX_MODULE) 25 | unsigned char etoupper(unsigned char c); 26 | #endif 27 | wchar etoupperw(wchar c); 28 | 29 | bool IsDigit(int ch); 30 | bool IsSpace(int ch); 31 | bool IsAlpha(int ch); 32 | 33 | void BinToHex(const byte *Bin,size_t BinSize,std::wstring &Hex); 34 | 35 | #ifndef SFX_MODULE 36 | uint GetDigits(uint Number); 37 | #endif 38 | 39 | bool LowAscii(const std::string &Str); 40 | bool LowAscii(const std::wstring &Str); 41 | 42 | int wcsicompc(const wchar *s1,const wchar *s2); 43 | int wcsicompc(const std::wstring &s1,const std::wstring &s2); 44 | int wcsnicompc(const wchar *s1,const wchar *s2,size_t n); 45 | int wcsnicompc(const std::wstring &s1,const std::wstring &s2,size_t n); 46 | 47 | void itoa(int64 n,char *Str,size_t MaxSize); 48 | void itoa(int64 n,wchar *Str,size_t MaxSize); 49 | void fmtitoa(int64 n,wchar *Str,size_t MaxSize); 50 | std::wstring GetWide(const char *Src); 51 | bool GetCmdParam(const std::wstring &CmdLine,std::wstring::size_type &Pos,std::wstring &Param); 52 | #ifndef RARDLL 53 | void PrintfPrepareFmt(const wchar *Org,std::wstring &Cvt); 54 | std::wstring wstrprintf(const wchar *fmt,...); 55 | std::wstring vwstrprintf(const wchar *fmt,va_list arglist); 56 | #endif 57 | 58 | #ifdef _WIN_ALL 59 | bool ExpandEnvironmentStr(std::wstring &Str); 60 | #endif 61 | 62 | void TruncateAtZero(std::wstring &Str); 63 | void ReplaceEsc(std::wstring &Str); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /application/src/routes/api/system/stats/ws.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use crate::routes::GetState; 3 | use axum::{ 4 | body::Bytes, 5 | extract::{WebSocketUpgrade, ws::Message}, 6 | response::Response, 7 | routing::any, 8 | }; 9 | use std::{pin::Pin, sync::Arc}; 10 | use utoipa_axum::router::OpenApiRouter; 11 | 12 | pub async fn handle_ws(ws: WebSocketUpgrade, state: GetState) -> Response { 13 | ws.on_upgrade(move |socket| async move { 14 | let socket = Arc::new(tokio::sync::Mutex::new(socket)); 15 | 16 | type ReturnType = dyn futures_util::Future> + Send; 17 | let futures: [Pin>; 2] = [ 18 | // Stats Listener 19 | Box::pin({ 20 | let state = Arc::clone(&state); 21 | let socket = Arc::clone(&socket); 22 | 23 | async move { 24 | loop { 25 | let stats = state.stats_manager.get_stats().await; 26 | 27 | socket 28 | .lock() 29 | .await 30 | .send(Message::Text( 31 | serde_json::to_string(&*stats).unwrap().into(), 32 | )) 33 | .await?; 34 | 35 | tokio::time::sleep(std::time::Duration::from_secs(1)).await; 36 | } 37 | } 38 | }), 39 | // Pinger 40 | Box::pin(async move { 41 | loop { 42 | tokio::time::sleep(std::time::Duration::from_secs(30)).await; 43 | 44 | socket 45 | .lock() 46 | .await 47 | .send(Message::Ping(Bytes::from_static(&[1, 2, 3]))) 48 | .await?; 49 | } 50 | }), 51 | ]; 52 | 53 | if let Err(err) = futures_util::future::try_join_all(futures).await { 54 | tracing::debug!("error while serving stats websocket: {:?}", err); 55 | } 56 | }) 57 | } 58 | 59 | pub fn router(state: &State) -> OpenApiRouter { 60 | OpenApiRouter::new() 61 | .route("/", any(handle_ws)) 62 | .with_state(state.clone()) 63 | } 64 | -------------------------------------------------------------------------------- /application/src/routes/api/backups/_backup_.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod delete { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, GetState}, 8 | server::backup::adapters::BackupAdapter, 9 | }; 10 | use axum::{extract::Path, http::StatusCode}; 11 | use serde::{Deserialize, Serialize}; 12 | use utoipa::ToSchema; 13 | 14 | #[derive(ToSchema, Deserialize)] 15 | pub struct Payload { 16 | adapter: BackupAdapter, 17 | } 18 | 19 | #[derive(ToSchema, Serialize)] 20 | struct Response {} 21 | 22 | #[utoipa::path(delete, path = "/", responses( 23 | (status = ACCEPTED, body = inline(Response)), 24 | (status = NOT_FOUND, body = ApiError), 25 | ), params( 26 | ( 27 | "backup" = uuid::Uuid, 28 | description = "The backup uuid", 29 | example = "123e4567-e89b-12d3-a456-426614174000", 30 | ), 31 | ), request_body = inline(Payload))] 32 | pub async fn route( 33 | state: GetState, 34 | Path(backup_id): Path, 35 | axum::Json(data): axum::Json, 36 | ) -> ApiResponseResult { 37 | let backup = match state 38 | .backup_manager 39 | .find_adapter(data.adapter, backup_id) 40 | .await? 41 | { 42 | Some(backup) => backup, 43 | None => { 44 | return ApiResponse::error("backup not found") 45 | .with_status(StatusCode::NOT_FOUND) 46 | .ok(); 47 | } 48 | }; 49 | 50 | tokio::spawn(async move { 51 | if let Err(err) = backup.delete(&state.config).await { 52 | tracing::error!( 53 | backup = %backup.uuid(), 54 | adapter = ?backup.adapter(), 55 | "failed to delete backup: {:#?}", 56 | err 57 | ); 58 | } 59 | }); 60 | 61 | ApiResponse::json(Response {}) 62 | .with_status(StatusCode::ACCEPTED) 63 | .ok() 64 | } 65 | } 66 | 67 | pub fn router(state: &State) -> OpenApiRouter { 68 | OpenApiRouter::new() 69 | .routes(routes!(delete::route)) 70 | .with_state(state.clone()) 71 | } 72 | -------------------------------------------------------------------------------- /application/src/routes/api/system/logs/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod _file_; 5 | 6 | mod get { 7 | use crate::{ 8 | response::{ApiResponse, ApiResponseResult}, 9 | routes::GetState, 10 | }; 11 | use serde::Serialize; 12 | use utoipa::ToSchema; 13 | 14 | #[derive(ToSchema, Serialize)] 15 | struct ResponseLogFile { 16 | name: compact_str::CompactString, 17 | size: u64, 18 | last_modified: chrono::DateTime, 19 | } 20 | 21 | #[derive(ToSchema, Serialize)] 22 | struct Response { 23 | #[schema(inline)] 24 | log_files: Vec, 25 | } 26 | 27 | #[utoipa::path(get, path = "/", responses( 28 | (status = OK, body = inline(Response)), 29 | ))] 30 | pub async fn route(state: GetState) -> ApiResponseResult { 31 | let mut log_files = Vec::new(); 32 | 33 | let mut directory = tokio::fs::read_dir(&state.config.system.log_directory).await?; 34 | while let Ok(Some(entry)) = directory.next_entry().await { 35 | let metadata = match entry.metadata().await { 36 | Ok(metadata) => metadata, 37 | Err(_) => continue, 38 | }; 39 | 40 | if !metadata.is_file() { 41 | continue; 42 | } 43 | 44 | log_files.push(ResponseLogFile { 45 | name: entry.file_name().to_string_lossy().into(), 46 | size: metadata.len(), 47 | last_modified: chrono::DateTime::from_timestamp( 48 | metadata 49 | .modified() 50 | .map(|t| t.duration_since(std::time::UNIX_EPOCH).unwrap_or_default()) 51 | .unwrap_or_default() 52 | .as_secs() as i64, 53 | 0, 54 | ) 55 | .unwrap_or_default(), 56 | }); 57 | } 58 | 59 | log_files.sort_by(|l1, l2| l1.last_modified.cmp(&l2.last_modified)); 60 | 61 | ApiResponse::json(Response { log_files }).ok() 62 | } 63 | } 64 | 65 | pub fn router(state: &State) -> OpenApiRouter { 66 | OpenApiRouter::new() 67 | .routes(routes!(get::route)) 68 | .nest("/{file}", _file_::router(state)) 69 | .with_state(state.clone()) 70 | } 71 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/getbits.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_GETBITS_ 2 | #define _RAR_GETBITS_ 3 | 4 | class BitInput 5 | { 6 | public: 7 | enum BufferSize {MAX_SIZE=0x8000}; // Size of input buffer. 8 | 9 | int InAddr; // Curent byte position in the buffer. 10 | int InBit; // Current bit position in the current byte. 11 | 12 | bool ExternalBuffer; 13 | public: 14 | BitInput(bool AllocBuffer); 15 | ~BitInput(); 16 | 17 | byte *InBuf; // Dynamically allocated input buffer. 18 | 19 | void InitBitInput() 20 | { 21 | InAddr=InBit=0; 22 | } 23 | 24 | // Move forward by 'Bits' bits. 25 | void addbits(uint Bits) 26 | { 27 | Bits+=InBit; 28 | InAddr+=Bits>>3; 29 | InBit=Bits&7; 30 | } 31 | 32 | // Return 16 bits from current position in the buffer. 33 | // Bit at (InAddr,InBit) has the highest position in returning data. 34 | uint getbits() 35 | { 36 | #if defined(LITTLE_ENDIAN) && defined(ALLOW_MISALIGNED) 37 | uint32 BitField=RawGetBE4(InBuf+InAddr); 38 | BitField >>= (16-InBit); 39 | #else 40 | uint BitField=(uint)InBuf[InAddr] << 16; 41 | BitField|=(uint)InBuf[InAddr+1] << 8; 42 | BitField|=(uint)InBuf[InAddr+2]; 43 | BitField >>= (8-InBit); 44 | #endif 45 | return BitField & 0xffff; 46 | } 47 | 48 | 49 | // Return 32 bits from current position in the buffer. 50 | // Bit at (InAddr,InBit) has the highest position in returning data. 51 | uint getbits32() 52 | { 53 | uint BitField=RawGetBE4(InBuf+InAddr); 54 | BitField <<= InBit; 55 | BitField|=(uint)InBuf[InAddr+4] >> (8-InBit); 56 | return BitField & 0xffffffff; 57 | } 58 | 59 | // Return 64 bits from current position in the buffer. 60 | // Bit at (InAddr,InBit) has the highest position in returning data. 61 | uint64 getbits64() 62 | { 63 | uint64 BitField=RawGetBE8(InBuf+InAddr); 64 | BitField <<= InBit; 65 | BitField|=(uint)InBuf[InAddr+8] >> (8-InBit); 66 | return BitField; 67 | } 68 | 69 | void faddbits(uint Bits); 70 | uint fgetbits(); 71 | 72 | // Check if buffer has enough space for IncPtr bytes. Returns 'true' 73 | // if buffer will be overflown. 74 | bool Overflow(uint IncPtr) 75 | { 76 | return InAddr+IncPtr>=MAX_SIZE; 77 | } 78 | 79 | void SetExternalBuffer(byte *Buf); 80 | }; 81 | #endif 82 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/backup/_backup_/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod restore; 5 | 6 | mod delete { 7 | use crate::{ 8 | response::{ApiResponse, ApiResponseResult}, 9 | routes::{ApiError, GetState, api::servers::_server_::GetServer}, 10 | }; 11 | use axum::{extract::Path, http::StatusCode}; 12 | use serde::Serialize; 13 | use utoipa::ToSchema; 14 | 15 | #[derive(ToSchema, Serialize)] 16 | struct Response {} 17 | 18 | #[utoipa::path(delete, path = "/", responses( 19 | (status = ACCEPTED, body = inline(Response)), 20 | (status = NOT_FOUND, body = ApiError), 21 | ), params( 22 | ( 23 | "server" = uuid::Uuid, 24 | description = "The server uuid", 25 | example = "123e4567-e89b-12d3-a456-426614174000", 26 | ), 27 | ( 28 | "backup" = uuid::Uuid, 29 | description = "The backup uuid", 30 | example = "123e4567-e89b-12d3-a456-426614174000", 31 | ), 32 | ))] 33 | pub async fn route( 34 | state: GetState, 35 | server: GetServer, 36 | Path((_server, backup_id)): Path<(uuid::Uuid, uuid::Uuid)>, 37 | ) -> ApiResponseResult { 38 | let backup = match state.backup_manager.find(backup_id).await? { 39 | Some(backup) => backup, 40 | None => { 41 | return ApiResponse::error("backup not found") 42 | .with_status(StatusCode::NOT_FOUND) 43 | .ok(); 44 | } 45 | }; 46 | 47 | tokio::spawn(async move { 48 | if let Err(err) = backup.delete(&state.config).await { 49 | tracing::error!( 50 | server = %server.uuid, 51 | backup = %backup.uuid(), 52 | adapter = ?backup.adapter(), 53 | "failed to delete backup: {:#?}", 54 | err 55 | ); 56 | } 57 | }); 58 | 59 | ApiResponse::json(Response {}) 60 | .with_status(StatusCode::ACCEPTED) 61 | .ok() 62 | } 63 | } 64 | 65 | pub fn router(state: &State) -> OpenApiRouter { 66 | OpenApiRouter::new() 67 | .nest("/restore", restore::router(state)) 68 | .routes(routes!(delete::route)) 69 | .with_state(state.clone()) 70 | } 71 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/crypt3.cpp: -------------------------------------------------------------------------------- 1 | void CryptData::SetKey30(bool Encrypt,SecPassword *Password,const wchar *PwdW,const byte *Salt) 2 | { 3 | byte AESKey[16],AESInit[16]; 4 | 5 | bool Cached=false; 6 | for (uint I=0;I>8); 39 | PswNum[2]=(byte)(I>>16); 40 | sha1_process(&c, PswNum, 3); 41 | if (I%(HashRounds/16)==0) 42 | { 43 | sha1_context tempc=c; 44 | uint32 digest[5]; 45 | sha1_done( &tempc, digest ); 46 | AESInit[I/(HashRounds/16)]=(byte)digest[4]; 47 | } 48 | } 49 | uint32 digest[5]; 50 | sha1_done( &c, digest ); 51 | for (uint I=0;I<4;I++) 52 | for (uint J=0;J<4;J++) 53 | AESKey[I*4+J]=(byte)(digest[I]>>(J*8)); 54 | 55 | KDF3Cache[KDF3CachePos].Pwd=*Password; 56 | if ((KDF3Cache[KDF3CachePos].SaltPresent=(Salt!=NULL))==true) 57 | memcpy(KDF3Cache[KDF3CachePos].Salt,Salt,SIZE_SALT30); 58 | memcpy(KDF3Cache[KDF3CachePos].Key,AESKey,sizeof(AESKey)); 59 | SecHideData(KDF3Cache[KDF3CachePos].Key,sizeof(KDF3Cache[KDF3CachePos].Key),true,false); 60 | memcpy(KDF3Cache[KDF3CachePos].Init,AESInit,sizeof(AESInit)); 61 | KDF3CachePos=(KDF3CachePos+1)%ASIZE(KDF3Cache); 62 | 63 | cleandata(RawPsw,sizeof(RawPsw)); 64 | } 65 | rin.Init(Encrypt, AESKey, 128, AESInit); 66 | cleandata(AESKey,sizeof(AESKey)); 67 | cleandata(AESInit,sizeof(AESInit)); 68 | } 69 | 70 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/unicode.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_UNICODE_ 2 | #define _RAR_UNICODE_ 3 | 4 | #if defined( _WIN_ALL) 5 | #define DBCS_SUPPORTED 6 | #endif 7 | 8 | bool WideToChar(const wchar *Src,char *Dest,size_t DestSize); 9 | bool CharToWide(const char *Src,wchar *Dest,size_t DestSize); 10 | bool WideToChar(const std::wstring &Src,std::string &Dest); 11 | bool CharToWide(const std::string &Src,std::wstring &Dest); 12 | byte* WideToRaw(const wchar *Src,size_t SrcSize,byte *Dest,size_t DestSize); 13 | void WideToRaw(const std::wstring &Src,std::vector &Dest); 14 | wchar* RawToWide(const byte *Src,wchar *Dest,size_t DestSize); 15 | std::wstring RawToWide(const std::vector &Src); 16 | void WideToUtf(const wchar *Src,char *Dest,size_t DestSize); 17 | void WideToUtf(const std::wstring &Src,std::string &Dest); 18 | size_t WideToUtfSize(const wchar *Src); 19 | bool UtfToWide(const char *Src,wchar *Dest,size_t DestSize); 20 | bool UtfToWide(const char *Src,std::wstring &Dest); 21 | //bool UtfToWide(const std::vector &Src,std::wstring &Dest); 22 | bool IsTextUtf8(const byte *Src); 23 | bool IsTextUtf8(const byte *Src,size_t SrcSize); 24 | 25 | int wcsicomp(const wchar *s1,const wchar *s2); 26 | inline int wcsicomp(const std::wstring &s1,const std::wstring &s2) {return wcsicomp(s1.c_str(),s2.c_str());} 27 | int wcsnicomp(const wchar *s1,const wchar *s2,size_t n); 28 | inline int wcsnicomp(const std::wstring &s1,const std::wstring &s2,size_t n) {return wcsnicomp(s1.c_str(),s2.c_str(),n);} 29 | const wchar_t* wcscasestr(const wchar_t *str, const wchar_t *search); 30 | std::wstring::size_type wcscasestr(const std::wstring &str, const std::wstring &search); 31 | #ifndef SFX_MODULE 32 | wchar* wcslower(wchar *s); 33 | void wcslower(std::wstring &s); 34 | wchar* wcsupper(wchar *s); 35 | void wcsupper(std::wstring &s); 36 | #endif 37 | int toupperw(int ch); 38 | int tolowerw(int ch); 39 | int atoiw(const std::wstring &s); 40 | int64 atoilw(const std::wstring &s); 41 | 42 | #ifdef DBCS_SUPPORTED 43 | class SupportDBCS 44 | { 45 | public: 46 | SupportDBCS(); 47 | void Init(); 48 | char* charnext(const char *s); 49 | 50 | bool IsLeadByte[256]; 51 | bool DBCSMode; 52 | }; 53 | extern SupportDBCS gdbcs; 54 | 55 | inline char* charnext(const char *s) {return (char *)(gdbcs.DBCSMode ? gdbcs.charnext(s):s+1);} 56 | inline bool IsDBCSMode() {return gdbcs.DBCSMode;} 57 | 58 | #else 59 | #define charnext(s) ((s)+1) 60 | #define IsDBCSMode() (false) 61 | #endif 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/backup/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod _backup_; 5 | 6 | mod post { 7 | use crate::{ 8 | response::{ApiResponse, ApiResponseResult}, 9 | routes::{ApiError, GetState, api::servers::_server_::GetServer}, 10 | server::backup::adapters::BackupAdapter, 11 | }; 12 | use axum::http::StatusCode; 13 | use serde::{Deserialize, Serialize}; 14 | use utoipa::ToSchema; 15 | 16 | #[derive(ToSchema, Deserialize)] 17 | pub struct Payload { 18 | adapter: BackupAdapter, 19 | uuid: uuid::Uuid, 20 | ignore: compact_str::CompactString, 21 | } 22 | 23 | #[derive(ToSchema, Serialize)] 24 | struct Response {} 25 | 26 | #[utoipa::path(post, path = "/", responses( 27 | (status = ACCEPTED, body = inline(Response)), 28 | (status = CONFLICT, body = ApiError), 29 | ), params( 30 | ( 31 | "server" = uuid::Uuid, 32 | description = "The server uuid", 33 | example = "123e4567-e89b-12d3-a456-426614174000", 34 | ), 35 | ), request_body = inline(Payload))] 36 | pub async fn route( 37 | state: GetState, 38 | server: GetServer, 39 | axum::Json(data): axum::Json, 40 | ) -> ApiResponseResult { 41 | if state.backup_manager.fast_contains(&server, data.uuid).await { 42 | return ApiResponse::error("backup already exists") 43 | .with_status(StatusCode::CONFLICT) 44 | .ok(); 45 | } 46 | 47 | tokio::spawn(async move { 48 | if let Err(err) = state 49 | .backup_manager 50 | .create(data.adapter, &server, data.uuid, data.ignore) 51 | .await 52 | { 53 | tracing::error!( 54 | "failed to create backup {} (adapter = {:?}) for {}: {}", 55 | data.uuid, 56 | data.adapter, 57 | server.uuid, 58 | err 59 | ); 60 | } 61 | }); 62 | 63 | ApiResponse::json(Response {}) 64 | .with_status(StatusCode::ACCEPTED) 65 | .ok() 66 | } 67 | } 68 | 69 | pub fn router(state: &State) -> OpenApiRouter { 70 | OpenApiRouter::new() 71 | .nest("/{backup}", _backup_::router(state)) 72 | .routes(routes!(post::route)) 73 | .with_state(state.clone()) 74 | } 75 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/scantree.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_SCANTREE_ 2 | #define _RAR_SCANTREE_ 3 | 4 | enum SCAN_DIRS 5 | { 6 | SCAN_SKIPDIRS, // Skip directories, but recurse for files if recursion mode is enabled. 7 | SCAN_GETDIRS, // Get subdirectories in recurse mode. 8 | SCAN_GETDIRSTWICE, // Get the directory name both before and after the list of files it contains. 9 | SCAN_GETCURDIRS // Get subdirectories in current directory even in RECURSE_NONE mode. 10 | }; 11 | 12 | enum SCAN_CODE { SCAN_SUCCESS,SCAN_DONE,SCAN_ERROR,SCAN_NEXT }; 13 | 14 | class CommandData; 15 | 16 | class ScanTree 17 | { 18 | private: 19 | static constexpr size_t MAXSCANDEPTH = MAXPATHSIZE/2; 20 | 21 | bool ExpandFolderMask(); 22 | bool GetFilteredMask(); 23 | bool GetNextMask(); 24 | SCAN_CODE FindProc(FindData *FD); 25 | void ScanError(bool &Error); 26 | 27 | // FindFile *FindStack[MAXSCANDEPTH]; 28 | std::vector FindStack; 29 | int Depth; 30 | 31 | int SetAllMaskDepth; 32 | 33 | StringList *FileMasks; 34 | RECURSE_MODE Recurse; 35 | bool GetLinks; 36 | SCAN_DIRS GetDirs; 37 | uint Errors; 38 | 39 | // Set when processing paths like c:\ (root directory without wildcards). 40 | bool ScanEntireDisk; 41 | 42 | std::wstring CurMask; 43 | std::wstring OrigCurMask; 44 | 45 | // Store all folder masks generated from folder wildcard mask in non-recursive mode. 46 | StringList ExpandedFolderList; 47 | 48 | // Store a filter string for folder wildcard in recursive mode. 49 | StringList FilterList; 50 | 51 | // Save the list of unreadable dirs here. 52 | StringList *ErrDirList; 53 | std::vector *ErrDirSpecPathLength; 54 | 55 | // Set if processing a folder wildcard mask. 56 | bool FolderWildcards; 57 | 58 | bool SearchAllInRoot; 59 | size_t SpecPathLength; 60 | 61 | std::wstring ErrArcName; 62 | 63 | CommandData *Cmd; 64 | public: 65 | ScanTree(StringList *FileMasks,RECURSE_MODE Recurse,bool GetLinks,SCAN_DIRS GetDirs); 66 | ~ScanTree(); 67 | SCAN_CODE GetNext(FindData *FindData); 68 | size_t GetSpecPathLength() {return SpecPathLength;} 69 | uint GetErrors() {return Errors;}; 70 | void SetErrArcName(const std::wstring &Name) {ErrArcName=Name;} 71 | void SetCommandData(CommandData *Cmd) {ScanTree::Cmd=Cmd;} 72 | void SetErrDirList(StringList *List,std::vector *Lengths) 73 | { 74 | ErrDirList=List; 75 | ErrDirSpecPathLength=Lengths; 76 | } 77 | }; 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/compress.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_COMPRESS_ 2 | #define _RAR_COMPRESS_ 3 | 4 | // Combine pack and unpack constants to class to avoid polluting global 5 | // namespace with numerous short names. 6 | class PackDef 7 | { 8 | public: 9 | // Maximum LZ match length we can encode even for short distances. 10 | static const uint MAX_LZ_MATCH = 0x1001; 11 | 12 | // We increment LZ match length for longer distances, because shortest 13 | // matches are not allowed for them. Maximum length increment is 3 14 | // for distances larger than 256KB (0x40000). Here we define the maximum 15 | // incremented LZ match. Normally packer does not use it, but we must be 16 | // ready to process it in corrupt archives. 17 | static const uint MAX_INC_LZ_MATCH = MAX_LZ_MATCH + 3; 18 | 19 | static const uint MAX3_LZ_MATCH = 0x101; // Maximum match length for RAR v3. 20 | static const uint MAX3_INC_LZ_MATCH = MAX3_LZ_MATCH + 3; 21 | static const uint LOW_DIST_REP_COUNT = 16; 22 | 23 | static const uint NC = 306; /* alphabet = {0, 1, 2, ..., NC - 1} */ 24 | static const uint DCB = 64; // Base distance codes up to 4 GB. 25 | static const uint DCX = 80; // Extended distance codes up to 1 TB. 26 | static const uint LDC = 16; 27 | static const uint RC = 44; 28 | static const uint HUFF_TABLE_SIZEB = NC + DCB + RC + LDC; 29 | static const uint HUFF_TABLE_SIZEX = NC + DCX + RC + LDC; 30 | static const uint BC = 20; 31 | 32 | static const uint NC30 = 299; /* alphabet = {0, 1, 2, ..., NC - 1} */ 33 | static const uint DC30 = 60; 34 | static const uint LDC30 = 17; 35 | static const uint RC30 = 28; 36 | static const uint BC30 = 20; 37 | static const uint HUFF_TABLE_SIZE30 = NC30 + DC30 + RC30 + LDC30; 38 | 39 | static const uint NC20 = 298; /* alphabet = {0, 1, 2, ..., NC - 1} */ 40 | static const uint DC20 = 48; 41 | static const uint RC20 = 28; 42 | static const uint BC20 = 19; 43 | static const uint MC20 = 257; 44 | 45 | // Largest alphabet size among all values listed above. 46 | static const uint LARGEST_TABLE_SIZE = 306; 47 | 48 | }; 49 | 50 | 51 | enum FilterType { 52 | // These values must not be changed, because we use them directly 53 | // in RAR5 compression and decompression code. 54 | FILTER_DELTA=0, FILTER_E8, FILTER_E8E9, FILTER_ARM, 55 | FILTER_AUDIO, FILTER_RGB, FILTER_ITANIUM, FILTER_TEXT, 56 | 57 | // These values can be changed. 58 | FILTER_LONGRANGE,FILTER_EXHAUSTIVE,FILTER_NONE 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /application/src/models.rs: -------------------------------------------------------------------------------- 1 | use crate::server::state::ServerState; 2 | use serde::{Deserialize, Serialize}; 3 | use std::str::FromStr; 4 | use utoipa::ToSchema; 5 | 6 | #[derive(ToSchema, Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)] 7 | #[serde(rename_all = "lowercase")] 8 | #[schema(rename_all = "lowercase")] 9 | pub enum ServerPowerAction { 10 | Start, 11 | Stop, 12 | Restart, 13 | Kill, 14 | } 15 | 16 | impl FromStr for ServerPowerAction { 17 | type Err = anyhow::Error; 18 | 19 | fn from_str(s: &str) -> Result { 20 | match s { 21 | "start" => Ok(Self::Start), 22 | "stop" => Ok(Self::Stop), 23 | "restart" => Ok(Self::Restart), 24 | "kill" => Ok(Self::Kill), 25 | _ => Err(anyhow::anyhow!( 26 | "invalid server power action provided: {}", 27 | s 28 | )), 29 | } 30 | } 31 | } 32 | 33 | #[derive(ToSchema, Debug, Clone, Copy, Deserialize, Serialize, PartialEq, Eq)] 34 | #[serde(rename_all = "lowercase")] 35 | #[schema(rename_all = "lowercase")] 36 | pub enum ServerBackupStatus { 37 | Starting, 38 | Finished, 39 | Failed, 40 | } 41 | 42 | #[derive(ToSchema, Serialize)] 43 | pub struct Server { 44 | pub state: ServerState, 45 | pub is_suspended: bool, 46 | pub utilization: crate::server::resources::ResourceUsage, 47 | pub configuration: crate::server::configuration::ServerConfiguration, 48 | } 49 | 50 | #[derive(ToSchema, Serialize)] 51 | pub struct DirectoryEntry { 52 | pub name: compact_str::CompactString, 53 | pub created: chrono::DateTime, 54 | pub modified: chrono::DateTime, 55 | pub mode: compact_str::CompactString, 56 | pub mode_bits: compact_str::CompactString, 57 | pub size: u64, 58 | pub directory: bool, 59 | pub file: bool, 60 | pub symlink: bool, 61 | pub mime: &'static str, 62 | } 63 | 64 | #[derive(ToSchema, Serialize)] 65 | pub struct Download { 66 | pub identifier: uuid::Uuid, 67 | pub destination: String, 68 | 69 | pub progress: u64, 70 | pub total: u64, 71 | } 72 | 73 | #[derive(ToSchema, Serialize)] 74 | #[serde(rename_all = "lowercase")] 75 | pub enum PullProgressStatus { 76 | Pulling, 77 | Extracting, 78 | } 79 | 80 | #[derive(ToSchema, Serialize)] 81 | pub struct PullProgress { 82 | pub status: PullProgressStatus, 83 | pub progress: i64, 84 | pub total: i64, 85 | } 86 | 87 | #[derive(ToSchema, Serialize)] 88 | pub struct Progress { 89 | pub progress: u64, 90 | pub total: u64, 91 | } 92 | -------------------------------------------------------------------------------- /application/src/io/compression/mod.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | use utoipa::ToSchema; 3 | 4 | pub mod reader; 5 | pub mod writer; 6 | 7 | #[derive(Clone, Copy)] 8 | pub enum CompressionType { 9 | None, 10 | Gz, 11 | Xz, 12 | Bz2, 13 | Lz4, 14 | Zstd, 15 | } 16 | 17 | #[derive(Clone, Copy, ToSchema, Deserialize, Serialize, Default)] 18 | #[serde(rename_all = "snake_case")] 19 | #[schema(rename_all = "snake_case")] 20 | pub enum CompressionLevel { 21 | #[default] 22 | BestSpeed, 23 | GoodSpeed, 24 | GoodCompression, 25 | BestCompression, 26 | } 27 | 28 | impl CompressionLevel { 29 | #[inline] 30 | pub const fn to_deflate_level(self) -> u32 { 31 | match self { 32 | CompressionLevel::BestSpeed => 1, 33 | CompressionLevel::GoodSpeed => 4, 34 | CompressionLevel::GoodCompression => 6, 35 | CompressionLevel::BestCompression => 9, 36 | } 37 | } 38 | 39 | #[inline] 40 | pub const fn to_xz_level(self) -> u32 { 41 | match self { 42 | CompressionLevel::BestSpeed => 1, 43 | CompressionLevel::GoodSpeed => 4, 44 | CompressionLevel::GoodCompression => 6, 45 | CompressionLevel::BestCompression => 9, 46 | } 47 | } 48 | 49 | #[inline] 50 | pub const fn to_bz2_level(self) -> u32 { 51 | match self { 52 | CompressionLevel::BestSpeed => 1, 53 | CompressionLevel::GoodSpeed => 4, 54 | CompressionLevel::GoodCompression => 6, 55 | CompressionLevel::BestCompression => 9, 56 | } 57 | } 58 | 59 | #[inline] 60 | pub const fn to_zstd_level(self) -> i32 { 61 | match self { 62 | CompressionLevel::BestSpeed => 1, 63 | CompressionLevel::GoodSpeed => 8, 64 | CompressionLevel::GoodCompression => 14, 65 | CompressionLevel::BestCompression => 22, 66 | } 67 | } 68 | 69 | #[inline] 70 | pub const fn to_lzma2_level(self) -> u32 { 71 | match self { 72 | CompressionLevel::BestSpeed => 1, 73 | CompressionLevel::GoodSpeed => 4, 74 | CompressionLevel::GoodCompression => 6, 75 | CompressionLevel::BestCompression => 9, 76 | } 77 | } 78 | 79 | #[inline] 80 | pub const fn to_lz4_level(self) -> i32 { 81 | match self { 82 | CompressionLevel::BestSpeed => 1, 83 | CompressionLevel::GoodSpeed => 5, 84 | CompressionLevel::GoodCompression => 8, 85 | CompressionLevel::BestCompression => 12, 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/mod.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | pub mod _server_; 5 | 6 | mod get { 7 | use crate::{ 8 | response::{ApiResponse, ApiResponseResult}, 9 | routes::GetState, 10 | }; 11 | 12 | #[utoipa::path(get, path = "/", responses( 13 | (status = OK, body = Vec), 14 | ))] 15 | pub async fn route(state: GetState) -> ApiResponseResult { 16 | let mut servers = Vec::new(); 17 | 18 | for server in state.server_manager.get_servers().await.iter() { 19 | servers.push(server.to_api_response().await); 20 | } 21 | 22 | ApiResponse::json(servers).ok() 23 | } 24 | } 25 | 26 | mod post { 27 | use crate::{ 28 | response::{ApiResponse, ApiResponseResult}, 29 | routes::{ApiError, GetState}, 30 | }; 31 | use axum::http::StatusCode; 32 | use serde::{Deserialize, Serialize}; 33 | use utoipa::ToSchema; 34 | 35 | #[derive(ToSchema, Deserialize)] 36 | pub struct Payload { 37 | uuid: uuid::Uuid, 38 | #[serde(default)] 39 | start_on_completion: bool, 40 | #[serde(default)] 41 | skip_scripts: bool, 42 | } 43 | 44 | #[derive(ToSchema, Serialize)] 45 | struct Response {} 46 | 47 | #[utoipa::path(post, path = "/", responses( 48 | (status = OK, body = inline(Response)), 49 | (status = CONFLICT, body = ApiError) 50 | ), request_body = inline(Payload))] 51 | pub async fn route( 52 | state: GetState, 53 | axum::Json(data): axum::Json, 54 | ) -> ApiResponseResult { 55 | if state 56 | .server_manager 57 | .get_servers() 58 | .await 59 | .iter() 60 | .any(|s| s.uuid == data.uuid) 61 | { 62 | return ApiResponse::error("server with this uuid already exists") 63 | .with_status(StatusCode::CONFLICT) 64 | .ok(); 65 | } 66 | 67 | let mut server_data = state.config.client.server(data.uuid).await?; 68 | server_data.settings.start_on_completion = Some(data.start_on_completion); 69 | 70 | state 71 | .server_manager 72 | .create_server(&state, server_data, !data.skip_scripts) 73 | .await; 74 | 75 | ApiResponse::json(Response {}).ok() 76 | } 77 | } 78 | 79 | pub fn router(state: &State) -> OpenApiRouter { 80 | OpenApiRouter::new() 81 | .nest("/{server}", _server_::router(state)) 82 | .routes(routes!(get::route)) 83 | .routes(routes!(post::route)) 84 | .with_state(state.clone()) 85 | } 86 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/uicommon.cpp: -------------------------------------------------------------------------------- 1 | static bool GetAutoRenamedName(std::wstring &Name); 2 | static SOUND_NOTIFY_MODE uiSoundNotify; 3 | 4 | void uiInit(SOUND_NOTIFY_MODE Sound) 5 | { 6 | uiSoundNotify = Sound; 7 | } 8 | 9 | 10 | // Additionally to handling user input, it analyzes and sets command options. 11 | // Returns only 'replace', 'skip' and 'cancel' codes. 12 | UIASKREP_RESULT uiAskReplaceEx(CommandData *Cmd,std::wstring &Name,int64 FileSize,RarTime *FileTime,uint Flags) 13 | { 14 | if (Cmd->Overwrite==OVERWRITE_NONE) 15 | return UIASKREP_R_SKIP; 16 | 17 | #if !defined(SFX_MODULE) && !defined(SILENT) 18 | // Must be before Cmd->AllYes check or -y switch would override -or. 19 | if (Cmd->Overwrite==OVERWRITE_AUTORENAME && GetAutoRenamedName(Name)) 20 | return UIASKREP_R_REPLACE; 21 | #endif 22 | 23 | std::wstring NewName=Name; 24 | UIASKREP_RESULT Choice=Cmd->AllYes || Cmd->Overwrite==OVERWRITE_ALL ? 25 | UIASKREP_R_REPLACE : uiAskReplace(NewName,FileSize,FileTime,Flags); 26 | 27 | if (Choice==UIASKREP_R_REPLACE || Choice==UIASKREP_R_REPLACEALL) 28 | { 29 | PrepareToDelete(Name); 30 | 31 | // Overwrite the link itself instead of its target. 32 | // For normal files we prefer to inherit file attributes, permissions 33 | // and hard links. 34 | FindData FD; 35 | if (FindFile::FastFind(Name,&FD,true) && FD.IsLink) 36 | DelFile(Name); 37 | } 38 | 39 | if (Choice==UIASKREP_R_REPLACEALL) 40 | { 41 | Cmd->Overwrite=OVERWRITE_ALL; 42 | return UIASKREP_R_REPLACE; 43 | } 44 | if (Choice==UIASKREP_R_SKIPALL) 45 | { 46 | Cmd->Overwrite=OVERWRITE_NONE; 47 | return UIASKREP_R_SKIP; 48 | } 49 | if (Choice==UIASKREP_R_RENAME) 50 | { 51 | if (GetNamePos(NewName)==0) 52 | SetName(Name,NewName); 53 | else 54 | Name=NewName; 55 | if (FileExist(Name)) 56 | return uiAskReplaceEx(Cmd,Name,FileSize,FileTime,Flags); 57 | return UIASKREP_R_REPLACE; 58 | } 59 | #if !defined(SFX_MODULE) && !defined(SILENT) 60 | if (Choice==UIASKREP_R_RENAMEAUTO && GetAutoRenamedName(Name)) 61 | { 62 | Cmd->Overwrite=OVERWRITE_AUTORENAME; 63 | return UIASKREP_R_REPLACE; 64 | } 65 | #endif 66 | return Choice; 67 | } 68 | 69 | 70 | bool GetAutoRenamedName(std::wstring &Name) 71 | { 72 | std::wstring Ext=GetExt(Name); 73 | for (uint FileVer=1;FileVer<1000000;FileVer++) 74 | { 75 | std::wstring NewName=Name; 76 | RemoveExt(NewName); 77 | wchar Ver[10]; 78 | itoa(FileVer,Ver,ASIZE(Ver)); 79 | NewName = NewName + L"(" + Ver + L")" + Ext; 80 | if (!FileExist(NewName)) 81 | { 82 | Name=NewName; 83 | return true; 84 | } 85 | } 86 | return false; 87 | } 88 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/suballoc.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * This file is part of PPMd project * 3 | * Written and distributed to public domain by Dmitry Shkarin 1997, * 4 | * 1999-2000 * 5 | * Contents: interface to memory allocation routines * 6 | ****************************************************************************/ 7 | #if !defined(_SUBALLOC_H_) 8 | #define _SUBALLOC_H_ 9 | 10 | #if defined(__GNUC__) && defined(ALLOW_MISALIGNED) 11 | #define RARPPM_PACK_ATTR __attribute__ ((packed)) 12 | #else 13 | #define RARPPM_PACK_ATTR 14 | #endif /* defined(__GNUC__) */ 15 | 16 | #ifdef ALLOW_MISALIGNED 17 | #pragma pack(1) 18 | #endif 19 | 20 | struct RARPPM_MEM_BLK 21 | { 22 | ushort Stamp, NU; 23 | RARPPM_MEM_BLK* next, * prev; 24 | void insertAt(RARPPM_MEM_BLK* p) 25 | { 26 | next=(prev=p)->next; 27 | p->next=next->prev=this; 28 | } 29 | void remove() 30 | { 31 | prev->next=next; 32 | next->prev=prev; 33 | } 34 | } RARPPM_PACK_ATTR; 35 | 36 | #ifdef ALLOW_MISALIGNED 37 | #ifdef _AIX 38 | #pragma pack(pop) 39 | #else 40 | #pragma pack() 41 | #endif 42 | #endif 43 | 44 | 45 | class SubAllocator 46 | { 47 | private: 48 | static const int N1=4, N2=4, N3=4, N4=(128+3-1*N1-2*N2-3*N3)/4; 49 | static const int N_INDEXES=N1+N2+N3+N4; 50 | 51 | struct RAR_NODE 52 | { 53 | RAR_NODE* next; 54 | }; 55 | 56 | inline void InsertNode(void* p,int indx); 57 | inline void* RemoveNode(int indx); 58 | inline uint U2B(int NU); 59 | inline void SplitBlock(void* pv,int OldIndx,int NewIndx); 60 | inline void GlueFreeBlocks(); 61 | void* AllocUnitsRare(int indx); 62 | inline RARPPM_MEM_BLK* MBPtr(RARPPM_MEM_BLK *BasePtr,int Items); 63 | 64 | long SubAllocatorSize; 65 | byte Indx2Units[N_INDEXES], Units2Indx[128], GlueCount; 66 | byte *HeapStart,*LoUnit, *HiUnit; 67 | struct RAR_NODE FreeList[N_INDEXES]; 68 | public: 69 | SubAllocator(); 70 | ~SubAllocator() {StopSubAllocator();} 71 | void Clean(); 72 | bool StartSubAllocator(int SASize); 73 | void StopSubAllocator(); 74 | void InitSubAllocator(); 75 | inline void* AllocContext(); 76 | inline void* AllocUnits(int NU); 77 | inline void* ExpandUnits(void* ptr,int OldNU); 78 | inline void* ShrinkUnits(void* ptr,int OldNU,int NewNU); 79 | inline void FreeUnits(void* ptr,int OldNU); 80 | long GetAllocatedMemory() {return(SubAllocatorSize);} 81 | 82 | byte *pText, *UnitsStart,*HeapEnd,*FakeUnitsStart; 83 | }; 84 | 85 | 86 | #endif /* !defined(_SUBALLOC_H_) */ 87 | -------------------------------------------------------------------------------- /application/src/routes/api/servers/_server_/files/create_directory.rs: -------------------------------------------------------------------------------- 1 | use super::State; 2 | use utoipa_axum::{router::OpenApiRouter, routes}; 3 | 4 | mod post { 5 | use crate::{ 6 | response::{ApiResponse, ApiResponseResult}, 7 | routes::{ApiError, api::servers::_server_::GetServer}, 8 | }; 9 | use axum::http::StatusCode; 10 | use serde::{Deserialize, Serialize}; 11 | use std::path::PathBuf; 12 | use utoipa::ToSchema; 13 | 14 | #[derive(ToSchema, Deserialize)] 15 | pub struct Payload { 16 | name: compact_str::CompactString, 17 | path: compact_str::CompactString, 18 | } 19 | 20 | #[derive(ToSchema, Serialize)] 21 | struct Response {} 22 | 23 | #[utoipa::path(post, path = "/", responses( 24 | (status = OK, body = inline(Response)), 25 | (status = NOT_FOUND, body = ApiError), 26 | (status = EXPECTATION_FAILED, body = ApiError), 27 | ), params( 28 | ( 29 | "server" = uuid::Uuid, 30 | description = "The server uuid", 31 | example = "123e4567-e89b-12d3-a456-426614174000", 32 | ), 33 | ), request_body = inline(Payload))] 34 | pub async fn route( 35 | server: GetServer, 36 | axum::Json(data): axum::Json, 37 | ) -> ApiResponseResult { 38 | let path = match server.filesystem.async_canonicalize(&data.path).await { 39 | Ok(path) => path, 40 | Err(_) => PathBuf::from(data.path), 41 | }; 42 | 43 | let metadata = server.filesystem.async_metadata(&path).await; 44 | if !metadata.map(|m| m.is_dir()).unwrap_or(true) { 45 | return ApiResponse::error("path is not a directory") 46 | .with_status(StatusCode::EXPECTATION_FAILED) 47 | .ok(); 48 | } 49 | 50 | if server.filesystem.is_ignored(&path, true).await { 51 | return ApiResponse::error("path not found") 52 | .with_status(StatusCode::NOT_FOUND) 53 | .ok(); 54 | } 55 | 56 | let destination = path.join(&data.name); 57 | 58 | if server.filesystem.is_ignored(&destination, true).await { 59 | return ApiResponse::error("destination not found") 60 | .with_status(StatusCode::EXPECTATION_FAILED) 61 | .ok(); 62 | } 63 | 64 | server.filesystem.async_create_dir_all(&destination).await?; 65 | server.filesystem.chown_path(&destination).await?; 66 | 67 | ApiResponse::json(Response {}).ok() 68 | } 69 | } 70 | 71 | pub fn router(state: &State) -> OpenApiRouter { 72 | OpenApiRouter::new() 73 | .routes(routes!(post::route)) 74 | .with_state(state.clone()) 75 | } 76 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | if cfg!(windows) { 3 | println!("cargo:rustc-flags=-lpowrprof"); 4 | println!("cargo:rustc-link-lib=shell32"); 5 | if cfg!(target_env = "gnu") { 6 | println!("cargo:rustc-link-lib=pthread"); 7 | } 8 | } else { 9 | println!("cargo:rustc-link-lib=pthread"); 10 | } 11 | let files: Vec = [ 12 | "strlist", 13 | "strfn", 14 | "pathfn", 15 | "smallfn", 16 | "global", 17 | "file", 18 | "filefn", 19 | "filcreat", 20 | "archive", 21 | "arcread", 22 | "unicode", 23 | "system", 24 | #[cfg(windows)] 25 | "isnt", 26 | "crypt", 27 | "crc", 28 | "rawread", 29 | "encname", 30 | "match", 31 | "timefn", 32 | "rdwrfn", 33 | "consio", 34 | "options", 35 | "errhnd", 36 | "rarvm", 37 | "secpassword", 38 | "rijndael", 39 | "getbits", 40 | "sha1", 41 | "sha256", 42 | "blake2s", 43 | "hash", 44 | "extinfo", 45 | "extract", 46 | "volume", 47 | "list", 48 | "find", 49 | "unpack", 50 | "headers", 51 | "threadpool", 52 | "rs16", 53 | "cmddata", 54 | "ui", 55 | "filestr", 56 | "scantree", 57 | "dll", 58 | "qopen", 59 | ] 60 | .iter() 61 | .map(|&s| format!("vendor/unrar/{s}.cpp")) 62 | .collect(); 63 | cc::Build::new() 64 | .cpp(true) // Switch to C++ library compilation. 65 | .opt_level(2) 66 | .std("c++14") 67 | // by default cc crate tries to link against dynamic stdlib, which causes problems on windows-gnu target 68 | .cpp_link_stdlib(None) 69 | .warnings(false) 70 | .extra_warnings(false) 71 | .flag_if_supported("-stdlib=libc++") 72 | .flag_if_supported("-fPIC") 73 | .flag_if_supported("-Wno-switch") 74 | .flag_if_supported("-Wno-parentheses") 75 | .flag_if_supported("-Wno-macro-redefined") 76 | .flag_if_supported("-Wno-dangling-else") 77 | .flag_if_supported("-Wno-logical-op-parentheses") 78 | .flag_if_supported("-Wno-unused-parameter") 79 | .flag_if_supported("-Wno-unused-variable") 80 | .flag_if_supported("-Wno-unused-function") 81 | .flag_if_supported("-Wno-missing-braces") 82 | .flag_if_supported("-Wno-unknown-pragmas") 83 | .flag_if_supported("-Wno-deprecated-declarations") 84 | .define("_FILE_OFFSET_BITS", Some("64")) 85 | .define("_LARGEFILE_SOURCE", None) 86 | .define("RAR_SMP", None) 87 | .define("RARDLL", None) 88 | .files(&files) 89 | .compile("libunrar.a"); 90 | } 91 | -------------------------------------------------------------------------------- /application/src/routes/api/mod.rs: -------------------------------------------------------------------------------- 1 | use super::{GetState, State}; 2 | use crate::response::ApiResponse; 3 | use axum::{ 4 | body::Body, 5 | extract::Request, 6 | http::{Response, StatusCode}, 7 | middleware::Next, 8 | response::IntoResponse, 9 | routing::any, 10 | }; 11 | use utoipa_axum::router::OpenApiRouter; 12 | 13 | mod backups; 14 | pub mod servers; 15 | mod system; 16 | mod transfers; 17 | mod update; 18 | 19 | pub async fn auth(state: GetState, req: Request, next: Next) -> Result, StatusCode> { 20 | let key = req 21 | .headers() 22 | .get("Authorization") 23 | .and_then(|v| v.to_str().ok()) 24 | .unwrap_or("") 25 | .to_string(); 26 | let (r#type, token) = match key.split_once(' ') { 27 | Some((t, tok)) => (t, tok), 28 | None => { 29 | return Ok(ApiResponse::error("invalid authorization header") 30 | .with_status(StatusCode::UNAUTHORIZED) 31 | .with_header("WWW-Authenticate", "Bearer") 32 | .into_response()); 33 | } 34 | }; 35 | 36 | if r#type != "Bearer" { 37 | return Ok(ApiResponse::error("invalid authorization header") 38 | .with_status(StatusCode::UNAUTHORIZED) 39 | .with_header("WWW-Authenticate", "Bearer") 40 | .into_response()); 41 | } 42 | 43 | if !constant_time_eq::constant_time_eq(token.as_bytes(), state.config.token.as_bytes()) { 44 | return Ok(ApiResponse::error("invalid authorization token") 45 | .with_status(StatusCode::UNAUTHORIZED) 46 | .with_header("WWW-Authenticate", "Bearer") 47 | .into_response()); 48 | } 49 | 50 | Ok(next.run(req).await) 51 | } 52 | 53 | pub fn router(state: &State) -> OpenApiRouter { 54 | OpenApiRouter::new() 55 | .nest( 56 | "/system", 57 | system::router(state) 58 | .route_layer(axum::middleware::from_fn_with_state(state.clone(), auth)), 59 | ) 60 | .nest( 61 | "/update", 62 | update::router(state) 63 | .route_layer(axum::middleware::from_fn_with_state(state.clone(), auth)), 64 | ) 65 | .nest("/transfers", transfers::router(state)) 66 | .nest( 67 | "/servers", 68 | servers::router(state) 69 | .route_layer(axum::middleware::from_fn_with_state(state.clone(), auth)), 70 | ) 71 | .nest( 72 | "/backups", 73 | backups::router(state) 74 | .route_layer(axum::middleware::from_fn_with_state(state.clone(), auth)), 75 | ) 76 | .route( 77 | "/servers/{server}/ws", 78 | any(crate::server::websocket::handler::handle_ws), 79 | ) 80 | .with_state(state.clone()) 81 | } 82 | -------------------------------------------------------------------------------- /application/src/server/configuration/process/json.rs: -------------------------------------------------------------------------------- 1 | use super::ServerConfigurationFile; 2 | 3 | pub struct JsonFileParser; 4 | 5 | #[async_trait::async_trait] 6 | impl super::ProcessConfigurationFileParser for JsonFileParser { 7 | async fn process_file( 8 | content: &str, 9 | config: &ServerConfigurationFile, 10 | server: &crate::server::Server, 11 | ) -> Result, anyhow::Error> { 12 | tracing::debug!( 13 | server = %server.uuid, 14 | "processing json file" 15 | ); 16 | 17 | let mut json = if content.trim().is_empty() { 18 | serde_json::Value::Object(serde_json::Map::new()) 19 | } else { 20 | serde_json::from_str(content) 21 | .unwrap_or_else(|_| serde_json::Value::Object(serde_json::Map::new())) 22 | }; 23 | 24 | for replacement in &config.replace { 25 | let value = match &replacement.replace_with { 26 | serde_json::Value::String(_) => { 27 | let resolved = ServerConfigurationFile::replace_all_placeholders( 28 | server, 29 | &replacement.replace_with, 30 | ) 31 | .await?; 32 | 33 | serde_json::from_str(&resolved) 34 | .unwrap_or_else(|_| serde_json::Value::String(resolved.into())) 35 | } 36 | other => other.clone(), 37 | }; 38 | 39 | let path: Vec<&str> = replacement.r#match.split('.').collect(); 40 | set_nested_value( 41 | &mut json, 42 | &path, 43 | value, 44 | replacement.insert_new.unwrap_or(true), 45 | replacement.update_existing, 46 | ); 47 | } 48 | 49 | Ok(serde_json::to_vec_pretty(&json)?) 50 | } 51 | } 52 | 53 | pub fn set_nested_value( 54 | json: &mut serde_json::Value, 55 | path: &[&str], 56 | value: serde_json::Value, 57 | insert_new: bool, 58 | update_existing: bool, 59 | ) { 60 | if path.is_empty() { 61 | return; 62 | } 63 | 64 | if !json.is_object() { 65 | *json = serde_json::Value::Object(serde_json::Map::new()); 66 | } 67 | 68 | let map = json.as_object_mut().unwrap(); 69 | 70 | if path.len() == 1 { 71 | let key = path[0].to_string(); 72 | let exists = map.contains_key(&key); 73 | 74 | if (exists && update_existing) || (!exists && insert_new) { 75 | map.insert(key, value); 76 | } 77 | return; 78 | } 79 | 80 | let child = map 81 | .entry(path[0].to_string()) 82 | .or_insert_with(|| serde_json::Value::Object(serde_json::Map::new())); 83 | 84 | set_nested_value(child, &path[1..], value, insert_new, update_existing); 85 | } 86 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/recvol.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_RECVOL_ 2 | #define _RAR_RECVOL_ 3 | 4 | #define REV5_SIGN "Rar!\x1aRev" 5 | #define REV5_SIGN_SIZE 8 6 | 7 | class RecVolumes3 8 | { 9 | private: 10 | File *SrcFile[256]; 11 | std::vector Buf; 12 | 13 | #ifdef RAR_SMP 14 | ThreadPool *RSThreadPool; 15 | #endif 16 | public: 17 | RecVolumes3(CommandData *Cmd,bool TestOnly); 18 | ~RecVolumes3(); 19 | void Make(CommandData *Cmd,std::wstring ArcName); 20 | bool Restore(CommandData *Cmd,const std::wstring &Name,bool Silent); 21 | void Test(CommandData *Cmd,const std::wstring &Name); 22 | }; 23 | 24 | 25 | struct RecVolItem 26 | { 27 | File *f; 28 | std::wstring Name; 29 | uint CRC; 30 | uint64 FileSize; 31 | bool New; // Newly created RAR volume. 32 | bool Valid; // If existing RAR volume is valid. 33 | }; 34 | 35 | 36 | class RecVolumes5; 37 | struct RecRSThreadData 38 | { 39 | RecVolumes5 *RecRSPtr; 40 | RSCoder16 *RS; 41 | bool Encode; 42 | uint DataNum; 43 | const byte *Data; 44 | size_t StartPos; 45 | size_t Size; 46 | }; 47 | 48 | class RecVolumes5 49 | { 50 | private: 51 | void ProcessRS(CommandData *Cmd,uint DataNum,const byte *Data,uint MaxRead,bool Encode); 52 | void ProcessRS(CommandData *Cmd,uint MaxRead,bool Encode); 53 | uint ReadHeader(File *RecFile,bool FirstRev); 54 | 55 | std::vector RecItems; 56 | 57 | byte *RealReadBuffer; // Real pointer returned by 'new'. 58 | byte *ReadBuffer; // Pointer aligned for SSE instructions. 59 | 60 | byte *RealBuf; // Real pointer returned by 'new'. 61 | byte *Buf; // Store ECC or recovered data here, aligned for SSE. 62 | size_t RecBufferSize; // Buffer area allocated for single volume. 63 | 64 | uint DataCount; // Number of archives. 65 | uint RecCount; // Number of recovery volumes. 66 | uint TotalCount; // Total number of archives and recovery volumes. 67 | 68 | bool *ValidFlags; // Volume validity flags for recovering. 69 | uint MissingVolumes; // Number of missing or bad RAR volumes. 70 | 71 | #ifdef RAR_SMP 72 | ThreadPool *RecThreadPool; 73 | #endif 74 | uint MaxUserThreads; // Maximum number of threads defined by user. 75 | RecRSThreadData *ThreadData; // Array to store thread parameters. 76 | public: // 'public' only because called from thread functions. 77 | void ProcessAreaRS(RecRSThreadData *td); 78 | public: 79 | RecVolumes5(CommandData *Cmd,bool TestOnly); 80 | ~RecVolumes5(); 81 | bool Restore(CommandData *Cmd,const std::wstring &Name,bool Silent); 82 | void Test(CommandData *Cmd,const std::wstring &Name); 83 | }; 84 | 85 | bool RecVolumesRestore(CommandData *Cmd,const std::wstring &Name,bool Silent); 86 | void RecVolumesTest(CommandData *Cmd,Archive *Arc,const std::wstring &Name); 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/timefn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_TIMEFN_ 2 | #define _RAR_TIMEFN_ 3 | 4 | struct RarLocalTime 5 | { 6 | uint Year; 7 | uint Month; 8 | uint Day; 9 | uint Hour; 10 | uint Minute; 11 | uint Second; 12 | uint Reminder; // Part of time smaller than 1 second, represented in 1/REMINDER_PRECISION intervals. 13 | uint wDay; 14 | uint yDay; 15 | }; 16 | 17 | 18 | class RarTime 19 | { 20 | private: 21 | static const uint TICKS_PER_SECOND = 1000000000; // Internal precision. 22 | 23 | // Internal time representation in 1/TICKS_PER_SECOND since 01.01.1601. 24 | // We use nanoseconds here to handle the high precision Unix time. 25 | // It allows dates up to July 2185. 26 | // 27 | // If we'll ever need to extend the date range, we can define a lower 28 | // precision Windows version of TICKS_PER_SECOND. But then Unix and Windows 29 | // versions can differ in least significant digits of "lt" time output 30 | // for Unix archives. 31 | // Alternatively we can introduce 'bool HighPrecision' set to true 32 | // in SetUnixNS() and TicksPerSecond() instead of constant above. 33 | // It might be more reliable than defining TicksPerSecond variable, 34 | // which wouldn't survive memset of any structure hosting RarTime. 35 | // We would need to eliminate all such memsets in the entire code first. 36 | uint64 itime; 37 | public: 38 | // RarLocalTime::Reminder precision. Must be equal to TICKS_PER_SECOND. 39 | // Unlike TICKS_PER_SECOND, it is a public field. 40 | static const uint REMINDER_PRECISION = TICKS_PER_SECOND; 41 | public: 42 | RarTime() {Reset();} 43 | bool operator == (RarTime &rt) {return itime==rt.itime;} 44 | bool operator != (RarTime &rt) {return itime!=rt.itime;} 45 | bool operator < (RarTime &rt) {return itime (RarTime &rt) {return itime>rt.itime;} 48 | bool operator >= (RarTime &rt) {return itime>rt.itime || itime==rt.itime;} 49 | 50 | void GetLocal(RarLocalTime *lt); 51 | void SetLocal(RarLocalTime *lt); 52 | #ifdef _WIN_ALL 53 | void GetWinFT(FILETIME *ft); 54 | void SetWinFT(FILETIME *ft); 55 | #endif 56 | uint64 GetWin(); 57 | void SetWin(uint64 WinTime); 58 | time_t GetUnix(); 59 | void SetUnix(time_t ut); 60 | uint64 GetUnixNS(); 61 | void SetUnixNS(uint64 ns); 62 | uint GetDos(); 63 | void SetDos(uint DosTime); 64 | void GetText(wchar *DateStr,size_t MaxSize,bool FullMS); 65 | void SetIsoText(const wchar *TimeText); 66 | void SetAgeText(const wchar *TimeText); 67 | void SetCurrentTime(); 68 | void Reset() {itime=0;} 69 | bool IsSet() {return itime!=0;} 70 | void Adjust(int64 ns); 71 | }; 72 | 73 | const wchar *GetMonthName(uint Month); 74 | bool IsLeapYear(uint Year); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /application/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wings-rs" 3 | version = "0.22.5" 4 | edition = "2024" 5 | 6 | [dependencies] 7 | unrar = { path = "../unrar-rs" } 8 | tracing = "0.1.41" 9 | tracing-subscriber = { version = "0.3.19", features = ["chrono"] } 10 | tracing-appender = "0.2.3" 11 | anyhow = { workspace = true } 12 | axum = { workspace = true } 13 | axum-server = { workspace = true } 14 | axum-extra = { workspace = true } 15 | bollard = { workspace = true } 16 | serde = { workspace = true } 17 | serde_json = { workspace = true } 18 | utoipa = { workspace = true } 19 | utoipa-axum = { workspace = true } 20 | reqwest = { workspace = true } 21 | tokio = { workspace = true } 22 | colored = "3.0.0" 23 | chrono = { workspace = true } 24 | nestify = "0.3.3" 25 | rayon = "1.10.0" 26 | serde_yml = "0.0.12" 27 | serde_default = "0.2.0" 28 | users = "0.11.0" 29 | futures-util = { workspace = true } 30 | tokio-util = { workspace = true } 31 | uuid = { workspace = true } 32 | rand = { workspace = true } 33 | tar = "0.4.44" 34 | zip = { version = "6.0.0", default-features = false, features = ["bzip2", "deflate", "sha1", "time", "zstd", "lzma", "xz"] } 35 | sevenz-rust2 = { version = "0.20.0", features = ["deflate", "compress", "brotli", "zstd", "bzip2", "ppmd", "lz4"] } 36 | flate2 = { version = "1.1.1", features = ["zlib-rs"], default-features = false } 37 | jwt = "0.16.0" 38 | hmac = { version = "0.12.1", features = ["std"] } 39 | sha2 = "0.10.9" 40 | ddup-bak = "0.7.0" 41 | infer = "0.19.0" 42 | rustls = { version = "0.23.27", features = ["ring"] } 43 | ignore = { version = "0.4.23", features = ["simd-accel"] } 44 | sha1 = "0.10.6" 45 | futures = "0.3.31" 46 | russh = "0.55.0" 47 | russh-sftp = "2.1.1" 48 | md5 = "0.8.0" 49 | human_bytes = "0.4.3" 50 | ansi_term = "0.12.1" 51 | clap = "4.5.37" 52 | dialoguer = "0.12.0" 53 | sysinfo = "0.37.0" 54 | crc32fast = "1.4.2" 55 | cap-std = "4.0.0" 56 | rustix = { version = "1.0.7", features = ["system"] } 57 | cidr = { version = "0.3.1", features = ["serde"] } 58 | hickory-resolver = "0.25.2" 59 | constant_time_eq = "0.4.2" 60 | new_mime_guess = "4.0.4" 61 | async-trait = "0.1.88" 62 | content_disposition = "0.4.0" 63 | cron = { version = "0.15.0", features = ["serde"] } 64 | chrono-tz = "0.10.4" 65 | gzp = "2.0.0" 66 | lzma-rust2 = { version = "0.15.4", features = ["optimization"] } 67 | bzip2 = "0.6.0" 68 | zstd = { version = "0.13.3", features = ["zstdmt"] } 69 | base64 = "0.22.1" 70 | chunked_vec = "=0.3.4" 71 | async-channel = "2.5.0" 72 | lzzzz = "2.0.0" 73 | xmltree = { version = "0.12.0", features = ["indexmap"] } 74 | java-properties = "2.0.0" 75 | rust-ini = "0.21.3" 76 | regex = "1.12.2" 77 | serde_regex = "1.1.0" 78 | compact_str = { git = "https://github.com/0x7d8/compact_str.git", version = "0.9.0", features = ["serde", "utoipa"] } 79 | 80 | [target.'cfg(target_os = "linux")'.dependencies] 81 | tikv-jemallocator = "0.6.0" 82 | 83 | [build-dependencies] 84 | serde_json = { workspace = true } 85 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/errhnd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_ERRHANDLER_ 2 | #define _RAR_ERRHANDLER_ 3 | 4 | enum RAR_EXIT // RAR exit code. 5 | { 6 | RARX_SUCCESS = 0, 7 | RARX_WARNING = 1, 8 | RARX_FATAL = 2, 9 | RARX_CRC = 3, 10 | RARX_LOCK = 4, 11 | RARX_WRITE = 5, 12 | RARX_OPEN = 6, 13 | RARX_USERERROR = 7, 14 | RARX_MEMORY = 8, 15 | RARX_CREATE = 9, 16 | RARX_NOFILES = 10, 17 | RARX_BADPWD = 11, 18 | RARX_READ = 12, 19 | RARX_USERBREAK = 255 20 | }; 21 | 22 | 23 | class ErrorHandler 24 | { 25 | private: 26 | RAR_EXIT ExitCode; 27 | uint ErrCount; 28 | bool EnableBreak; 29 | bool Silent; 30 | bool DisableShutdown; // Shutdown is not suitable after last error. 31 | bool ReadErrIgnoreAll; 32 | public: 33 | ErrorHandler(); 34 | void Clean(); 35 | void MemoryError(); 36 | void OpenError(const std::wstring &FileName); 37 | void CloseError(const std::wstring &FileName); 38 | void ReadError(const std::wstring &FileName); 39 | void AskRepeatRead(const std::wstring &FileName,bool &Ignore,bool &Retry,bool &Quit); 40 | void WriteError(const std::wstring &ArcName,const std::wstring &FileName); 41 | void WriteErrorFAT(const std::wstring &FileName); 42 | bool AskRepeatWrite(const std::wstring &FileName,bool DiskFull); 43 | void SeekError(const std::wstring &FileName); 44 | void GeneralErrMsg(const wchar *fmt,...); 45 | void MemoryErrorMsg(); 46 | void OpenErrorMsg(const std::wstring &FileName); 47 | void OpenErrorMsg(const std::wstring &ArcName,const std::wstring &FileName); 48 | void CreateErrorMsg(const std::wstring &FileName); 49 | void CreateErrorMsg(const std::wstring &ArcName,const std::wstring &FileName); 50 | void ReadErrorMsg(const std::wstring &FileName); 51 | void ReadErrorMsg(const std::wstring &ArcName,const std::wstring &FileName); 52 | void WriteErrorMsg(const std::wstring &ArcName,const std::wstring &FileName); 53 | void ArcBrokenMsg(const std::wstring &ArcName); 54 | void ChecksumFailedMsg(const std::wstring &ArcName,const std::wstring &FileName); 55 | void UnknownMethodMsg(const std::wstring &ArcName,const std::wstring &FileName); 56 | void Exit(RAR_EXIT ExitCode); 57 | void SetErrorCode(RAR_EXIT Code); 58 | RAR_EXIT GetErrorCode() {return ExitCode;} 59 | uint GetErrorCount() {return ErrCount;} 60 | void SetSignalHandlers(bool Enable); 61 | void Throw(RAR_EXIT Code); 62 | void SetSilent(bool Mode) {Silent=Mode;} 63 | bool GetSysErrMsg(std::wstring &Msg); 64 | void SysErrMsg(); 65 | int GetSystemErrorCode(); 66 | void SetSystemErrorCode(int Code); 67 | void SetDisableShutdown() {DisableShutdown=true;} 68 | bool IsShutdownEnabled() {return !DisableShutdown;} 69 | 70 | bool UserBreak; // Ctrl+Break is pressed. 71 | bool MainExit; // main() is completed. 72 | }; 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rdwrfn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _RAR_DATAIO_ 2 | #define _RAR_DATAIO_ 3 | 4 | class Archive; 5 | class CmdAdd; 6 | class Unpack; 7 | class ArcFileSearch; 8 | 9 | 10 | class ComprDataIO 11 | { 12 | private: 13 | void ShowUnpRead(int64 ArcPos,int64 ArcSize); 14 | void ShowUnpWrite(); 15 | 16 | 17 | bool UnpackFromMemory; 18 | size_t UnpackFromMemorySize; 19 | byte *UnpackFromMemoryAddr; 20 | 21 | bool UnpackToMemory; 22 | size_t UnpackToMemorySize; 23 | byte *UnpackToMemoryAddr; 24 | 25 | size_t UnpWrSize; 26 | byte *UnpWrAddr; 27 | 28 | int64 UnpPackedSize; 29 | int64 UnpPackedLeft; 30 | 31 | bool ShowProgress; 32 | bool TestMode; 33 | bool SkipUnpCRC; 34 | bool NoFileHeader; 35 | 36 | File *SrcFile; 37 | File *DestFile; 38 | 39 | CmdAdd *Command; 40 | 41 | FileHeader *SubHead; 42 | int64 *SubHeadPos; 43 | 44 | #ifndef RAR_NOCRYPT 45 | CryptData *Crypt; 46 | CryptData *Decrypt; 47 | #endif 48 | 49 | 50 | int LastPercent; 51 | 52 | wchar CurrentCommand; 53 | 54 | public: 55 | ComprDataIO(); 56 | ~ComprDataIO(); 57 | void Init(); 58 | int UnpRead(byte *Addr,size_t Count); 59 | void UnpWrite(byte *Addr,size_t Count); 60 | void EnableShowProgress(bool Show) {ShowProgress=Show;} 61 | void GetUnpackedData(byte **Data,size_t *Size); 62 | void SetPackedSizeToRead(int64 Size) {UnpPackedSize=UnpPackedLeft=Size;} 63 | void SetTestMode(bool Mode) {TestMode=Mode;} 64 | void SetSkipUnpCRC(bool Skip) {SkipUnpCRC=Skip;} 65 | void SetNoFileHeader(bool Mode) {NoFileHeader=Mode;} 66 | void SetFiles(File *SrcFile,File *DestFile); 67 | void SetCommand(CmdAdd *Cmd) {Command=Cmd;} 68 | void SetSubHeader(FileHeader *hd,int64 *Pos) {SubHead=hd;SubHeadPos=Pos;} 69 | bool SetEncryption(bool Encrypt,CRYPT_METHOD Method,SecPassword *Password, 70 | const byte *Salt,const byte *InitV,uint Lg2Cnt,byte *HashKey,byte *PswCheck); 71 | void SetCmt13Encryption(); 72 | void SetUnpackToMemory(byte *Addr,uint Size); 73 | void SetCurrentCommand(wchar Cmd) {CurrentCommand=Cmd;} 74 | void AdjustTotalArcSize(Archive *Arc); 75 | 76 | 77 | bool PackVolume; 78 | bool UnpVolume; 79 | bool NextVolumeMissing; 80 | int64 CurPackRead,CurPackWrite,CurUnpRead,CurUnpWrite; 81 | 82 | 83 | // Size of already processed archives. 84 | // Used to calculate the total operation progress. 85 | int64 ProcessedArcSize; 86 | 87 | // Last extracted archive size up to QO or RR block. 88 | int64 LastArcSize; 89 | 90 | int64 TotalArcSize; 91 | 92 | DataHash PackedDataHash; // Packed write and unpack read hash. 93 | DataHash PackHash; // Pack read hash. 94 | DataHash UnpHash; // Unpack write hash. 95 | 96 | bool Encryption; 97 | bool Decryption; 98 | }; 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/rar.cpp: -------------------------------------------------------------------------------- 1 | #include "rar.hpp" 2 | 3 | #if !defined(RARDLL) 4 | int main(int argc, char *argv[]) 5 | { 6 | 7 | #ifdef _UNIX 8 | setlocale(LC_ALL,""); 9 | #endif 10 | 11 | InitConsole(); 12 | ErrHandler.SetSignalHandlers(true); 13 | 14 | #ifdef SFX_MODULE 15 | std::wstring ModuleName; 16 | #ifdef _WIN_ALL 17 | ModuleName=GetModuleFileStr(); 18 | #else 19 | CharToWide(argv[0],ModuleName); 20 | #endif 21 | #endif 22 | 23 | #ifdef _WIN_ALL 24 | SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT|SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); 25 | 26 | 27 | #endif 28 | 29 | #if defined(_WIN_ALL) && !defined(SFX_MODULE) 30 | // Must be initialized, normal initialization can be skipped in case of 31 | // exception. 32 | POWER_MODE ShutdownOnClose=POWERMODE_KEEP; 33 | #endif 34 | 35 | try 36 | { 37 | 38 | // Use std::unique_ptr to free Cmd in case of exception. 39 | std::unique_ptr Cmd(new CommandData); 40 | #ifdef SFX_MODULE 41 | Cmd->Command=L"X"; 42 | char *Switch=argc>1 ? argv[1]:NULL; 43 | if (Switch!=NULL && Cmd->IsSwitch(Switch[0])) 44 | { 45 | int UpperCmd=etoupper(Switch[1]); 46 | switch(UpperCmd) 47 | { 48 | case 'T': 49 | case 'V': 50 | Cmd->Command[0]=UpperCmd; 51 | break; 52 | case '?': 53 | Cmd->OutHelp(RARX_SUCCESS); 54 | break; 55 | } 56 | } 57 | Cmd->AddArcName(ModuleName); 58 | Cmd->ParseDone(); 59 | Cmd->AbsoluteLinks=true; // If users runs SFX, he trusts an archive source. 60 | #else // !SFX_MODULE 61 | Cmd->ParseCommandLine(true,argc,argv); 62 | if (!Cmd->ConfigDisabled) 63 | { 64 | Cmd->ReadConfig(); 65 | Cmd->ParseEnvVar(); 66 | } 67 | Cmd->ParseCommandLine(false,argc,argv); 68 | #endif 69 | 70 | #if defined(_WIN_ALL) && !defined(SFX_MODULE) 71 | ShutdownOnClose=Cmd->Shutdown; 72 | if (ShutdownOnClose!=POWERMODE_KEEP) 73 | ShutdownCheckAnother(true); 74 | #endif 75 | 76 | uiInit(Cmd->Sound); 77 | InitLogOptions(Cmd->LogName,Cmd->ErrlogCharset); 78 | ErrHandler.SetSilent(Cmd->AllYes || Cmd->MsgStream==MSG_NULL); 79 | 80 | Cmd->OutTitle(); 81 | Cmd->ProcessCommand(); 82 | } 83 | catch (RAR_EXIT ErrCode) 84 | { 85 | ErrHandler.SetErrorCode(ErrCode); 86 | } 87 | catch (std::bad_alloc&) 88 | { 89 | ErrHandler.MemoryErrorMsg(); 90 | ErrHandler.SetErrorCode(RARX_MEMORY); 91 | } 92 | catch (...) 93 | { 94 | ErrHandler.SetErrorCode(RARX_FATAL); 95 | } 96 | 97 | #if defined(_WIN_ALL) && !defined(SFX_MODULE) 98 | if (ShutdownOnClose!=POWERMODE_KEEP && ErrHandler.IsShutdownEnabled() && 99 | !ShutdownCheckAnother(false)) 100 | Shutdown(ShutdownOnClose); 101 | #endif 102 | ErrHandler.MainExit=true; 103 | CloseLogOptions(); 104 | return ErrHandler.GetErrorCode(); 105 | } 106 | #endif 107 | 108 | 109 | -------------------------------------------------------------------------------- /unrar-rs/unrar_sys/vendor/unrar/acknow.txt: -------------------------------------------------------------------------------- 1 | ACKNOWLEDGMENTS 2 | 3 | * We used "Screaming Fast Galois Field Arithmetic Using Intel 4 | SIMD Instructions" paper by James S. Plank, Kevin M. Greenan 5 | and Ethan L. Miller to improve Reed-Solomon coding performance. 6 | Also we are grateful to Artem Drobanov and Bulat Ziganshin 7 | for samples and ideas allowed to make Reed-Solomon coding 8 | more efficient. 9 | 10 | * RAR4 text compression algorithm is based on Dmitry Shkarin PPMII 11 | and Dmitry Subbotin carryless rangecoder public domain source code. 12 | You can find it in ftp.elf.stuba.sk/pub/pc/pack. 13 | 14 | * RAR encryption includes parts of public domain code 15 | from Szymon Stefanek AES and Steve Reid SHA-1 implementations. 16 | 17 | * With exception of SFX modules, RAR uses CRC32 function based 18 | on Intel Slicing-by-8 algorithm. Original Intel Slicing-by-8 code 19 | is available here: 20 | 21 | https://sourceforge.net/projects/slicing-by-8/ 22 | 23 | Original Intel Slicing-by-8 code is licensed under BSD License 24 | available at http://www.opensource.org/licenses/bsd-license.html 25 | 26 | Copyright (c) 2004-2006 Intel Corporation. 27 | All Rights Reserved 28 | 29 | Redistribution and use in source and binary forms, with or without 30 | modification, are permitted provided that the following conditions 31 | are met: 32 | 33 | Redistributions of source code must retain the above copyright notice, 34 | this list of conditions and the following disclaimer. 35 | 36 | Redistributions in binary form must reproduce the above copyright 37 | notice, this list of conditions and the following disclaimer 38 | in the documentation and/or other materials provided with 39 | the distribution. 40 | 41 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 42 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 43 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 44 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 45 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 46 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 47 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 48 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 49 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 50 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 51 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 52 | SUCH DAMAGE. 53 | 54 | * RAR archives may optionally include BLAKE2sp hash ( https://blake2.net ), 55 | designed by Jean-Philippe Aumasson, Samuel Neves, Zooko Wilcox-O'Hearn 56 | and Christian Winnerlein. 57 | 58 | * Useful hints provided by Alexander Khoroshev and Bulat Ziganshin allowed 59 | to significantly improve RAR compression and speed. 60 | --------------------------------------------------------------------------------