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)

This commit is contained in:
4zv4l 2024-04-05 16:23:01 +08:00 committed by GitHub
parent 2c646bfadd
commit 38b3115a9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -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 {

View File

@ -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