当使用主动模式时ActiveTransfers设置为true,然后想指定使用的端口,反复尝试配置ActiveListenAddr参数,发现只能配置为 ip:0 这种格式使用动态端口,指定一个端口时会报错
ActiveListenAddr配置为 172.16.50.190:24001 报错如下
goftp: 6.383 #1 was ready
goftp: 6.383 #1 listening on 172.16.50.190:24001 for active connection
goftp: 6.383 #1 sending command PORT 172,16,50,190,93,193
goftp: 6.384 #1 got 200-Connection established (24001)
goftp: 6.385 #1 sending command MLSD .
goftp: 6.385 #1 got 500-Command not found
goftp: 6.385 #1 was ready
panic: error listening on 172.16.50.190:24001 for active transfer: listen tcp 172.16.50.190:24001: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.
ActiveListenAddr配置为 172.16.50.190:0 工作正常
goftp: 2.667 #1 listening on 172.16.50.190:52771 for active connection
goftp: 2.667 #1 sending command PORT 172,16,50,190,206,35
goftp: 2.667 #1 got 200-Connection established (52771)
goftp: 2.668 #1 sending command MLSD .
goftp: 2.668 #1 got 500-Command not found
goftp: 2.668 #1 was ready
goftp: 2.668 #1 listening on 172.16.50.190:52773 for active connection
goftp: 2.668 #1 sending command PORT 172,16,50,190,206,37
goftp: 2.668 #1 got 200-Connection established (52773)
goftp: 2.669 #1 sending command LIST .
goftp: 2.671 #1 got 150-Opening ASCII mode data connection for file list
当使用主动模式时ActiveTransfers设置为true,然后想指定使用的端口,反复尝试配置ActiveListenAddr参数,发现只能配置为 ip:0 这种格式使用动态端口,指定一个端口时会报错
看起来是内部逻辑多次监听同一个地址导致的,既然是要使用多个端口,ActiveListenAddr是否应该配置一个端口范围呢