Commit Graph

122 Commits

Author SHA1 Message Date
Burak Goncu
a7d632dfd4 engine: ask a conventional server for a desktop of a chosen size
Match Client was tied to High Performance mode, which only a Mac has, so a
TigerVNC desktop stayed the size it was started at however small the
screen it was shown on.

A host can now name a size in pixels. It is sent with SetDesktopSize to a
server that has announced ExtendedDesktopSize, kept until the server has
said whether it does, sent again after a reconnection, and never sent to a
Mac. A size that was asked for once is not asked for again when the server
turns it down or someone there chooses another.
2026-11-23 22:51:20 +03:00
Burak Goncu
4fa9b979a1 engine: sign in to servers that speak RSA-AES
RealVNC servers speak RA2 by default, and wayvnc offers it beside TLS when
it is set up to ask for a password, which is how Raspberry Pi OS sets it
up. Neither could be connected to.

The four types are RA2 and RA2ne and their 256-bit forms. The ends exchange
RSA keys and a random number each, make an AES key for each direction, and
send the sign-in in AES-EAX messages; with RA2 the session goes on inside
them. Nothing vouches for the server's key, so a host is asked about it and
without a host to ask the sign-in stops.

Automatic selection takes a type that encrypts the session first, RSA-AES
before VeNCrypt where both are offered since it needs nothing of the
transport, and an encrypted sign-in before a plain one. VeNCrypt, once
chosen, falls back to what it has that needs no TLS, says when it wants a
user name, and reports whether it took the connection into TLS.
2026-11-23 22:51:20 +03:00
Burak Goncu
1d38970474 Let a release be made with an App Store Connect API key
The release scripts signed and uploaded through the Apple ID that Xcode
is signed in with, and Xcode had forgotten its account in the middle of
a release: the archive was made and could not be sent. Named in the
environment, an API key and its issuer are now handed to xcodebuild in
the Apple ID's place. Version 1.1.1 for iPhone and iPad went to
TestFlight that way.

The Mac's disk image needs a Developer ID certificate, which a key may
use only with access to cloud-managed distribution certificates; the
script says so where it says how.
2026-11-11 13:26:23 +03:00
Burak Goncu
8d3f1ef1cf Give the last of the command line tests its room too
A third test took "within five seconds" as the sign that a tool which
would have run for ten minutes was stopped by its time limit, and a
loaded CI runner took nine. It gets the minute the other two have.
2026-11-11 13:23:21 +03:00
Burak Goncu
2781d3ff04 Version 1.1.1
The changelog says what went wrong in 1.1.0 on a device it had not
been tried on, and the pictures show a session as it is again: without
the status bar.
2026-11-11 13:16:01 +03:00
Burak Goncu
7dc495eccf Leave a desktop size check under way to finish
The canvas reports its size at every layout pass, most of them with a
size it has reported before, and each report cancelled the check on
whether the Mac made the desktop it was asked for and started it over.
On a screen that is laid out often the check might never have got to
its answer. A check for the size already being checked is left alone,
and one that ended without learning anything is made again the next
time that size is asked for.
2026-11-11 13:16:01 +03:00
Burak Goncu
3bc1714784 Keep the trackpad deck from coming and going at the edge of a hinge's range
A foldable set down like a laptop brings the trackpad deck out, and
"like a laptop" is a hinge between 60 and 135 degrees. Held at either
end of that, a hinge reads a little to one side and then the other from
one moment to the next, and every reading across the line brought the
deck out or put it away again. Once open like a laptop, a hinge now
stays that until it is ten degrees past the line.

The canvas also laid itself out again for every reading of the hinge,
which a device held in the hand gives many of a second. It does so now
only when the posture changes.
2026-11-11 13:16:01 +03:00
Burak Goncu
c34c232c00 Stop two layouts of a screen from replacing each other without end
The layout of a session is meant to change nothing that it is worked
out from. The status bar was one way it did, and that is gone; this is
for the ways nobody has found yet, on devices nobody here has tried.

