masneyb / gftp

gFTP is a free multithreaded file transfer client for *NIX based machines. 56 language translations available.
http://www.gftp.org
MIT License
116 stars 20 forks source link

"Local Hosts" #102

Closed wdlkmpx closed 2 years ago

wdlkmpx commented 3 years ago

I spent a couple of days updating and fixing the dialog, it was probably a waste of time, but I learned a few more things..

I think it should be removed. I don't think it's of much use since HTTP (proxy) support was removed (it should probably be reimplemented using a third party lib). But there is FTP proxy support.

I guess this makes sense if you're using gftp without direct internet access or something, but need sources that include FTP servers in a Local Area Network (local hosts) and servers reachable only through proxies.

Is this of any use to anyone?

localhosts

zensubz commented 2 years ago

Hi,

I don't know much technicalities about this one, but from my past experience, I could say, I had used gftp to connect/share data in the local (intranet) servers. I would like to make a request to retain this feature, if possible. Thanks.

wdlkmpx commented 2 years ago

I think this only works if the FTP protocol is being used, and it's used to ignore the proxy server specified in the Preferences dialog when connecting to FTP servers in the local area network.

There is no proxy support for FTPS, SSH, FSP, etc, I see this was potentially used in universities around 2001.

This doesn't make much sense, there should be a checkbox to enable/disable the proxy server so you can connect to any server that doesn't require a proxy.... This is overkill, and indeed it's confusing, as people don't know what's it for.

wdlkmpx commented 2 years ago

This is how this works:

You want connect to ftp.zzzzwwww.org, but you a need a proxy because it's not reachable, so you go to Preferences-FTP and specify the proxy server, and tweak stuff until it works.

Now, you have an FTP a server at 192.168.1.78, but you don't need a proxy server for that, so you add a Local Host.

I think this also make sense if you want to connect to 2 ftp servers at the same time.

It would be more transparent to just add check box to enable/disable the proxy server if it's specified in the preferences dialog... Assuming that a traditional client-server approach is being used...

zensubz commented 2 years ago

@wdlkmpx Thank you very much for explaining the technicalities. I don't remember if there was any proxy setting I had tweaked, all I used to do was connect to the server (intranet) with its IP address, and share data. So if in case that feature is still present in gftp then I shouldn't worry. I am sure you are the right person to really judge regarding the Local-Hosts/proxy feature you have spoken here. Really appreciate the great work you are doing for gftp.

wdlkmpx commented 2 years ago

Testing ftp.proxy to find out whether my theory is correct or not https://github.com/ftpproxy/ftp.proxy ./ftp.proxy -de -D 2001 -r forward

Proxy hostname: localhost Proxy port: 2001 Proxy user: anonymous Proxy pass: xx Type: user@host:port

Host: localhost Port: 21

OK, connected to localhost:21 through localhost:2001

Host: ftp.freebsd.org Port: 21

OK:

Connected to 127.0.0.1:2001
220 server ready - login please
USER anonymous@ftp.freebsd.org:21
331 password required
PASS xxxx
230 login accepted
SYST
215 UNIX Type: L8
.....

Now I want to connect to localhost:21 without a proxy.... I'll add a Local Host (IP & domain) ... hmm unable to bypass proxy.. so what is a Local Host?

In preferences->FTP, I remove the proxy Hostname... proxy disabled. Connect to localhost:21 without proxy

Connected to localhost:21
220 (vsFTPd 3.0.3)
USER anonymous
331 Please specify the password.
PASS xxxx
wdlkmpx commented 2 years ago

It looks like this feature is currently broken, so nobody will notice any change if I remove it completely (even from the core lib).

gftprc

# This section specifies which hosts are on the local subnet and won't need to
# go out the proxy server (if available). Syntax: dont_use_proxy=.domain or
# dont_use_proxy=network number/netmask
dont_use_proxy=127.0.0.1/255.255.255.0
dont_use_proxy=localhost
wdlkmpx commented 2 years ago

I changed some values: dont_use_proxy=127.0.0.1/255.0.0.0 dont_use_proxy=192.168.1.6/255.255.255.0

And got this:

Thread 2 "gftp-gtk" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb60d2b40 (LWP 22273)]
gftp_need_proxy (connect_data=<synthetic pointer>, proxy_port=2001, proxy_hostname=0x471d20 "localhost", 
    service=0x43f01c "ftp", request=0x5b60d0) at socket-connect.c:234
234             (((addy[0] & 0xff) << 24) | ((addy[1] & 0xff) << 16) |

I think this has been broken for a looong time. After commit https://github.com/masneyb/gftp/commit/5196900bb668f603b4d5244d37ca2d71193dba58 gftp no longer segfaults, but the feature remains broken, these are the line(s) to fix: https://github.com/masneyb/gftp/blob/master/lib/socket-connect.c#L261

I've no idea how to fix it.

wdlkmpx commented 2 years ago

I decided to remove the dont_use_proxy stuff, including the related GTK ui code. There's a new option to enable/disable FTP proxy.

I think it was fixable but required a different approach (get IP string and compare against request->hostname and forget about getaddrinfo and netmask). This stuff didn't support ipv6, so voodoo was bound to happen at some point, since it required getaddrinfo.

socket-connect.c required a cleanup, it was getting messy. 'Cause proxy_hosts = hosts that don't use proxy.

Here is a file with all the related code, so that it can be studied and reused for other purposes: gftp__dont_use_proxy.c.zip

Screenshot: Screenshot(5)