working on basic ftp implementation
This commit is contained in:
parent
a45c2b2cf7
commit
be43b49838
18
launcher/src/ftp.rs
Normal file
18
launcher/src/ftp.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use suppaftp::FtpError;
|
||||||
|
use suppaftp::NativeTlsFtpStream;
|
||||||
|
use suppaftp::NativeTlsConnector;
|
||||||
|
use suppaftp::native_tls::Certificate;
|
||||||
|
use suppaftp::native_tls::TlsConnector;
|
||||||
|
|
||||||
|
|
||||||
|
fn ftpConnection() -> Result<NativeTlsFtpStream, FtpError>{
|
||||||
|
let ftp_stream = NativeTlsFtpStream::connect("gitea.piwalker.net:21").unwrap_or_else(|err|
|
||||||
|
panic!("{}", err)
|
||||||
|
);
|
||||||
|
let cert = include_bytes!("../res/vsftpd.crt");
|
||||||
|
let cert = Certificate::from_pem(cert).unwrap();
|
||||||
|
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
||||||
|
ftp_stream.login("anonymous", "anonymous@").map(|_| Ok(ftp_stream)).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -7,6 +7,8 @@ use serde_json::{Result, Value};
|
|||||||
use suppaftp::{FtpError, NativeTlsConnector, NativeTlsFtpStream};
|
use suppaftp::{FtpError, NativeTlsConnector, NativeTlsFtpStream};
|
||||||
use suppaftp::native_tls::{Certificate, TlsConnector};
|
use suppaftp::native_tls::{Certificate, TlsConnector};
|
||||||
|
|
||||||
|
mod ftp;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("test");
|
println!("test");
|
||||||
let ftp_stream = NativeTlsFtpStream::connect("gitea.piwalker.net:21").unwrap_or_else(|err|
|
let ftp_stream = NativeTlsFtpStream::connect("gitea.piwalker.net:21").unwrap_or_else(|err|
|
||||||
@ -16,6 +18,7 @@ fn main() {
|
|||||||
let cert = Certificate::from_pem(cert).unwrap();
|
let cert = Certificate::from_pem(cert).unwrap();
|
||||||
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
||||||
assert!(ftp_stream.login("anonymous", "anonymous@").is_ok());
|
assert!(ftp_stream.login("anonymous", "anonymous@").is_ok());
|
||||||
|
assert!(ftp_stream.size("test").is_ok());
|
||||||
println!("test");
|
println!("test");
|
||||||
let data = ftp_stream.retr_as_buffer("fcs7/versions.json").unwrap();
|
let data = ftp_stream.retr_as_buffer("fcs7/versions.json").unwrap();
|
||||||
println!("test");
|
println!("test");
|
||||||
|
Loading…
Reference in New Issue
Block a user