A layout that comes straight back after it was replaced, four times
within two seconds, is taken for one of two that undo each other, and
whichever is in place is then kept for five seconds. Someone turning a
device on its side and back is a layout returning as well, once and
seconds apart, and is let through. A layout a little wrong is better
than an app the system has to end.
2026-11-11 13:16:01 +03:00
Burak Goncu
af2d226829 Hide the status bar for as long as a session is on the screen
Version 1.1.0 showed the status bar wherever a screen had room for it,
and worked that out from what the screen keeps clear. What a screen
keeps clear depends on whether the bar is showing. On an iPhone Duo
with iOS 27.3 the two did not agree: showing the bar made for a safe
area that said to hide it, and hiding it made for one that said to show
it. Asking the status bar manager for the bar's frame during layout
applied each change there and then, so all of it happened inside one
layout pass that never ended, and the system ended the app as soon as
a session opened.

The bar is hidden throughout a session, as it was in 1.0, and the
layout is worked out from the screen alone: nothing it depends on is
anything it changes. A session no longer asks for a dark appearance
either, which was there for the bar to be read over black.
2026-11-11 13:15:34 +03:00
Burak Goncu
ea38440e85 Give the command line tests room on a busy machine
Two tests check that a tool is stopped by its time limit or by
cancellation rather than left to finish, and took "within five
seconds" as the sign of it. A loaded CI runner took seven. Anything
far short of the ten minutes the tool would have run says the same.
v1.1.0
2026-11-11 12:24:59 +03:00
Burak Goncu
b4523eec20 Version 1.1.0
The changelog, the README and the architecture notes say what changed
for iPhone and iPad, and the pictures show the session as it now is.
2026-11-11 12:19:18 +03:00
Burak Goncu
6cb56d4614 Keep the end-to-end tests from leaving preference files behind
Each test made its settings in a defaults suite with a name of its
own, and a named suite is a property list in ~/Library/Preferences
that nothing ever removes: one more for every test, every run. The
suites are named by a path in the temporary directory now, the way the
settings tests already do it.
2026-11-11 12:19:17 +03:00
Burak Goncu
fca38f3467 Start the picture below what a screen's rounded corners cut into
The top of a Mac's screen is its menu bar, with the Apple menu in one
corner and the clock in the other. On a screen with nothing at the top
but deeply rounded corners, an iPhone Duo's two displays above all, the
picture ran to the top edge and the corners took both.

iOS says how far down content has to start to be seen whole, the safe
area adapted to the corners, and the picture now starts there: about
17 points on the Duo, 9 on an iPad, nothing more where a sensor housing
already keeps it lower. On the Duo that is also the strip in which the
system keeps taps to itself, so the menu bar is out of it.

The handle of the controls sits on the top of the picture and not in
that strip, where a tap might never reach it.
2026-11-11 12:14:48 +03:00
Burak Goncu
13506587f9 Keep the picture its size when a keyboard or the deck comes up
Whatever covered the bottom of the screen was treated as less room,
and the picture was shrunk to fit what was left. Above a keyboard on a
phone that left a desktop a third of its size, at the very moment
someone needed to read what they were typing.

The viewport now knows the difference between room it does not have
and room that is covered for a while (bottomCover). A covered picture
keeps the size it has with nothing in the way and slides up instead,
as far as it takes to show where the pointer is; it pans from its top
to where its last line clears the cover, and goes back when the cover
does.

A picture that is slid up or zoomed in is also cut to the part of the
screen that is the picture's, so that it no longer runs on under the
status bar.
2026-11-11 11:43:47 +03:00
Burak Goncu
12e4fd7521 Show in the statistics whether video is decoded in hardware
A session that cannot keep up may be short of network or short of a
decoder, and only one of those shows in the numbers so far. "Decoder"
says Hardware or Software wherever VideoToolbox tells.

Scripted launches can also ask for more desktop space, the trackpad
deck and the statistics overlay.
2026-11-11 11:38:36 +03:00
Burak Goncu
239f313a3a engine: report whether the video decoder runs in hardware
When a device cannot decode a stream's chroma in hardware, VideoToolbox
decodes on the CPU without a word, and nothing costs a session more.
The decoder already wrote which it got to the log; the session's
statistics now carry it too, where an app can show it.
2026-11-11 11:38:36 +03:00
Burak Goncu
938d550388 Put a session's controls out of the picture's way on a touch screen
The controls floated over the bottom of the picture for as long as a
session lasted. The bottom of a Mac's screen is its Dock, so the Dock
was covered and could not be touched; and the picture stopped short of
the bottom of the screen, leaving a black band under it.

