Skip to content

Conversation

@jgrund
Copy link

@jgrund jgrund commented Oct 18, 2022

Allow signals to be sent detached from the channel struct.

This is done using a higher-order function and by cloning the sender so it can be used independently of the Channel.

This is useful to be able to spawn a cancelation handler separately from the main Channel recieve loop.

Signed-off-by: Joe Grund [email protected]

@jgrund jgrund force-pushed the jgrund/detach-signal branch from 1772198 to 6413886 Compare October 18, 2022 20:58
@Eugeny
Copy link
Owner

Eugeny commented Oct 19, 2022

Isn't this something that can be solved with tokio::select? (for any commands, not just .signal())

let channel = ...
let (tx, rx) = mpsc::channel(1);

loop {
    tokio::select! {
        msg = channel.wait() => ...
        sig = rx.recv() => channel.signal(sig)
    }
}

...

tx.send(Sig::...)

@jgrund
Copy link
Author

jgrund commented Oct 19, 2022

Isn't this something that can be solved with tokio::select? (for any commands, not just .signal())

Not really, because I do not want to hold a Channel ref, only a way to send signals to it.

My usecase is a map of signal senders that I can use to interrupt open connections on demand (orchestration platform).

@Eugeny
Copy link
Owner

Eugeny commented Oct 19, 2022

You don't need to hold the ref for that - the ref can stay in the wait() loop, while you can move tx where you need it and use it to send signals

@jgrund
Copy link
Author

jgrund commented Oct 19, 2022

the ref can stay in the wait() loop

Yeah, this is the ref I was talking about.

It's honestly easier to have the channel return me a (scoped) sender directly than to have to create a layer of indirection that does the same thing.

@Eugeny
Copy link
Owner

Eugeny commented Oct 19, 2022

Can't merge this as it's a band-aid fix for one specific method that will eventually lead to duplication of every channel method.

However I'm open to adding a Channel.handle method that would return a handle object that's similar to Channel but only has "sender write" methods such as data/signal/close etc. Could even be a trait shared between it and Channel to avoid duplication.

Let me know if this is something you'd like to work on, otherwise I'll see if I can find time for it in the future.

@jgrund jgrund force-pushed the jgrund/detach-signal branch 2 times, most recently from e803532 to 7b12f66 Compare December 26, 2022 18:40
elegaanz and others added 9 commits May 25, 2024 23:11
The `CryptoVec::resize` implementation was running into a segmentation
fault in some case. If the capacity of the vector was more than 0, and
that the new allocation failed, the call to
`std::ptr::copy_non_overlapping` would have a null pointer as
destination. This was very easy to trigger by a malicious peer, they
just had to send a packet with an announced size large enough for the
allocation to fail. The code now correctly panics, which would only end
the current thread and not crash the whole application without giving it
a chance to continue running.
Adds @elegaanz as a contributor for code.

