Repository navigation
Conversation
…ror.c error2text, error_text_init and httpstatus2text are teddycloud code, not Cyclone. Move them to src/error_text.c + include/error_text.h and restore src/cyclone/common/error.h to upstream. error2text now returns "" for codes outside the table instead of reading out of bounds. Add a unit test.
…th a wrapper
Add include/debug.h (found first via -Iinclude), which includes the
unmodified Cyclone debug.h and redefines the TRACE_* macros for the
runtime log level, colored prefix and *_RESUME variants. It also carries
the PRIuTIME override for 32 bit builds.
settings.h is no longer pulled into every file: the macros use
tc_log_level()/tc_log_color() from settings.c, and supportsAnsiColors()
moved there as a static helper. The macros are now do { } while (0), which
exposed three TRACE_* calls without a trailing semicolon in toniefile.c.
Drop the patched copies of debug.h, debug.c and compiler_port.h.
…est out of mpi.c - mime.c: use upstream, add .wasm via MIME_CUSTOM_TYPES in os_port_config.h (new test in test_content_mime.py). - tls_certificate.c: use upstream; rename its weak tlsParseCertificateList with a per-object -D so tls_adapter.c's definition is the only one (also works on MSVC, which has no weak symbols). - mpi.c: the Miller-Rabin test and the mpiCheckProbablePrime override move to src/mpi_prime.c. The remaining patch in src/cyclone/cyclone_crypto/mpi/mpi.c is two UB fixes (zero-length memcpy, shift of a promoted byte). Its weak mpiCheckProbablePrime is renamed per object, -O3 replaces the pragma. - Remove the unused src/cyclone/cyclone_crypto/mpi.h copy.
…hange bin/teddycloud.lo was only created when missing, so adding or removing sources kept linking the old object list.
…pies Cyclone's osSuspendAllTasks()/osResumeAllTasks() only serialized trace output. Replace that with tc_log_lock()/tc_log_unlock() (recursive lock in platform_linux.c / platform_windows.c) used by the TRACE_* wrapper and by TRACE_PRINTF/ARRAY/MPI via os_port_config.h. The Windows version also fixes the old lazy init, which returned from the first osResumeAllTasks() without leaving the critical section. os_port_posix.c now comes straight from cyclone/. Dropped with it: the pthread_cancel branch in osDeleteTask (only called on the calling thread), the NULL check in osReleaseSemaphore (callers pass member addresses) and the OsTaskId casts. src/cyclone/common/os_port_windows.c keeps only the SetThreadDescription call. Remove the byte-identical copies of os_port.h, os_port_posix.h, os_port_windows.h, fs_port.h and error.h; nothing patched in that directory needs to shadow them anymore. Add a test for the log lock.
It has no upstream counterpart in Cyclone (2.4.4 or later), so it is teddycloud code. Windows-only, unchanged apart from the path.
…d server Covers closed, open-ended, clamped and unparsable ranges on /content and on a static web file. Known-broken cases are expectedFailure with the expected answer: bytes=0-N is served as 200, a start past the end gives an empty 206, a reversed range sends a ~4 GB Content-Length, and a suffix range or any range on an empty file never gets an answer.
skip_header=true on /v2/content with and without Range and for a file shorter than the header, and /v3/chapter splits including a Range inside a chapter. tests/sim/taf.py can now build a header with track pages.
…f the vendored server Backport the hooks Cyclone 2.6 provides for this to the vendored 2.4.4 server (HTTP_PARSE_REQUEST_HEADER_FIELD_HOOK, HTTP_FORMAT_RESPONSE_HEADER_HOOK, HTTP_REQUEST_PRIVATE_HEADER_FIELDS, HTTP_RESPONSE_PRIVATE_HEADER_FIELDS) and implement the teddycloud part in src/http_ext.c: parsing of Range, If-Range and User-Agent, and the Accept-Ranges, Access-Control-Allow-Origin and Content-Range response headers. The request/response fields now come from http_ext.h through net_config.h. The headers are now written after Content-Length instead of at their old places; behaviour is unchanged (tests/py/test_http_range.py, test_taf_serving.py).
…rm files Including windows.h in settings.c, after Cyclone's cpu_endian.h, clashed with winsock.h (swapInt32 redefinition) and broke the Windows build. The platform files already include the Windows headers in a working order.
With dry_run the matrix builds and tests like for a pull request (load into the local daemon, run the container test) and publishes nothing to GHCR. It is an input of the manual dispatch (default false, so a dispatch still publishes) and of workflow_call.
… of the vendored server httpSendResponse* with Range, the TAF header skip / chapter split and streaming of a TAF that is still being written is teddycloud code. Copy it to src/http_ext.c as httpExtSendResponse* and rename its callers. The vendored http_server.c is rebuilt from upstream and keeps only: the call to httpExtSendResponse in the default file handler, the RTNL "*binary" path, the web_bearer_token reset, a larger chunk-size buffer and a clearer error trace. Cyclone's own httpSendResponse stays untouched (and unused). Behaviour is unchanged (tests/py/test_http_range.py, test_taf_serving.py, test_box_profiles.py).
One resolver (httpExtResolveRange, with a C test) now decides for /content and for static files / TAFs: - bytes=0-N is a partial response instead of the whole file with 200 - a start behind the end of /content gives 416 with Content-Range: bytes */size instead of an empty 206 with "bytes 100-99/100" - a reversed range (50-10) is ignored instead of sending a ~4 GB Content-Length - a suffix range (bytes=-N) is ignored; it used to be read as a huge start and never got an answer - a range on an empty /content file gives 416 instead of hanging The header parser tracks whether a range was sent and whether it has an end, so start 0 is no longer "no range". The expected failures in test_http_range.py and test_taf_serving.py are now regular tests.
On musl pthread_t is a pointer, so Cyclone's "OS_INVALID_TASK_ID -1" and "taskId == OS_SELF_TASK_ID" do not compile with -Werror (the Alpine images failed). Keep a patched os_port_posix.c with the two casts and put the four casts back into the vendored http_server.c. Not fixed in Cyclone 2.6.6 either. Reproduced and verified in alpine:latest for linux/amd64 and linux/386.
…range parsing) - ci: debianAsanTest did not get dry_run, so a dry run could still publish its images. Pass it, and keep dry runs in their own concurrency group so they cannot cancel a real publish run. - http: a growing stream keeps ignoring a range that starts at 0, as before; "bytes=0-" would otherwise cut it off at its current size. - log: TRACE_*_RESUME continue a line without holding the lock, so they now take the lock themselves (an unlock without a lock is undefined on Windows). - handler_api: clear response.contentRange after freeing it. - range: parse with strtoull; numbers above 32 bits are not a usable range (new test). Add the reason text for 416. - remove the identical src/cyclone copies of mime.h and tls_certificate.h, which would shadow the newer headers after an upgrade.
…ne call each The pcap log of the plain HTTP traffic sits above TLS in httpSend/httpReceive (server) and httpClientSend/Receive/Open (client), where there is no hook in Cyclone. Build the pcaplog context in src/http_ext.c and keep only a single call per site in the vendored files. Checked by hand against develop: a server with pcap.enabled writes the same 286720 bytes and the same 300 captured requests.
…ream The copy carried ~470 lines of formatting changes next to the real change (the netMutex around tcpWaitForEvents, which teddycloud's tcpWaitForEvents does not release while it waits). Keep only that change; Cyclone 2.6 drops the mutex.
- http_server.h is upstream plus the two PRIVATE_HEADER_FIELDS macros. The allowOrigin/isHttps settings and the unused static-task fields are gone: core.allowOrigin is a snapshot kept in http_ext.c (httpExtSetAllowOrigin), and httpExtIsHttps() asks the connection for its TLS context. - http_server_misc.h is upstream again; httpStatusCodeText() and its table moved to http_ext.c. The vendored status line table only gets 206, 410, 416. - remove the byte-identical copies of aes.h, http_client_transport.h and mqtt_client_transport.h.
…erver The chunk length is bounded by the buffer, so the larger char s[] only silenced a -Wformat-overflow warning that the build already tolerates.
A manual run of build_release.yml on a branch has no tc_nightly/tc_v* tag, so TAG_NAME is empty and actions/create-release aborted the zip job. Create the release and upload the asset only when TAG_NAME is set; the zip is still built and uploaded as an artifact.
Submodules common, cyclone_tcp, cyclone_ssl, cyclone_crypto -> v2.6.6. Build - Makefile: the TLS sources moved to cyclone_ssl/tls (+ include dirs for tls13, dtls), tls_record_encryption/decryption became tls_record_encrypt/decrypt, mpi_misc, ec_misc, tls_kdf, rsa_misc and pem_key_import/export are new sources, the patched aes.c, mpi.c and mqtt_client_transport.c copies are gone (2.6.6 has the fixes). - Yarrow was removed upstream: rand.c uses HMAC_DRBG (SHA-256), seeded with 64 bytes. - Private context macros renamed to *_CONTEXT_PRIVATE (TLS, MQTT client, HTTP client/server). - platform: netGetDefaultContext, netLock/netUnlock and socketOpenEx for the new stack API. - crypto_config.h: HMAC_DRBG_SUPPORT, TLS_KDF_SUPPORT. teddycloud code ported to the new APIs - cert.c: pem key import/export argument order and formats, EC curve instead of domain parameters, X509Options; our own x509ExportEcPrivateKey is replaced by Cyclone's. - cloud_request.c: tlsLoadCertificate, TLS init callbacks take a parameter. - tls_adapter.c: tlsParseCertificateList is now a thin wrapper around Cyclone's (renamed by -D) that fills the client certificate fields afterwards, instead of a stale copy of the whole function. Vendored patches re-ported onto 2.6.6 (src/cyclone): http_server.c (RTNL *binary path, bearer token reset, musl casts, call of httpExtSendResponse), http_server_misc.c (bounds, status texts, pcap, chunked default), http_client_transport.c (pcap), os_port_posix.c (musl casts), os_port_windows.c (thread name). http_server.h is upstream again.
Cyclone 2.6 inserts and shifts error codes, so the hard-coded numbers in error_text.c would label errors wrongly (it already did in the 5xx block: ERROR_CRL_EXPIRED was "Wrong nonce"). The table is now keyed by the enumerators and the number in the text is taken from the enum. Texts that did not match their enumerator were replaced by ones derived from the name. The test checks that the number in the text matches the code.
- rand: initialise the PRNG once at start-up (tls_adapter_init) instead of lazily from whichever connection thread asks first; two threads could initialise it concurrently, and a failed init was marked as done. - tls_config.h: pin what Cyclone 2.6 changed silently, so old boxes and brokers keep working: minimum RSA/DH/DSA modulus 1024 (2.6: 2048) and Encrypt-then-MAC off (2.6: on). - cert: write EC private keys as PKCS#8 PEM again, as with 2.4.4 (RFC 5915 was not intended). - http_server_misc.c: put the request line length guard back before terminating the buffer.
preinstall listed clean and build as plain prerequisites, so with -j the clean could
delete objects and the generated protobuf headers while the build was compiling
("proto/...pb-c.h: No such file"). Run them as ordered sub-makes; the build step still
parallelises through the job server.
The image builds compiled everything serially, which is painfully slow under QEMU (arm/v6, arm/v7, ppc64le, s390x, 386). Checked: make -j zip in alpine produces the same release zip.
arm/v7 and arm/v6 containers run natively on the ubuntu-24.04-arm runners (Neoverse-N2 executes AArch32 and no QEMU handler is registered; checked with a probe), so build and test them there instead of emulating them on the amd64 runner. The QEMU setup and the qemu-user-static registration are skipped for all ARM platforms, otherwise they would make the 32-bit runs emulated again.
strtok keeps its position in one static pointer for the whole process. Two boxes connecting at the same time run ha_publish in two HTTP threads; the second strtok call of one thread then continues in the other thread's buffer, which may already be freed. AddressSanitizer caught it as a heap-buffer-overflow in cJSON's print_string_ptr, reached from ha_addstrarray. The update check, the playback path of the box state and the settings loader run in such threads too.
A box resuming a download asks for the rest of the file. Content fetched from the cloud (not cached yet, or marked for refresh) was requested without the Range header, so the cloud answered 200 with the whole file and the box started over at 0 and reported an error. The request to the cloud now carries Range and If-Range as the box sent them; a 206 is passed through and not cached.
…very (#568) The for loop already increments index, so the extra increment skipped the setting that follows each internal one. core.contentdir and core.allowOrigin never got a Home Assistant entity although their status is published.
The discovery name included the full setting description, which pushed entity ids to Home Assistant's 255 character limit. Depending on the device name the truncated id ends in an underscore and Home Assistant rejects the entity (#549).
Loading the config copies the server's settings into every box, internal.online and internal.last_connection included. Those of the server's settings were set by every open web connection, so after a restart or reload every box, also one that never connected, showed the time of it as its last contact. The web connections are only counted now, and a box connection marks only the box's settings.
The hardware detected from the user agent (internal.toniebox_firmware.boxIC) was only kept in memory. It is now also stored as overlay.<id>.boxVersion, saved when it changes, and reported by /api/getBoxes. An unknown user agent keeps the stored version. Refs #561
Every file below /content that was no JSON went out as audio/ogg, and iOS Safari names a download after its type: pictures, MP3s and other files of the library or the content folder were saved as "….ogg". TAFs and extensionless content stay audio/ogg, anything else gets the type of its extension. Fixes #556
A search for one field kept only a third of the custom slots (3 of 9), so ten custom tonies named alike showed only three. Split the slots among the fields actually searched and allow 60 results.
The /cache/ entries of the box images were only added when /api/tonieboxesJson was asked. A web UI that got the URLs before a restart showed broken images until it reloaded that list. Add the entries when tonies.json is loaded, as for the figurine images.
…ort (#569) Co-authored-by: zimmermq <4189714+zimmermq@users.noreply.github.com>
Before the box opens its TLS connection, the firmware checks whether the API host is reachable: a plain TCP connect to port 443 with a timeout of 7500 ms. The port patch did not change it, so a box patched to another port only connected when something on the host also accepted TCP on 443. Without that, the box reported the ant error and dropped the Wi-Fi. The patch now sets the port of the check as well (v5.231.0 to v5.237.0, eu and pd builds); the timeout stays at about 7500 ms. Port 443 restores the original bytes. An image is only written when every connect function has its check.
/api/auth/refresh-token only checked the session so far; a session ended 7 days after login however often the client refreshed. Now a refresh moves the expiry of the session that authenticated the request to a full lifetime from now, and renews the cookie with the same Max-Age when the browser holds that session in it. Clients that stay open, like the Teddybox kids mode on a child's device, remain logged in while they are used. The lifetime itself is unchanged (7 days), and the client cannot choose it. Co-authored-by: Christian Ditscher <chris@ditscher.me> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…tting them (#605) * fix(api): refuse query values that do not fit instead of cutting them queryGet() cut a value at 1023 bytes of the raw query or at the size of the caller's buffer and still reported it as found. A long move or rename target thus moved the file to a shortened name, often without its extension, and answered OK. queryGet() now reports such a value as missing with a warning; handlers that need the parameter answer 400. * fix(api): list folders with paths up to 256 bytes The folder listings read the path into 128 bytes. Since queryGet() refuses values that do not fit, a deeper path, quickly reached with umlauts, was taken as missing and the library root was listed instead. * fix(api): refuse a folder path that does not fit instead of cutting it dirCreate read at most 256 bytes of the body and created the folder under the shortened path, possibly cut inside a UTF-8 sequence, and answered OK. A longer body is now answered with 400 "path too long".
An extensionless content file must be served as audio/ogg, and the deep list path test also runs a path that no longer fits the buffer.
Nothing joins a task, and a joinable thread keeps its stack mapped after it ended until it is joined. Every task that ends (a stream, a TAP being generated) left its stack, 8 MB by default, of address space behind. The new C test sees 544 MB more after 64 such tasks, 64 MB with this change (glibc keeps a few stacks given back for the next threads). Cyclone's osCreateTask is replaced from TeddyCloud code (src/platform/platform_linux.c) and renamed in its object, as mpiCheckProbablePrime is, instead of growing the patched os_port_posix.c. os_port_windows.c leaks in its own way: the handle CreateThread returns is never closed. It is not touched here, as it cannot be built or tested on Linux.
When the content json of a tag cannot be written (a read-only or full content directory, a file where the tag's directory goes), load_content_json leaves cloud_ruid NULL, and dumpRuidAuth took its length: a box's claim or content request for that tag crashed the server (SEGV in dumpRuidAuth, cloud.dumpRuidAuthContentJson is on by default). NULL now counts as no rUID yet.
moveTAF2Lib compared the existing library file only by its header SHA1. A TAF that is corrupted inside the audio (issue #346: a zero-filled region) has the same header as a fresh download, so the fresh copy was deleted and the corrupted one kept. The library file is now fully validated and replaced when it fails. With core.full_taf_validation a corrupted TAF source was also typed as a stream source, which re-encoded it with ffmpeg and set the tag to live and nocloud. The source type now only depends on the TAF header. Part of #338
* Replace a corrupted library TAF when it is cached again moveTAF2Lib compared the existing library file only by its header SHA1. A TAF that is corrupted inside the audio (issue #346: a zero-filled region) has the same header as a fresh download, so the fresh copy was deleted and the corrupted one kept. The library file is now fully validated and replaced when it fails. With core.full_taf_validation a corrupted TAF source was also typed as a stream source, which re-encoded it with ffmpeg and set the tag to live and nocloud. The source type now only depends on the TAF header. Part of #338 * Report corrupted TAFs and allow redownloading them from the cloud The tag info now carries "corrupt" when the header of a TAF is fine but the SHA1 hash or length of the audio is not (found by the full validation or the track position check). getTagInfo?validate=true runs the full validation for one tag on demand. A tag that plays its own cloud content (a TAF in the content dir, or the library file it was cached to) gets a "redownloadUrl": the content download with force=true, which skips the local file and fetches from the cloud. If nothing gets cached, the previous source is restored. Tags with any other source are refused with 409, as the download clears the source. Part of #338 * Take the cached library path from getLibraryCachePath isCachedCloudContent built the library path itself, so it would drift if the layout changes. getLibraryCachePathNoCreate builds the path without creating directories, getLibraryCachePath now uses it, and isCachedCloudContent compares against it.
The per-id locks are switched off, so a tag info request and the cloud handler could save the same content json at once. Both wrote the same .tmp file and truncated each other. A read also took the file size and the data in two steps, so a save in between made it fail to parse, and the loader then wrote the json anew with defaults, losing the source. save_content_json and the read in load_content_json now hold MUTEX_CONTENT_JSON. test_taf_redownload waits for the old source to be restored, which happens after the answer went to the client.
test_os_task_ends_without_its_stack compared the thread count for equality after waiting 5 s. On a loaded runner the tasks need longer, and threads of earlier tests may end meanwhile. Wait up to 30 s and accept fewer threads than before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.