Where the picture and the controls go is now worked out from what the
screen keeps content clear of (SessionChromeLayout):

- The picture goes down to the bottom edge. The home indicator hides
  itself during a session, and system gestures at the edges wait for a
  second swipe, so that the Dock is the Dock.
- Where the screen has a strip the picture cannot use, the controls
  stand in it, always in view and covering nothing: down the side of
  an iPhone Duo's cover display, under its status bar, and down the
  side opposite the sensors of any iPhone on its side.
- Anywhere else they come out of the top of the picture, over the
  middle of the menu bar, and are put away to a small handle as soon as
  the remote screen is touched. They can be moved to the bottom, or
  kept in view.
- The status bar is shown where it has a place of its own, beside a
  sensor housing, instead of that place being left black.

The trackpad deck no longer comes out by itself whenever a foldable
reports being partially open, which it does when held with the
slightest bend: only when it is open like a laptop, and it can be put
away then too.

The transfer list keeps to the edge the controls do not use.
2026-11-11 11:26:18 +03:00
Burak Goncu
be3786384a Present frames at the display's full refresh rate on iPhone
Without CADisableMinimumFrameDurationOnPhone an iPhone app is held to
60 Hz on a 120 Hz display. A frame that arrives just after a refresh
then waits most of 17 ms to be shown; at the display's own rate it
waits half that at worst.
2026-11-11 11:26:18 +03:00
Burak Goncu
ac3c2e86ac Size a desktop for a small screen, not for 1024 points
On a phone, a desktop that follows the display was made 1024 points
wide whatever the phone's width. Held upright that is a desktop of
about eight megapixels, shown at two fifths of its size: text too small
to read without zooming, and the most a Mac will send at 60 frames a
second, for a screen that can show a third of it.

The minimum is now 720×600 points: wide enough for System Settings,
the widest window that cannot be made narrower. A phone held upright
gets a desktop of about four megapixels, the Duo's cover display one
of 3.7, and the text is half as large again. "More Space on Small
Screens", in a computer's settings and in the display menu, brings the
1024 points back for whoever wants the room.

macOS 27 makes a display as small as this. What earlier versions do is
not known, and a Mac that will not make one does not say so; it makes
a display of its own choosing instead. So once a resize has settled
the session checks that it got the size it asked for, and a Mac that
gave another is asked for the size every Mac gives from then on.
2026-11-11 11:26:18 +03:00
Burak Goncu
6f7ab04383 engine: say when a remote display resize has settled
The transport knows when a Mac has finished making its displays over
after being asked for another size; the session only used that to time
a password at the login window. isRemoteDisplayResizeSettled makes it
readable, for a client that needs to know when the size it sees is the
Mac's answer and not the size from before.
2026-11-11 11:24:35 +03:00
Burak Goncu
e79a5256e7 engine: let a client choose the smallest desktop Match Client asks for
A view smaller than 1024×600 points was always matched with a desktop
of its shape scaled up to that. For a phone held upright that is a
desktop shown at two fifths of its size and about eight megapixels to
encode, send and decode, right at the limit of the 60 fps tier.

VNCConfiguration.matchClientMinimumPointSize sets the minimum, 1024×600
as before unless changed. A minimum below what macOS 27.2 makes a
virtual display at, about 540 points a side, is raised to 640×560: a
Mac asked for less answers with a display of its own choosing, of
another shape. VNCSession.matchedDisplayPixelSize tells a client what
will be asked for, so that it can tell whether it was given.