This was requested by Eugeny [in this
comment](Eugeny#288 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
This worked before [this
change](Eugeny@194430b#diff-81b0128d04a2d9a37bdc6931dec1cb426a8ff7c6ad4ef10e1555ca3e29f08380L159),
and is permitted by the specification, as can be seen in [the example in
section 3.2 of
RFC8332](https://www.rfc-editor.org/rfc/rfc8332#section-3.2).
Authentication using RSA public keys was incorrectly hardcoded to use
`ssh-rsa`, i.e., SHA1. This led to public keys set up to use
`rsa-sha2-256` or `rsa-sha2-512` falling back to `ssh-rsa` and being
rejected by modern SSH servers that are configured not to support SHA1
by default.

The solution derives the hash name from the public key instead of
hardcoding it.
Adds @tomknig as a contributor for code.

This was requested by Eugeny [in this
comment](Eugeny#294 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
@jgrund jgrund force-pushed the jgrund/detach-signal branch from 7b12f66 to 19eebf1 Compare June 4, 2024 16:35
Barre and others added 5 commits June 7, 2024 16:36
Due to an incorrect specified array length, any combinaison of a cipher
using `block.rs`and `HMAC_SHA1_ETM` such as:

```
let mut config = client::Config::default();
config.preferred.cipher = &[cipher::AES_128_CTR];
config.preferred.mac = &[mac::HMAC_SHA1_ETM];
```

Would fail during packet auth.

```
[...]
[2024-06-07T12:49:14Z DEBUG russh::cipher] reading, clear len = 276
[2024-06-07T12:49:14Z DEBUG russh::cipher] read_exact 280
[2024-06-07T12:49:14Z DEBUG russh::cipher] read_exact done
[2024-06-07T12:49:14Z TRACE russh::client] disconnected
[2024-06-07T12:49:14Z DEBUG russh::client] disconnected: Error(PacketAuth)
[2024-06-07T12:49:14Z TRACE mio::poll] deregistering event source from poller
[2024-06-07T12:49:14Z DEBUG russh::client] drop session
[2024-06-07T12:49:14Z DEBUG russh::client] drop handle
```

This PR fixes that.
Adds @Barre as a contributor for code.

This was requested by Eugeny [in this
comment](Eugeny#298 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Adds @spoutn1k as a contributor for code.

This was requested by Eugeny [in this
comment](Eugeny#302 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
This PR addresses issues related to connecting to legacy Cisco devices
with no upgrade path (similar to issue Eugeny#277).

Changes Introduced

• Refactored cipher/mod.rs: Make room to be able to implement CBC crypto
support.
• Updated cipher/block.rs: To provide an interface compatible with both
streaming ciphers and CBC.
• General Cipher Updates: Light modifications to other ciphers for
compatibility with the new interface.

Context

I had trouble connecting to older Cisco devices which posed challenges
due to their outdated cryptographic support.

---------

Co-authored-by: Eugene <[email protected]>
@jgrund jgrund force-pushed the jgrund/detach-signal branch from 19eebf1 to 2b289c2 Compare June 8, 2024 19:07
Eugeny and others added 6 commits June 28, 2024 21:44
- update parse logic to perform host glob matching (using globset)
- generalise token expansion so it can be used to qualify hosts as well
as localising ProxyCommand
- add proxyjump to the config structure

---------

Co-authored-by: Adam Chappell <[email protected]>
Adds @packetsource as a contributor for code.

This was requested by Eugeny [in this
comment](Eugeny#306 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
allcontributors bot and others added 13 commits March 25, 2025 09:52
Adds @MingweiSamuel as a contributor for code.

This was requested by Eugeny [in this
comment](Eugeny#499 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
added native async-trait support
AspectUnk/russh-sftp#62
In this commit, I add a function to russh's client Handle that allows to
manually send a keepalive message to the server.

Fixes: Eugeny#507

Signed-off-by: Uli Schlachter <[email protected]>
Thank you for russh 😻

I needed to send _debug_ messages. I implemented the same way disconnect
is implemented as they both are session global messages.

Looking at the test suites, I did not find any appropriate place to add
a test for that.

One can observe the debug messages sent by a server, for instance, by
activating the `-v` option of ssh client.
Adds @pgrange as a contributor for code.

This was requested by Eugeny [in this
comment](Eugeny#510 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
For instance, if the service can not accept any new connection, instead
of silently terminating, it will return the underlying error:
```
Os { code: 24, kind: Uncategorized, message: "Too many open files" }
```
@jgrund jgrund force-pushed the jgrund/detach-signal branch from 34771f4 to 937fe2b Compare June 4, 2025 17:22
@jgrund jgrund force-pushed the jgrund/detach-signal branch from 937fe2b to 1b150e1 Compare June 5, 2025 20:05
@jgrund jgrund force-pushed the jgrund/detach-signal branch from 1b150e1 to c4be1c6 Compare July 1, 2025 14:58
Allow signals to be sent detached from the channel struct.

This is done using a higher-order function and by cloning the sender so
it can be used independently of the `Channel`.

This is useful to be able to spawn a cancelation handler separately from
the main `Channel` recieve loop.

Signed-off-by: Joe Grund <[email protected]>
f08f74

Signed-off-by: Joe Grund <[email protected]>
@jgrund jgrund force-pushed the jgrund/detach-signal branch from c4be1c6 to 5e77f26 Compare July 1, 2025 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.