Commit Graph

1003 Commits

Author SHA1 Message Date
Max Radermacher
385ae60bc8
Fix some codegen designated initializers
* Ignore `exclusiveProcessIdentifier` parameter

This was added in fee1bbddad, but the `NS_UNAVAILABLE` declarations
weren’t updated, which led to warnings in Xcode.

* Ignore `TSThread` initializer in subclasses

* Fix `TSAttachmentPointer` ignored initializer

* Add missing initializers to `TSMessage` subclasses

This only handles the immediate subclasses. There’s still more warnings
in the extended hierarchy, but those don’t seem to have been handled as
consistently in the first place, so updating them is more involved.
2022-05-09 13:59:38 -07:00
Max Radermacher
f7f129cdc5 Remove unnecessary error handler wrapper
This only calls the block, and the formatting in the old design made it
particularly difficult to read. (It also makes this path and the success
path more similar in their construction.)
2022-05-09 09:41:25 -07:00
Evan Hahn
04d7bb7462 Stop using arc4random in Swift files
This removes calls to `arc4random` and `arc4random_uniform` and replaces
them with calls to `Int.random` or equivalent.

These are a little less readable, which may be [why SwiftLint doesn't
like them][0]. (SwiftLint calls them "legacy", possibly because they're
not strong random number generators, but I couldn't find a clear
explanation for this anywhere, including [the original PR][1].)

This is the kind of change that's error-prone, so I wrote [a simple
script to help avoid regressions][2]. The script runs 10,000 iterations
of the old and new RNG and compares the ranges, reporting differences.
(Some differences are likely, like the ones that involve floats; others
are very unlikely to have differences.)

`git grep arc4random | grep swift` returns no results after this change.
Same for [everything else SwiftLint checks for][3].

[0]: https://realm.github.io/SwiftLint/legacy_random.html
[1]: https://github.com/realm/SwiftLint/pull/2419
[2]: https://gist.github.com/EvanHahn-Signal/9c75c9f484f4778149cbde3eafc9b285
[3]: ea6cc50890/Source/SwiftLintFramework/Rules/Idiomatic/LegacyRandomRule.swift (L23-L27)
2022-05-03 10:19:07 -05:00
Evan Hahn
5be42da750 Change references from master to main
_I recommend reviewing this with whitespace changes disabled._

Signal has renamed its primary branch to `main`. This updates references
to the old name, `master`, to either reference `main` or a specific
commit hash.

I also fixed a couple of small whitespace issues in a file I was
editing.
2022-05-02 10:30:40 -05:00
Max Radermacher
88a28c3457 Fix typos: Reciept → Receipt 2022-04-29 12:14:09 -07:00
Jordan Rose
df5dd99293 Decide whether to discard a GV2 message without building an entire job
We already have the deserialized envelope at the point where we're
first checking, but also we don't even use any information from it
besides the source address.

This commit also stops checking whether a group context has a revision
once we've created a job; I think that's reasonable.
2022-04-11 15:55:04 -07:00
Jordan Rose
1433246f6a Stop passing SSKProtoEnvelopes to get GV2 context info
They aren't needed; the code only checked that the envelope had some
content, any content.

No functionality change in practice: all call sites already had
plaintext data alongside the envelope, where that data was assumed to
come from the envelope, proving it had content.
2022-04-11 15:55:04 -07:00
Evan Hahn
8b072620a6 Add "Donation Receipts" view 2022-04-11 16:21:12 -05:00
Michelle Linington
9f1d45f67f Merge branch 'release/5.35.0' 2022-04-09 16:25:58 -07:00
Michelle Linington
988e6b8e14 Require transactions for the remainder of BlockingManager's interface 2022-04-08 19:01:43 -07:00
Michelle Linington
dd0a7f6b80 Require transaction to check blocked address state 2022-04-08 19:01:43 -07:00
Jordan Rose
5ecb9519b9 Refresh PNI pre-keys along with ACI pre-keys
Pre-keys are refreshed at regular (throttled) intervals, but the
"refresh" operation will only actually upload new pre-keys if the
server says we're running low. In addition, after the "refresh",
there's a "rotation" operation for the signed pre-key if the current
one is more than two days old. This only runs if the refresh was
skipped, since uploading new one-time pre-keys is already an
opportunity to rotate the signed pre-key (and it's worth doing so,
since pre-keys running low can indicate high traffic).