CI runs the display size tests.
2026-11-11 11:24:35 +03:00
Burak Goncu
592398fcdf Build the app's own code without warnings
The name of the overlay's coordinate space is read inside a closure
that may run off the main actor, so it no longer belongs to it. The
launch background names its two colours itself: a reference to a
system colour of one platform cannot be resolved when the shared
catalogue is built for the other.
v1.0.0
2026-11-11 06:22:29 +03:00
Burak Goncu
d77e8bd65f Say what the local network question at first launch is for 2026-11-11 06:17:44 +03:00
Burak Goncu
c3bb60b64e Say when the local network is what keeps a computer out of reach
When the system keeps the app off the local network, a computer on it
never answers, and the failure read as if the computer were asleep or
away. Looking for nearby computers already learns that access is
denied; the failure now says so too, with the way to the setting.
2026-11-11 06:17:04 +03:00
Burak Goncu
160ac3aa21 Make a tap the system asks about and then keeps back
Along the top of an unfolded iPhone Duo, as its simulator has it, a
strip about 16 points deep belongs to a system gesture: touches there
reach the canvas and UIKit asks whether a tap may begin, but the
handler never runs. With a desktop sized to the screen, a remote Mac's
menu bar is in exactly that strip and could not be clicked.

A tap that was asked about and not delivered within 60 ms is now made
by the canvas itself, and a delivery that turns up late for the same
tap is dropped, so that one tap is always one click. Where UIKit
delivers taps as usual, which is everywhere else, nothing changes.

The interface tests tap at the top edge of the screen, and all of them
now pass on the iPhone Duo simulator: a two-finger tap from the test
framework puts one finger in that strip.
2026-11-11 06:13:17 +03:00
Burak Goncu
575df553f1 Keep the sidebar in view when the library is empty
The welcome text asked for its full height at any width, so measured at
no width it was thousands of points tall. That became the least height
of the split view, and on the Mac a split view taller than its window
is centred in it: the first rows of the sidebar ended up above the
window's edge, and a new library opened with a sidebar that looked
empty.

The welcome is a scroll view now. It asks for no height of its own, and
a short window or a phone on its side still reaches all of it.
2026-11-11 05:46:23 +03:00
Burak Goncu
3f683c2580 Unlock an imported key away from the interface
A key file says how much work its passphrase takes to turn into a key,
and one made to resist guessing can ask for seconds of it. Importing
did that work on the main thread, so Settings stopped answering for as
long as it took. It runs in the background now, with a note that says
what is going on.
2026-11-11 05:23:18 +03:00
Burak Goncu
99024e2ef1 Say where a key exchange shows in the client and its streams
The time allowance a connection is made with also bounds each
replacement of its keys, and a channel stream's operations wait for
one to finish. Both are now said where the allowance and the stream
are described.
2026-11-11 05:17:22 +03:00
Burak Goncu
1fb468cf06 Leave a message's contents out of a protocol error's text
When swift-nio-ssh meets a message that is out of place, it words the
error by printing the whole message. For a channel message that takes
in what the channel was carrying: a piece of a file, the user's
typing. The text of the error is shown to the user and kept as the
reason a connection ended. This came to light with channel data that
was refused during a key exchange, where the error spelled out the
first bytes of the data.

Such an error is now described as far as the name of the message and
no further.
2026-11-11 05:17:22 +03:00
Burak Goncu
2fd2774521 Give up on a silent peer when data is on its way, too
TCP keepalive notices a peer that has gone silent only on a connection
with nothing left to send. With data outstanding, which is how a
session in use mostly is, the system retries the data instead, and by
default goes on doing so for many minutes before it gives the
connection up. The connection now has a drop time for that case as
well: the same 80 seconds the keepalive settings come to.

Checked on a loopback connection that the socket carries the setting
(TCP_RXT_CONNDROPTIME reads back as 80). The drop itself cannot be
brought about on loopback, where the far end always acknowledges.
2026-11-11 05:17:22 +03:00
Burak Goncu
43f4e360ff Stop a failing keychain from losing or hiding SSH keys
Saving to the keychain removed the item and then added it again. When
the add was refused, as it is when the device has been locked in the
meantime, the item was gone: renaming an SSH key could destroy the
private key. A save now replaces the item's value where it is, and
adds the item only when it is not there. Nothing is removed first, so a
save that fails leaves what was stored. Removing a secret now reports
it when the keychain would not do it.

Reading threw the keychain's answer away. A keychain that could not be
read looked exactly like an empty one: no keys in Settings, and "the
key is not on this device" when connecting. Reading now fails when the
keychain did, and the key store passes that on, so that Settings and a
session can say that the keys could not be read and why. Saved
passwords keep their old manner: one that cannot be read is asked for
again, as one that was never saved is.

