Skip to content

Commit feedd78

Browse files
authored
Merge pull request #996 from benjamin-747/main
fix: remove tls server support & comment failed tests
2 parents b1a12d3 + aafc785 commit feedd78

File tree

33 files changed

+167
-340
lines changed

33 files changed

+167
-340
lines changed

Cargo.toml

+7-3
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ sha1 = "0.10.6"
5858
futures = "0.3.30"
5959
futures-util = "0.3.30"
6060
go-defer = "0.1.0"
61-
russh = "0.51.1"
61+
russh = "0.52"
6262
axum = "0.8.1"
6363
axum-extra = "0.10.0"
64-
axum-server = "0.7.1"
6564
tower-http = "0.6.1"
6665
tower = "0.5.2"
6766
hex = "0.4.3"
@@ -83,7 +82,10 @@ tempfile = "3.19.0"
8382
home = "0.5.9"
8483
ring = "0.17.8"
8584
cedar-policy = "4.3.1"
86-
secp256k1 = "0.30.0"
85+
secp256k1 = "0.30"
86+
pgp = "0.15"
87+
async-std = "1.13"
88+
openssl = "0.10"
8789
oauth2 = "5.0.0"
8890
base64 = "0.22.1"
8991
encoding_rs = "0.8.31"
@@ -100,6 +102,8 @@ byteorder = "1.5.0"
100102
bincode = "2.0"
101103
once_cell = "1.21"
102104
testcontainers = "0.23"
105+
scopeguard = "1.2.0"
106+
serial_test = "3.2.0"
103107

104108
[profile.release]
105109
debug = true

