mirror of
https://github.com/RetroShare/libretroshare.git
synced 2026-09-12 19:50:03 +05:00
`getch()` forwards `getchar()`, whose EOF is -1. The POSIX rs_getpass() stored it in an `unsigned char`, where it becomes 0xFF and never equals RETURN, so a closed stdin made the read loop append one 0xFF byte per iteration for good. Measured on retroshare-service built from master, started as `-U <sslid> < /dev/null`: 23 MB of output in 90 seconds, one core at 100%, and the process does not answer SIGTERM -- the spin never returns to the shutdown check, so only SIGKILL ends it. That is the behaviour a service unit or a container gets today whenever the passphrase is asked with no terminal attached, which also covers stdin redirected from /dev/null and an ssh session dropping while the prompt is up. `ch` is now an int and EOF ends the read with an empty result: the same run then exits in under a second with a 2.5 kB log. The Windows branch had the milder form of the same bug: a closed console returns EOF from every `_getch()`, and the loop could only leave through the PASS_MAX branch, so it returned 512 bytes of 0xFF as if they had been typed. It now stops on EOF as well, and accepts '\n' next to '\r' so a redirected stdin terminates the line. An optional `eof` out parameter tells the caller the input stream ended, which a plain empty string cannot express: without it, a caller looping "passphrase cannot be empty, try again" spins just as hard one level up. It defaults to nullptr, so existing calls are unchanged. Also check tcgetattr(): it fails whenever stdin is not a terminal, and t_old was then applied to stdin uninitialized. |
||
|---|---|---|
| .github/workflows | ||
| .reuse | ||
| gradle/wrapper | ||
| LICENSES | ||
| misc/Android | ||
| src | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| build.gradle | ||
| CMakeLists.txt | ||
| COPYING | ||
| gradlew | ||
| gradlew.bat | ||
| README.asciidoc | ||
| settings.gradle | ||
// SPDX-FileCopyrightText: 2022 Retroshare Team <contact@retroshare.cc>
// SPDX-FileCopyrightText: 2022-2026 Gioacchino Mazzurco <gio@retroshare.cc>
// SPDX-License-Identifier: CC-BY-SA-4.0
== RetroShare library
RetroShare is a decentralized, private, secure, cross-platform, communication
software.
RetroShare functionalities (file sharing, chat, messages, forums, channels...)
are implemented under the hood by libretroshare which offers a documented C++ and
JSON API.
While RetroShare is an application on its own, libretroshare is meant to be
used as part of other programs, some of them are
https://retroshare.cc[RetroShare-gui],
https://retroshare.cc[RetroShare-service],
https://gitlab.com/elRepo.io/elRepo.io-android[elRepo.io]
(let us know if there are more).
=== Continuous integration
image:https://gitlab.com/RetroShare/libretroshare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/libretroshare/-/commits/master",title="pipeline status"]
=== Developer Documentation
All public API methods are documented with Doxygen comments, so the most updated
way to read documentation is reading those comments in `src/retroshare/`.
To use libretroshare as part of your Android application we suggest to add our
maven repository, and then specify the variant and version that fits your needs
as dependency. RetroShare is then exposed as an Android Service as you can see
at https://gitlab.com/RetroShare/libretroshare/-/blob/master/src/rs_android/org/retroshare/service/RetroShareServiceAndroid.java?ref_type=heads[RetroShareServiceAndroid.java] start it and then interact with it
via RetroShare JSON API.
.Example of adding libretroshare as dependency in Gradle
--------------------------------------------------------------------------------
repositories {
maven {
url "https://gitlab.com/api/v4/projects/32730908/packages/maven"
}
}
dependencies {
// Look at https://gitlab.com/RetroShare/libretroshare/-/packages for
// available options.
// Minimum Android platform supported goes here ⬇
// Build variant goes here ⬇
// Version goes here ⬇
implementation "org.retroshare.service:libretroshare-MinApiLevel21-release:72f8b7e8"
}
--------------------------------------------------------------------------------
{empty} +
image:https://deepwiki.com/badge.svg[link="https://deepwiki.com/RetroShare/libretroshare",title="Ask DeepWiki"]