{"action":"opened","issue":{"url":"https://api.github.com/repos/dutchcoders/goftp/issues/24","repository_url":"https://api.github.com/repos/dutchcoders/goftp","labels_url":"https://api.github.com/repos/dutchcoders/goftp/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/dutchcoders/goftp/issues/24/comments","events_url":"https://api.github.com/repos/dutchcoders/goftp/issues/24/events","html_url":"https://github.com/dutchcoders/goftp/issues/24","id":190664244,"number":24,"title":"When the FTP server is deployed on the LVS, goftp Can't make a data connection.","user":{"login":"Mohanson","id":12387889,"avatar_url":"https://avatars.githubusercontent.com/u/12387889?v=3","gravatar_id":"","url":"https://api.github.com/users/Mohanson","html_url":"https://github.com/Mohanson","followers_url":"https://api.github.com/users/Mohanson/followers","following_url":"https://api.github.com/users/Mohanson/following{/other_user}","gists_url":"https://api.github.com/users/Mohanson/gists{/gist_id}","starred_url":"https://api.github.com/users/Mohanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mohanson/subscriptions","organizations_url":"https://api.github.com/users/Mohanson/orgs","repos_url":"https://api.github.com/users/Mohanson/repos","events_url":"https://api.github.com/users/Mohanson/events{/privacy}","received_events_url":"https://api.github.com/users/Mohanson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-21T09:42:32Z","updated_at":"2016-11-21T09:42:32Z","closed_at":null,"body":"Consider when A FTP Server is on Linux LVS, which means the VIP(Virtual IP) != RealIP.\r\n\r\n`func (ftp *FTP) Pasv()` only return a port, and `func (ftp *FTP) newConnection(port int) (conn net.Conn, err error)` will combine the `VIP` of LVS and `Port` instead of `RealIP` and `Port`.\r\n\r\n```\r\nfunc (ftp *FTP) Pasv() (port int, err error) {\r\n\tvar line string\r\n\tif line, err = ftp.cmd(\"227\", \"PASV\"); err != nil {\r\n\t\treturn\r\n\t}\r\n\r\n\tre, err := regexp.Compile(`\\((.*)\\)`)\r\n\r\n\tres := re.FindAllStringSubmatch(line, -1)\r\n\r\n\ts := strings.Split(res[0][1], \",\")\r\n\r\n\tl1, _ := strconv.Atoi(s[len(s)-2])\r\n\tl2, _ := strconv.Atoi(s[len(s)-1])\r\n\r\n\tport = l1<<8 + l2\r\n\r\n\treturn\r\n}\r\n\r\n// open new data connection\r\nfunc (ftp *FTP) newConnection(port int) (conn net.Conn, err error) {\r\n\taddr := fmt.Sprintf(\"%s:%d\", strings.Split(ftp.addr, \":\")[0], port)\r\n\r\n\tif ftp.debug {\r\n\t\tlog.Printf(\"Connecting to %s\\n\", addr)\r\n\t}\r\n\r\n\tif conn, err = net.Dial(\"tcp\", addr); err != nil {\r\n\t\treturn\r\n\t}\r\n\r\n\tif ftp.tlsconfig != nil {\r\n\t\tconn = tls.Client(conn, ftp.tlsconfig)\r\n\t}\r\n\r\n\treturn\r\n}\r\n```\r\n\r\nI suggest use `func (ftp *FTP) Pasv() (host string, port int, err error) ` and `func (ftp *FTP) newConnection(host string, port int) (conn net.Conn, err error)`\r\n\r\nIf you want it , I will push a request pull."}}
{"actor":{"display_login":"Mohanson"}}