SSH keys saved from now on can be read from the keychain only while
the device is unlocked. Until now they could be read at any time after
the first unlock. A key is used when its owner starts a connection,
with the device unlocked in front of them. Keys that are already saved
keep the setting they have, and passwords are not changed.

None of this is tested against a real keychain. The four keychain
calls go through a seam, and the tests stand a keychain of their own
behind it.
2026-11-11 05:17:22 +03:00
Burak Goncu
ef8d548167 Lower the limit on the work a key file may ask for
A protected key file says how many rounds of key derivation unlock it,
and up to 4096 were accepted. Measured in a release build on an M5 Max,
a round takes 4.7 ms for the 48 bytes the usual cipher needs (OpenSSH's
own ssh-keygen takes 5.2 ms on the same machine), so 4096 rounds held
the caller for about 19 seconds, with no way to call the work off. In a
debug build the same file took 110 seconds.

The limit is now 1024. ssh-keygen asks for 16 rounds by default, and a
key made with -a 1000 already costs its owner five seconds at every
unlock, which is about as far as anyone goes. Such a key still imports,
in the same five seconds; a file that asks for more is turned away
before any of the work is done.
2026-11-11 05:17:22 +03:00
Burak Goncu
0804f50f4b Keep SSH passwords out of descriptions and dumps
Printing an SSH credential, interpolating it into a string or dumping
it spelled out the password, and so did doing any of that to the
tunnel factory that holds one. A credential now describes itself by
its kind alone and shows nothing inside, to dump, the debugger and a
failing test as much as to print. The factory needs nothing of its
own: what it shows of its credential is what the credential shows.
2026-11-11 05:17:22 +03:00
Burak Goncu
0b8c9965f1 Make the record of trusted host keys harder to get round
Three ways led past it.

A known hosts file that was there but could not be read counted as
empty. Every server was then one met for the first time, including a
server on record with a different key: the change the record exists to
catch was offered as a new server, and accepted outright wherever new
servers are. The store now says that it cannot read its file, which is
a verdict of its own and not "unknown". The standard policy and the
app refuse every key while that lasts, and the connection fails saying
what is wrong with the file instead of blaming the key.

Looking at the record could destroy it. A file that did not parse,
which is also what a file from a newer version of the app would be to
an older one, was moved aside by the first thing that read it, a mere
check included, and every record went with it without a word. Reading
no longer changes anything, and a file with a newer layout is
recognised as that. The way out is one the user takes on purpose:
Settings shows why the list cannot be read and offers to start a new
one, which sets the old file aside. Erasing all content does the same.

Trusting a key was unconditional. Of two connections made at once to a
server not yet on record, the second recorded its key over the first's
on the strength of a verdict taken before the first was recorded, even
though by then the two keys disagreed. A key is now recorded only if
the store, asked again under the lock the change is made under, still
has nothing against it, or has exactly the conflict the decision was
made in view of. Otherwise nothing is recorded and the connection is
refused. Accepting a changed key replaces everything on record for the
server in that same step, which the app used to do in two.
2026-11-11 05:17:22 +03:00
Burak Goncu
e97eac77b2 Refuse channels a server tries to open
swift-nio-ssh confirms every channel the other side asks for unless it
is given something that says no, and the client gave it nothing. A
server could open channels towards the client by the thousand. Each
was confirmed and kept, with eight megabytes of room for the server to
fill, and whatever it sent there was decrypted and thrown away for as
long as it cared to send. A test server that asked for 500 channels
got all 500.

A server opens channels towards a client for things the client asked
for first, such as a forwarded port, and this client asks for none.
Every channel a server asks for is now turned down. Saying no does not
disturb the connection, which goes on opening its own.
2026-11-11 05:17:22 +03:00
Burak Goncu
61c4b3cdbd End a channel stream when a queued write fails
A file transfer session queues each request without waiting to hear
whether it left, on the understanding that a failure would show up as
the end of the stream. It did not: the failure of the write was thrown
away. A request that never left was then waited on for a reply that
could not come, until someone cancelled the task.

