Skip to content

Commit b72513f

Browse files
committed
transit: Make TransitConnector crate-public
1 parent ae67e35 commit b72513f

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

src/transfer/v2.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,25 @@ async fn make_transit(
128128
};
129129

130130
/* Get a transit connection */
131-
let (transit, info) = match connector
132-
.connect(
131+
let connect_result = if is_leader {
132+
connector
133+
.leader_connect(
134+
is_leader,
135+
wormhole.key().derive_transit_key(wormhole.appid()),
136+
peer_abilities,
137+
Arc::new(their_hints),
138+
)
139+
.await
140+
} else {
141+
connector.follower_connect(
133142
is_leader,
134143
wormhole.key().derive_transit_key(wormhole.appid()),
135144
peer_abilities,
136145
Arc::new(their_hints),
137146
)
138-
.await
139-
{
147+
};
148+
149+
let (transit, info) = match connect_result {
140150
Ok(transit) => transit,
141151
Err(error) => {
142152
let error = TransferError::TransitConnect(error);

src/transit.rs

+3-26
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const PUBLIC_STUN_SERVER: &str = "stun.piegames.de:3478";
5151
note = "This will be a private type in the future. Open an issue if you require access to protocol intrinsics in the future"
5252
)]
5353
#[derive(Debug)]
54-
pub struct TransitKey;
54+
pub(crate) struct TransitKey;
5555

5656
#[expect(deprecated)]
5757
impl KeyPurpose for TransitKey {}
@@ -785,7 +785,7 @@ pub fn log_transit_connection(
785785
note = "This will be a private type in the future. Open an issue if you require access to protocol intrinsics in the future"
786786
)]
787787
#[expect(deprecated)]
788-
pub async fn init(
788+
pub(crate) async fn init(
789789
mut abilities: Abilities,
790790
peer_abilities: Option<Abilities>,
791791
relay_hints: Vec<RelayHint>,
@@ -931,7 +931,7 @@ impl MaybeConnectedSocket {
931931
since = "0.7.0",
932932
note = "This will be a private type in the future. Open an issue if you require access to protocol intrinsics in the future"
933933
)]
934-
pub struct TransitConnector {
934+
pub(crate) struct TransitConnector {
935935
/* Only `Some` if direct-tcp-v1 ability has been enabled.
936936
* The first socket is the port from which we will start connection attempts.
937937
* For in case the user is behind no firewalls, we must also listen to the second socket.
@@ -954,29 +954,6 @@ impl TransitConnector {
954954
&self.our_hints
955955
}
956956

957-
/**
958-
* Forwards to either [`leader_connect`](Self::leader_connect) or [`follower_connect`](Self::follower_connect).
959-
*
960-
* It usually is better to call the respective functions directly by their name, as it makes
961-
* them less easy to confuse (confusion may still happen though). Nevertheless, sometimes it
962-
* is desirable to use the same code for both sides and only track the side with a boolean.
963-
*/
964-
pub async fn connect(
965-
self,
966-
is_leader: bool,
967-
transit_key: Key<TransitKey>,
968-
their_abilities: Abilities,
969-
their_hints: Arc<Hints>,
970-
) -> Result<(Transit, TransitInfo), TransitConnectError> {
971-
if is_leader {
972-
self.leader_connect(transit_key, their_abilities, their_hints)
973-
.await
974-
} else {
975-
self.follower_connect(transit_key, their_abilities, their_hints)
976-
.await
977-
}
978-
}
979-
980957
/**
981958
* Connect to the other side, as sender.
982959
*/

0 commit comments

Comments
 (0)