None of this has changed. However, we can now do this for both ACI and
PNI pre-keys. This reworked +[TSPreKeyManager
checkPreKeysWithShouldThrottle:] quite a bit to declare the proper
operation dependencies, which isn't *strictly* necessary because the
queue they're executed on is already limited to a
maxConcurrentOperationCount of 1. We could remove that at this point
with proper use of "barrier" operations, but since all the operations
are hitting the server and account updates have to be serialized on
*that* end, there doesn't seem to be much of a benefit.
2022-04-07 14:06:27 -07:00
Jordan Rose
f0de694156 Rotate the PNI signed pre-key along with the ACI signed pre-key
This only applies to explicit rotations of *just* the signed pre-key.
Including this for regular pre-keys as well is more complicated.
2022-04-07 10:23:39 -07:00
Michelle Linington
f4539ab83c PR Feedback: Restrict logging 2022-04-01 14:55:30 -07:00
Michelle Linington
29dc1eefcd Lint 2022-04-01 14:55:30 -07:00
Michelle Linington
fc69576a74 Include status code in network request success log message 2022-04-01 14:55:30 -07:00
Michelle Linington
049b68c4ea Better description for OWSHTTPHeaders 2022-04-01 14:55:30 -07:00
Nora Trapp
e662b099dd Check if a user is stories capable when sending group replies 2022-03-31 00:37:56 -07:00
Nora Trapp
b88b3ce396 Process incoming story context 2022-03-31 00:34:32 -07:00
Martin Böttcher
462177a0ce
improve cold start app start times (#4079)
deferred some initial load for faster app start
2022-03-29 08:24:55 +02:00
Chris Eager
b66e80dd21 Update message reporting to use sender ACI instead of E164 2022-03-28 16:23:51 -07:00
Jordan Rose
c027faab7d Report HTTP status code when web sockets fail to connect
Necessary to detect when a device has been unlinked or unregistered.
2022-03-28 15:25:37 -07:00
Jordan Rose
4f3b4ea1ae Make debug log uploading not dependent on SSKEnvironment
This is important for when the app fails to launch (say, because it's
detected database corruption). We still want debug logs to be
uploadable there!
2022-03-23 10:19:15 -07:00
Evan Hahn
de105468a4 Assume everyone is GV2-capable 2022-03-22 17:11:57 -05:00
Jordan Rose
39042a8234 Create PNI identity keys and pre-keys upon registration
This doesn't handle
- device linking (we need to send the PNI identity key as well as the
  ACI identity key)
- existing devices that need PNI keys (that'll be an explicit check)
2022-03-18 12:34:11 -07:00
Artem Varaksa
829d1cd727 Fix SocketManager.isAnySocketOpen (fixes #5221). 2022-03-18 11:36:51 -07:00
Dimitris Apostolou
62724cf0be Fix typos 2022-03-18 11:31:06 -07:00
Martin Böttcher
eedfd70f3e merged master and pod files 2022-03-15 12:49:11 +01:00
Jordan Rose
ab8a5cd5c4 Use the WhoAmIResponse from the change-number server endpoint
...instead of requesting a separate /whoami right after changing
number to get the new number (and PNI).
2022-03-14 12:59:44 -07:00
Jordan Rose
8a29fdd71c Store the local PNI alongside the local ACI and phone number
Save the PNI after registration and when verifying or updating our
current phone number. (Also, show it in the Internal settings like the
phone number and ACI.)
2022-03-14 12:59:44 -07:00
Jordan Rose
a9b9f58d0e Update clang-format with AllowShortEnumsOnASingleLine: false
And apply it to our sources.
2022-03-14 11:20:20 -07:00
Jon Chambers
f642376631 Accept HTTP/429 as a "rate-limited" status code 2022-03-10 16:03:56 -05:00
Martin Böttcher
8f9be31ba3 replaced NSLocalizedStringFromAppBundle with OWSLocalizedString 2022-03-08 10:17:25 +01:00
Jordan Rose
15d13517fa Add SDSCursor protocol, for common functionality across cursors 2022-03-07 15:01:39 -08:00
Jordan Rose
0c04b3e575 Log on network requests with large content lengths
This is intended to catch requests to the server that could be causing
problems in the memory-constrained environment of the NSE. It's
unlikely, since we log *all* network requests and we haven't seen any
suspicious ones, but it could still be useful in the future.

Note that this only applies to data tasks, not download tasks; a
download task can be as big as it needs to be.
2022-03-01 16:19:38 -08:00
Michelle Linington
0f57b13e1d Drop Starscream dependency 2022-02-22 12:41:04 -08:00
Michelle Linington
fc1a94b5dc PR Feedback 2022-02-22 12:41:04 -08:00
Michelle Linington
e00e43ec95 Perform CDS requests against HSM backed service 2022-02-22 12:41:04 -08:00
Michelle Linington
aadd176cb9 Add CDS Constants 2022-02-22 12:41:04 -08:00
Michelle Linington
1f2e39b07a WebSocket responses can now vend raw bytes 2022-02-22 12:41:04 -08:00
Martin Böttcher
22ff15bcb6 Add the "Signalyzer" Instruments tool 2022-02-17 14:07:57 -08:00
Michelle Linington
1075bae92b Merge branch 'release/5.27.2' 2022-02-08 16:35:11 -08:00
Michelle Linington
ccbbab0070 Lint 2022-02-08 16:09:07 -08:00
Michelle Linington
5249ac6e88 PR Feedback: Account for varied pause behavior 2022-02-08 16:05:00 -08:00
Michelle Linington
a557af0603 Lint 2022-02-08 15:42:01 -08:00
Michelle Linington
0e2d6a3e7f IOS-866: Endless captcha
Fixes an issue where we would fail to respect the retry-after header of
a failed send response.
2022-02-08 15:19:15 -08:00
Jordan Rose
61232780ee Don't reindex conversations on every model change
Every single message updates a TSThread model, but only a change in a
member's profile name or phone number, or a change to a group's model,
can update the indexing information. Turn 'shouldBeIndexedForFTS' into
a tri-state 'FTSIndexMode' with options 'never', 'manualUpdates', and
'always', and use 'manualUpdates' for TSThreads. Then explicitly
reindex on any of the changes listed above.
2022-02-01 15:05:34 -08:00
Nora Trapp
41dd7a14d9 Add support for IASv4 enclaves 2022-01-27 15:58:47 -08:00
Jordan Rose
a31100f0f5 Fix copyrights 2022-01-26 09:50:56 -08:00
Jordan Rose
01518551eb Import SignalMetadataKit wholesale into SignalServiceKit
The only modifications are those necessary to build as part of SSK.
The follow-up commits will clean that up a bit.
2022-01-26 09:50:55 -08:00