A queued write that fails now ends the stream with the reason and
closes the channel, so the session and every request waiting on it
hear of it at once.
2026-11-11 05:17:22 +03:00
Burak Goncu
fc001b787b Hold channel traffic while the session keys are replaced
From the moment one side of an SSH connection offers a key exchange
until it announces its new keys, it may send nothing else (RFC 4253
section 7.1). swift-nio-ssh keeps to that by refusing channel messages
in the meantime, and does no more than refuse. A write fails. The
leading part of a write that was split to fit the server's window is
dropped with no error at all. A flow-control update that falls in the
interval is lost for good, after which the server waits for room the
client believes it has granted. Against a server that replaces keys
every megabyte, a tunnel echoing data and a file transfer in either
direction stopped dead, in 18 runs out of 18.

A gate now stands between the channels and swift-nio-ssh. It hears of
this side's offer and of its new keys from the packet protection, the
one place that sees a message's type before it is encrypted: the
protection handed to swift-nio-ssh is its own, every call passed
through unchanged, with that look added. Between the two, whatever a
channel asks for waits its turn: reading, writing, closing, opening a
channel, starting a subsystem. Reading is in that list because taking
delivery of data is what makes a channel grant the server more room.
The end of each batch of received data is kept from swift-nio-ssh as
well, since that is when its channels send updates and replies of
their own accord. Once the new keys are out, all of it goes ahead in
order. The wait is bounded by the connection's time allowance, after
which the connection ends as timed out.

A write still waiting when its stream is closed is not sent afterwards.

Queueing channel messages during a key exchange belongs in
swift-nio-ssh, whose current release, 0.15.1, does not do it. When a
release does, the gate can go.
2026-11-11 05:17:22 +03:00
Burak Goncu
778d83bef1 Accept the same host key when a server replaces the session keys
A server replaces a session's encryption keys every so often, after so
much data or so much time (RekeyLimit in OpenSSH), and proves its
identity again each time it does. The handshake handler took that
second proof for a question about an attempt that was already over and
refused it, which closed the connection. On a server set to replace
keys every hour, every tunnel and every file transfer ended at the
hour, and an idle session with them.

The key the policy accepted while connecting is now remembered. When the
server presents it again the answer is yes, at once, with no policy
consulted and no timer involved. When it presents any other key the
connection is refused with the host key error: a person was asked once,
and a different key afterwards is not a new question for them.

This is enough for a session that is quiet while its keys are replaced.
One that is sending or receiving at that moment still fails, because of
what swift-nio-ssh does with channel messages during a key exchange.
That is dealt with separately.
2026-11-11 05:17:22 +03:00
Burak Goncu
b75811ccb3 Take the current SwiftNIO releases
swift-nio 2.105.0, swift-nio-ssl 2.37.6, swift-nio-transport-services
1.28.0 and swift-collections 1.7.6. Nothing needed changing for them.
2026-11-11 05:02:50 +03:00
Burak Goncu
184174e0b1 Keep what a server says about itself short enough to show
When a server refuses a request it may say why, and what it says is put
in front of the user as it is. The explanation can be as long as a
packet, sixteen megabytes, and hold anything: an alert was handed all of
it, escapes and NULs included. The name of a file can be as long, and a
name is shown in the list.

The explanation is now cut to its first three hundred characters, with
a sign that there was more, and control characters are left out of it.
A name longer than 1024 bytes, which no file system gives an entry, is
left out of listings and transfers and counted with the other names
that cannot be used.
2026-11-11 04:45:33 +03:00
Burak Goncu
211e85b2d6 Do not fail a complete download because its file would not close
A download ended by asking the server to close the file, and failed if
the server refused, although by then every byte had arrived and the copy
was in its place. It also waited for that answer for as long as the
server took to give it.

A download is complete when the server has said where the file ends and
exactly that many bytes have arrived, which is now checked where the
file is read. The server is still told to close its end, but is neither
waited for nor able to turn the download into a failure. The same goes
for a listing that the server has said is at its end.

An upload still fails if its file does not close. Until then the server
has not said that what was written is kept.
2026-11-11 04:45:33 +03:00
Burak Goncu
aa2ee70d12 Leave out names that are not text, and ask what an entry is
A file name comes from the server as bytes and is UTF-8 only by
convention. Bytes that were not UTF-8 were replaced to make text of the
name, and the file was then asked for under the patched-up name, which
the server does not know. A folder with one such name in it could not
be downloaded: the transfer failed part of the way through with "no such
file".

