From 38b3115a9cd6cc4bbf4f79ef6074378fe91b8ddf Mon Sep 17 00:00:00 2001 From: 4zv4l <46655455+4zv4l@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:23:01 +0800 Subject: [PATCH] breaking,net.ftp: allow to choose a different port than port 21 (change FTP.connect to accept `host:port`, not just a `host` address) (#21185) --- vlib/net/ftp/ftp.v | 6 +++--- vlib/net/ftp/ftp_test.v | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/net/ftp/ftp.v b/vlib/net/ftp/ftp.v index 023023450f..01db981bc7 100644 --- a/vlib/net/ftp/ftp.v +++ b/vlib/net/ftp/ftp.v @@ -100,9 +100,9 @@ fn (mut zftp FTP) read() !(int, string) { return code, data } -// connect establishes an FTP connection to the host at `ip` port 21. -pub fn (mut zftp FTP) connect(ip string) !bool { - zftp.conn = net.dial_tcp('${ip}:21')! +// connect establishes an FTP connection to the host at `oaddress` (ip:port). +pub fn (mut zftp FTP) connect(oaddress string) !bool { + zftp.conn = net.dial_tcp(oaddress)! zftp.reader = io.new_buffered_reader(reader: zftp.conn) code, _ := zftp.read()! if code == ftp.connected { diff --git a/vlib/net/ftp/ftp_test.v b/vlib/net/ftp/ftp_test.v index 539a9ef13b..bfea567bb3 100644 --- a/vlib/net/ftp/ftp_test.v +++ b/vlib/net/ftp/ftp_test.v @@ -17,7 +17,7 @@ fn ftp_client_test_inside() ! { defer { zftp.close() or { panic(err) } } - connect_result := zftp.connect('ftp.redhat.com')! + connect_result := zftp.connect('ftp.redhat.com:21')! assert connect_result login_result := zftp.login('ftp', 'ftp')! assert login_result