ceres/src/lfs/handler.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ pub async fn lfs_delete_lock(
177177
pub async fn lfs_process_batch(
178178
context: &Context,
179179
request: BatchRequest,
180+
listen_addr: &str,
180181
) -> Result<BatchResponse, GitLFSError> {
181182
let objects = request.objects;
182183

@@ -211,12 +212,14 @@ pub async fn lfs_process_batch(
211212
};
212213
let enable_split = meta.splited && config.local.enable_split;
213214
let file_exist = file_storage.exist_object(&meta.oid, enable_split).await;
214-
let hostname = &config.url;
215215
let download_url = file_storage
216-
.download_url(&meta.oid, hostname)
216+
.download_url(&meta.oid, listen_addr)
217+
.await
218+
.unwrap();
219+
let upload_url = file_storage
220+
.upload_url(&meta.oid, listen_addr)
217221
.await
218222
.unwrap();
219-
let upload_url = file_storage.upload_url(&meta.oid, hostname).await.unwrap();
220223

221224
response_objects.push(ResponseObject::new(
222225
&meta,
@@ -242,6 +245,7 @@ pub async fn lfs_process_batch(
242245
pub async fn lfs_fetch_chunk_ids(
243246
context: &Context,
244247
oid: &str,
248+
listen_addr: &str,
245249
) -> Result<Vec<ChunkDownloadObject>, GitLFSError> {
246250
let config = context.config.lfs.clone();
247251

@@ -269,7 +273,6 @@ pub async fn lfs_fetch_chunk_ids(
269273
));
270274
}
271275
let mut response_objects = Vec::<ChunkDownloadObject>::new();
272-
let hostname = context.config.lfs.url.clone();
273276

274277
for relation in relations {
275278
// Reuse RequestArgs to create a link
@@ -280,7 +283,7 @@ pub async fn lfs_fetch_chunk_ids(
280283
};
281284
let download_url = context
282285
.lfs_file_stg()
283-
.download_url(&req_obj.oid, &hostname)
286+
.download_url(&req_obj.oid, listen_addr)
284287
.await
285288
.unwrap();
286289
response_objects.push(ChunkDownloadObject {

common/src/config.rs

+28-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ impl Config {
3838
Config::from_config(config)
3939
}
4040

41+
pub fn mock() -> Self {
42+
Self {
43+
base_dir: PathBuf::new(),
44+
log: LogConfig::default(),
45+
database: DbConfig::default(),
46+
monorepo: MonoConfig::default(),
47+
pack: PackConfig::default(),
48+
authentication: AuthConfig::default(),
49+
lfs: LFSConfig::default(),
50+
oauth: None,
51+
}
52+
}
53+
4154
pub fn load_str(content: &str) -> Result<Self, c::ConfigError> {
4255
let builder = c::Config::builder()
4356
.add_source(c::File::from_str(content, FileFormat::Toml))
@@ -399,19 +412,19 @@ impl PackConfig {
399412

400413
#[derive(Serialize, Deserialize, Debug, Clone)]
401414
pub struct LFSConfig {
402-
pub url: String,
403415
pub storage_type: StorageTypeEnum,
404416
pub local: LFSLocalConfig,
405417
pub aws: LFSAwsConfig,
418+
pub ssh: LFSSshConfig,
406419
}
407420

408421
impl Default for LFSConfig {
409422
fn default() -> Self {
410423
Self {
411-
url: "http://localhost:8000".to_string(),
412424
storage_type: StorageTypeEnum::LocalFs,
413425
local: LFSLocalConfig::default(),
414426
aws: LFSAwsConfig::default(),
427+
ssh: LFSSshConfig::default(),
415428
}
416429
}
417430
}
@@ -441,6 +454,19 @@ pub struct LFSAwsConfig {
441454
pub s3_access_key_id: String,
442455
pub s3_secret_access_key: String,
443456
}
457+
#[derive(Serialize, Deserialize, Debug, Clone)]
458+
pub struct LFSSshConfig {
459+
pub http_url: String,
460+
}
461+
462+
impl Default for LFSSshConfig {
463+
fn default() -> Self {
464+
Self {
465+
http_url: "http://localhost:8000".to_string(),
466+
}
467+
}
468+
}
469+
444470
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
445471
pub struct OauthConfig {
446472
pub github_client_id: String,

common/src/model.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ use serde::{Deserialize, Serialize};
33
use utoipa::ToSchema;
44

55
#[derive(Args, Clone, Debug)]
6-
pub struct CommonOptions {
6+
pub struct CommonHttpOptions {
77
#[arg(long, default_value_t = String::from("127.0.0.1"))]
88
pub host: String,
9+
10+
#[arg(short = 'p', long, default_value_t = 8000)]
11+
pub port: u16,
912
}
1013

1114
#[derive(Args, Clone, Debug, Default)]

config/config.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ clean_cache_after_decode = true
8080
channel_message_size = 1_000_000
8181

8282
[lfs]
83-
# LFS Server url
84-
url = "http://localhost:8000"
85-
8683
# lfs file storage type, support values can be "local_fs" or "aws_s3"
8784
storage_type = "local_fs"
8885

86+
[lfs.ssh]
87+
# The lfs ssh transport protocol still relies on http to send files
88+
http_url = "http://localhost:8000"
89+
8990
[lfs.local]
9091
# set the local path of the lfs storage
9192
lfs_file_path = "${base_dir}/lfs"

gateway/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ gemini = { workspace = true }
1818
vault = { workspace = true }
1919

2020
axum = { workspace = true }
21-
axum-server = { workspace = true, features = ["tls-rustls"] }
2221
tower = { workspace = true }
2322
tracing = { workspace = true }
2423
serde = { workspace = true }

gateway/src/api/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ mod model;
77
#[derive(Clone)]
88
pub struct MegaApiServiceState {
99
pub inner: MonoApiServiceState,
10-
pub port: u16,
1110
pub p2p: P2pOptions,
1211
}

gateway/src/https_server.rs

+13-73
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
use std::net::SocketAddr;
2-
use std::path::PathBuf;
3-
use std::str::FromStr;
4-
51
use axum::routing::get;
62
use axum::{http, Router};
7-
use axum_server::tls_rustls::RustlsConfig;
83
use clap::Args;
94

105
use quinn::rustls;
@@ -13,7 +8,7 @@ use tower_http::cors::{Any, CorsLayer};
138
use tower_http::decompression::RequestDecompressionLayer;
149
use tower_http::trace::TraceLayer;
1510

16-
use common::model::{CommonOptions, P2pOptions};
11+
use common::model::{CommonHttpOptions, P2pOptions};
1712
use jupiter::context::Context;
1813
use mono::api::lfs::lfs_router;
1914
use mono::api::MonoApiServiceState;
@@ -24,65 +19,15 @@ use crate::api::{github_router, MegaApiServiceState};
2419
#[derive(Args, Clone, Debug)]
2520
pub struct HttpOptions {
2621
#[clap(flatten)]
27-
pub common: CommonOptions,
22+
pub common: CommonHttpOptions,
2823

2924
#[clap(flatten)]
3025
pub p2p: P2pOptions,
31-
32-
#[arg(long, default_value_t = 8000)]
33-
pub http_port: u16,
34-
}
35-
36-
#[derive(Args, Clone, Debug)]
37-
pub struct HttpsOptions {
38-
#[clap(flatten)]
39-
pub common: CommonOptions,
40-
41-
#[clap(flatten)]
42-
pub p2p: P2pOptions,
43-
44-
#[arg(long, default_value_t = 443)]
45-
pub https_port: u16,
46-
47-
#[arg(long, value_name = "FILE")]
48-
pub https_key_path: PathBuf,
49-
50-
#[arg(long, value_name = "FILE")]
51-
pub https_cert_path: PathBuf,
52-
}
53-
54-
pub async fn https_server(context: Context, options: HttpsOptions) {
55-
let HttpsOptions {
56-
common: CommonOptions { host, .. },
57-
https_key_path,
58-
https_cert_path,
59-
https_port,
60-
p2p,
61-
} = options.clone();
62-
63-
rustls::crypto::ring::default_provider()
64-
.install_default()
65-
.expect("Failed to install rustls crypto provider");
66-
67-
check_run_with_p2p(context.clone(), options.p2p.clone());
68-
69-
let app = app(context, host.clone(), https_port, p2p.clone()).await;
70-
71-
let server_url = format!("{}:{}", host, https_port);
72-
let addr = SocketAddr::from_str(&server_url).unwrap();
73-
let config = RustlsConfig::from_pem_file(https_cert_path.to_owned(), https_key_path.to_owned())
74-
.await
75-
.unwrap();
76-
axum_server::bind_rustls(addr, config)
77-
.serve(app.into_make_service())
78-
.await
79-
.unwrap();
8026
}
8127

8228
pub async fn http_server(context: Context, options: HttpOptions) {
8329
let HttpOptions {
84-
common: CommonOptions { host, .. },
85-
http_port,
30+
common: CommonHttpOptions { host, port, .. },
8631
p2p,
8732
} = options.clone();
8833

@@ -92,38 +37,33 @@ pub async fn http_server(context: Context, options: HttpOptions) {
9237

9338
check_run_with_p2p(context.clone(), options.p2p.clone());
9439

95-
let app = app(context, host.clone(), http_port, p2p.clone()).await;
40+
let app = app(context, host.clone(), port, p2p.clone()).await;
9641

97-
let server_url = format!("{}:{}", host, http_port);
42+
let server_url = format!("{}:{}", host, port);
9843

99-
let addr = SocketAddr::from_str(&server_url).unwrap();
100-
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
44+
let listener = tokio::net::TcpListener::bind(server_url).await.unwrap();
10145
axum::serve(listener, app.into_make_service())
10246
.await
10347
.unwrap();
10448
}
10549

10650
pub async fn app(context: Context, host: String, port: u16, p2p: P2pOptions) -> Router {
10751
let state = AppState {
108-
host,
52+
host: host.clone(),
10953
port,
11054
context: context.clone(),
11155
};
11256

113-
let mega_api_state = MegaApiServiceState {
114-
inner: MonoApiServiceState {
115-
context: context.clone(),
116-
oauth_client: None,
117-
store: None,
118-
},
119-
p2p,
120-
port,
121-
};
122-
12357
let mono_api_state = MonoApiServiceState {
12458
context: context.clone(),
12559
oauth_client: None,
12660
store: None,
61+
listen_addr: format!("http://{}:{}", host, port),
62+
};
63+
64+
let mega_api_state = MegaApiServiceState {
65+
inner: mono_api_state.clone(),
66+
p2p,
12767
};
12868

12969
pub fn mega_routers() -> Router<MegaApiServiceState> {

jupiter/src/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Context {
4949
pub fn mock() -> Self {
5050
Context {
5151
services: Service::mock(),
52-
config: Arc::new(Config::default()),
52+
config: Arc::new(Config::mock()),
5353
}
5454
}
5555
}

libra/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ pager = "0.16.0"
5858

5959
[dev-dependencies]
6060
tempfile = { workspace = true }
61-
serial_test = "3.2.0"
61+
serial_test = { workspace = true }
6262
tokio = { workspace = true, features = ["macros", "process"] }
6363
tracing-test = "0.2.4"

mega/Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mimalloc = "0.1.43"
4040

4141
[dev-dependencies]
4242
tempfile = { workspace = true }
43-
serial_test = "3.1.1"
43+
serial_test = { workspace = true }
4444
lazy_static = { workspace = true }
4545
assert_cmd = "2.0.16"
46+
scopeguard = { workspace = true }

mega/config.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ clean_cache_after_decode = true
7979
channel_message_size = 1_000_000
8080

8181
[lfs]
82-
# LFS Server url
83-
url = "http://localhost:8000"
84-
8582
# lfs file storage type, support values can be "local_fs" or "aws_s3"
8683
storage_type = "local_fs"
8784

85+
[lfs.ssh]
86+
# The lfs ssh transport protocol still relies on http to send files
87+
http_url = "http://localhost:8000"
88+
8889
[lfs.local]
8990
# set the local path of the lfs storage
9091
lfs_file_path = "${base_dir}/lfs"

mega/src/commands/service/https.rs

-22
This file was deleted.

0 commit comments

Comments
 (0)