A name that is not UTF-8 is now kept as the bytes it is and left out of
listings and transfers, as a name with a slash in it already was, and
what is left out is counted. A listing says how many entries it could
not show, and a folder download returns how many files and folders it
could not copy. The file browser says so under the list and on the
finished transfer, and the rest of the folder is listed and copied.
Deleting a folder that holds such entries says why that cannot be done
from here.

A listing normally says what each entry is. An entry it did not
describe was taken for neither a file nor a folder: a folder was shown
as a file, and a folder download copied nothing and reported success.
Such an entry is now asked about. If the server does not say even then,
the entry is tried as a folder: what can be opened as one is one, and
anything else is taken for a file.
2026-11-11 04:45:33 +03:00
Burak Goncu
36fa82d2a4 Carry permissions with a file, and its date on the way down
An uploaded file was created with whatever the server gives a new file,
and a downloaded one with what this device gives one. A private key or
a .env that only its owner could read was readable by everyone at the
other end, a script arrived without the permission to be run, and a
downloaded file was dated as of the download.

A new file on the server is now made with the local file's permissions,
and a new folder with the local folder's. A downloaded file gets the
remote file's permissions and its modification date, and a folder made
for a download the remote folder's permissions. In both directions the
receiving side's own mask for new files still applies, so a copy can
have fewer permissions than the original and never more. Only who may
read, write and run is carried: running as the owner or the group, and
the sticky bit, stay behind. The owner can always write to the copy of
a folder, because it has to be filled.

A file that replaces another still takes that file's permissions, not
those of the file it is a copy of. An uploaded file is still dated as
of the upload; setting its date would take a request this client does
not make yet.
2026-11-11 04:45:33 +03:00
Burak Goncu
a92db1b0f3 Leave what was there when a transfer does not finish
A download opened its destination by emptying it, and deleted it when
the transfer failed. A download over an existing file that failed or was
cancelled took the old file with it. An upload did the same to the file
on the server. And when an upload was cancelled while the server was
still opening the file, the answer was dropped: the file stayed on the
server emptied, and was never closed.

Both directions now write to a hidden file of their own beside the
destination and give it the destination's name once it is complete. On
this device that is a rename, which replaces in one step. On the server
it is the posix-rename extension where the server offers it, as OpenSSH
does, and that is one step too. A server without it is asked for an
ordinary rename, which is enough when nothing is in the way. When a file
is in the way, that file is moved aside, the new one renamed into place
and the old one deleted; if the new one still cannot be renamed, the old
one is moved back. Nothing has the name between those two renames, and a
connection lost just then leaves the old file whole under the other
name. Version 3 of the protocol allows nothing better.

If the transfer fails or is cancelled, the partial file is removed and
the destination is as it was. Once the whole file is on the server,
cancelling no longer stops it from being moved into place.

A request to open something that is given up on is now remembered. If
the server opens it after all, it is closed again, and removed if the
request had been to create it.

What changes with this: a link at the destination is replaced, not
written through. The new file belongs to whoever transferred it. An
upload has to be allowed to create a file in the folder, even to replace
a file it could have written to. The file that is replaced passes its
permissions on to the new one, exactly on this device and as far as the
server's mask for new files allows on the server, so that new contents
do not make a private file public.
2026-11-11 04:45:33 +03:00
Burak Goncu
924c808210 Stop waiting for a file server that has stopped answering
A request to the file server waited for its reply for as long as the
connection stayed up. A server that had stopped answering, as one does
when the disk behind it hangs, left a listing waiting for ever, whatever
timeout the connection had been made with.

Cancelling did not release a transfer either. On its way out the
transfer asked the server to close the file, and after an upload to
remove it, and waited for the answers. A transfer from a silent server
that was cancelled only returned when the session was closed.

Requests now have a deadline. When the server has sent nothing at all
for as long as the connection's timeout, the requests that have waited
that long fail as timed out. The time is counted from the server's last
sign of life, not from when a request was sent: a transfer keeps
thirty-two requests going, and on a slow link the last of them is
answered long after it was sent with nothing being wrong. One request
that times out does not end the session.

A transfer or a listing that is given up on tells the server to close
and remove what it has to, and returns without waiting to hear back.
The requests are on their way before it returns, so whatever is asked
next is answered after them.

A server that works on a single request for longer than the timeout and
sends nothing meanwhile, as closing a large upload onto a slow disk can,
now fails that request where it used to be waited for.
2026-11-11 04:45:33 +03:00
Burak Goncu
e0f5dfd2b2 Put limits on what a file server can make the app hold
A folder's listing arrives in batches until the server says it has
reached the end, and all of it was collected. A server that never said
so was listened to for as long as it kept sending: the listing did not
return and memory grew until the transfer was cancelled. A listing now
ends at 100,000 entries or 64 MB of names, with an error that says the
folder holds too much, and a batch with nothing in it counts as the end.
One reply can no longer announce more entries than a whole listing may
have, which a single packet of small ones could do a million at a time,
and the extensions a server announces at the start are counted as well.

A folder download walks the whole tree before it fetches anything, and
keeps what it finds. The walk now stops at 250,000 files and folders,
and at a path the local file system has no room for, which is where a
tree that goes down without end stops. Local folders are made after the
walk and not during it, so a tree that is turned down leaves nothing
behind. What is kept for each entry is its path inside the tree.

A handle may be 256 bytes long by the protocol. Any length was taken,
and the handle sent back with each of the thirty-two requests a transfer
keeps going. A longer one is now an invalid response, and so is the
answer to a read that carries more than was asked for, which was written
out as it came.
2026-11-11 04:45:33 +03:00
Burak Goncu
0c2025a3a1 Add up the sizes a server reports without overflowing
Before a folder is downloaded, the sizes in its listing are added up to
give the progress a total. Each size was brought into range, but the
sum was not, and a server that listed two files of the largest size
there is crashed the app on the addition.

Totals now stop at the largest value there is. That goes for the sizes
of local files on the way up as well, since a file that is mostly holes
can claim nearly any size, and for the running counts that progress is
reported from.

The rest of the arithmetic on what a server sends was gone through too.
Offsets into the local file were converted to the system's signed
positions on trust. They are the client's own, 32 KiB apart, and no
real transfer gets them out of range, but a position that does not fit
is now refused as a file too large rather than trapped on.
2026-11-11 04:45:33 +03:00
Burak Goncu
b6afddd0ff Read a file name's bytes before trusting it with a path
A server names the files it lists, and a download puts each one under
that name in the folder the user chose. Names with a slash in them were
left out, but the slash was looked for among the name's characters, and
a slash followed by a combining mark or an invisible joiner is a single
character that is not "/". The file system still splits the name there.
A server that listed "../" and an accent in front of a file name had
the file written into the folder above the chosen one, and a folder
named that way took everything in it along.

A name is now checked byte by byte: it is something other than "." and
"..", and has no slash and no NUL in it. Apart from that, a download
only writes where the name leads once every "." and ".." is worked out,
and that has to be the entry of that name directly inside the folder.
Each check holds without the other. The second also keeps a file from
being saved under a name the system made out of its own, as happens to
a name that starts with a byte order mark.

The name a single download is saved under, and the names typed for a
new folder or a rename, go by the same rule. The first replaced slashes
by searching the text for them, which stepped over the same combination.

The tests run the client against a small SFTP server inside the test
process, which lists whatever names a test gives it.
2026-11-11 04:45:33 +03:00
Burak Goncu
49fc8626c0 Keep what arrived of a download that did not finish
A copy from the Mac that failed part of the way left the files that had
arrived in a temporary folder, with no way to them. They are put where
finished downloads go, and the row that reports the failure offers them.
2026-11-11 04:21:20 +03:00
Burak Goncu
000b5eb18a Send files to a Mac without dragging them
Dragging a file onto the picture needs somewhere to drag it from, which
an iPhone seldom has. Send Files, in the session's menu on both
platforms, takes files from the system's browser and copies them into
the Mac's Downloads folder, with the same progress as a drop. The Mac
renames a file rather than replace one already there.

A finished upload now stays in the list six seconds, and is sent off
once however often the list changes in that time.
2026-11-11 04:20:33 +03:00