KiTTY icon indicating copy to clipboard operation
KiTTY copied to clipboard

BUG: "Proxy choice" filenames can't have spaces.

Open lars18th opened this issue 3 years ago • 17 comments

Hi @cyd01 ,

I'm using the last version of KiTTY (0.74.4.11p), and it seems that the "Proxy choice" functionality is broken. Please, do this check:

  • Connect to any server and configure a Dynamic tunnel (port X).
  • Open a new KiTTY session and configure to connect through the tunnel with a Socks 4 over 127.0.0.1 (port X). You'll see that you can connect.
  • Do the same but now use the Proxy choice using a preconfigured 127.0.0.1 (port X). You'll see that you can not connect. In fact, the KiTTY doesn't try to connect to the socket port.

Please, can you review this? Thank you!

lars18th avatar May 20 '21 20:05 lars18th

Hi,

Updated to 0.74.4.13p and identical behaviour... using the PORTABLE mode. The "Proxy choice" functionality is broken.

lars18th avatar May 20 '21 21:05 lars18th

Can you post your settings to see what is wrong with you ? Thanks

cyd01 avatar May 21 '21 15:05 cyd01

Hi @cyd01 ,

Not required to share any settings file! I do a check with a clean KiTTY inside an empty subdirectory, and after I changed the entry proxyselection=yes in the KITTY.INI to enable the option and I've created a config file in the "\Proxies" subdirectory. So you can check it by youself... it fails. Please, check it.

What I've isolated in recent tests:

  • If you use any non-local IP as the proxy then it works. So here is not the error.
  • However, it fails when you use localhost or 127.0.0.1 in the ProxyHost entry. In this case the KiTTY never arrives to open the proxy socket.
  • And if instead of using the "Proxy choice" you configure identical values in the Connection>Proxy Configuration, then all works.

So, it's when you're using a LOCAL tunnel when it fails. So for this reason I see the problem with tunnels over SSH. Therefore a bug in the "Proxy choice" exists. I'm sure you can reproduce it, and then it will be more easy to debug and fix it.

Regards.

lars18th avatar May 22 '21 11:05 lars18th

I did what you wrote, and it works in my side.
That's why I asked you to send me your files. But I understand if you don't want to.
So I've joined mine. Maybe it can help.

kitty.ini:

[ConfigBox]
proxyselection=yes
[KiTTY]
savemode=dir

Proxy definition file -> localhost:9090 :

ProxyExcludeList\\
ProxyDNS\1\
ProxyLocalhost\0\
ProxyMethod\1\
ProxyHost\localhost\
ProxyPort\9090\
ProxyUsername\\
ProxyPassword\\
ProxyTelnetCommand\connect%20%25host%20%25port%5Cn\
ProxyLogToTerm\1\

Session that establish proxy (with dynamic port forward) :

Present\1\
HostName\user@dest\
Protocol\ssh\
PortNumber\2022\
PortForwardings\D9090=\

Real target (don't forget to select the proxy choice):

Present\1\
HostName\anotheruser@anotherdest\
Protocol\ssh\
PortNumber\2022\

cyd01 avatar May 22 '21 13:05 cyd01

Hi @cyd01 ,

No differences with my configuration. All values are equal (except the ProxyPort/PortForwardings; but I've checked with different ports). Futhermore, it's not necessary to use a "Real target" config, you can type the values manually.

I can't understand why you say it works. As now (previous versions have worked) it fails. I'm using Windows 7 in PORTABLE mode. Any idea?

I'll do more checks to found at which version it started to fail. Thank you for testing it.

lars18th avatar May 22 '21 17:05 lars18th

Hi @cyd01 ,

I found where is the difference, and the problem is very annoying. Let me to explain:

  • In my stored sessions, the one that I use to stablish the tunnel I use PortForwardings\4D1080=\. Note here that I'm enforcing to use TCPv4, instead of auto.
  • Then in this case the listenning of the redirected port starts in the localhost 127.0.0.1 port 1080. However, for an unkown reason this port can't be used by KiTTY. In fact, if I change the port from TCPv4 to Auto in the config... then it continues NOT working.
  • However, if I start initially using the Auto mode for the tunnel, then it really works.

You understand this? In fact I don't want to use IPv6 at all. I'll never want to create any tunnel using this "uncontrollable" protocol (what is the IPv6). But I can't disable it in Windows (without consequencies, so even I don't want to use it it's necessary to have it activated). So for this reason, when using the proxy the "localhost" is resolved to "[::1]" and it works. But, from my point of view this is an error: when using IPv4 for the proxy the localhost requires to resolve to the 127.0.0.1 loopback and not to the IPv6 loopback.

So the question is: Why this works with the regular config proxy and not with the "Proxy choice"? Are you using different code? Are the name resolve calls the same, or you use a different call to resolve the name of the proxy?

lars18th avatar May 22 '21 17:05 lars18th

Hi @cyd01 ,

Can you reproduce the bug?

lars18th avatar May 24 '21 08:05 lars18th

Send me a memory dump of the session that set the proxy just after trying to connect with the other session:

http://www.9bis.net/kitty/#!pages/Savedump.md

Le lun. 24 mai 2021 à 10:15, Lars The @.***> a écrit :

Hi @cyd01 https://github.com/cyd01 ,

Can you reproduce the bug?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cyd01/KiTTY/issues/298#issuecomment-846866408, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIESOBR753QXVWNTZZ6V5MTTPIDLXANCNFSM45H33QYA .

cyd01 avatar May 24 '21 10:05 cyd01

Send me a memory dump of the session that set the proxy just after trying to connect with the other session: http://www.9bis.net/kitty/#!pages/Savedump.md Le lun. 24 mai 2021 à 10:15, Lars The @.***> a écrit :

Hi @cyd01 ,

Please clarify this before I prepare the dump:

  • I'm using the PORTABLE mode, and the Pointed https://www.9bis.net/kitty/files/kitty-debug.exe debug version is not the portable one. What I need to do?
  • You want the dump of the original session that creates the IPv4 tunnel (the 127.0.0.1:1080 Socks4 server) or the proxied version (the one that wants to connect over the socks4 server)?

lars18th avatar May 24 '21 11:05 lars18th

Hi @cyd01 ,

Now I see WHERE is the bug. The bug is not related to IPv4/IPv6. The bug is because a limit of files in the user "Proxy choice" lists. So, the first 10 files are working, but from the file 11 all fails! .

So how to reproduce the bug:

  • Generate 11 identical files (with different filename) in the subdirectory \Proxies\.
  • Then open the proxy server, and try to connect with the file 10 in the "Proxy choice" list. In this case ALL works.
  • After try to do the same using the file 11 in the "Proxy choice" list. Files are identical so the proxy is the same. However, in this case the connection fails (in fact KiTTY is trying to connect directly without the proxy).

Please try it! In this case I'm sure you can reproduce the bug.

lars18th avatar May 25 '21 07:05 lars18th

Very strange ! The proxy limit is 100: https://github.com/cyd01/KiTTY/blob/64dd8883c3fd889c2c77bc0dfcb0f09817c865cd/kitty_proxy.h#L4 I'll try to look at it when I'll finish with 0.75. Cyd

Le mar. 25 mai 2021 à 09:23, Lars The @.***> a écrit :

Hi @cyd01 https://github.com/cyd01 ,

Now I see WHERE is the bug. The bug is not related to IPv4/IPv6. The bug is because a limit of files in the user "Proxy choice" lists. So, the first 10 files are working, but from the file 11 all fails! .

So how to reproduce the bug:

  • Generate 11 identical files (with different filename) in the subdirectory \Proxies.
  • Then open the proxy server, and try to connect with the file 10 in the "Proxy choice" list. In this case ALL works.
  • After try to do the same using the file 11 in the "Proxy choice" list. Files are identical so the proxy is the same. However, in this case the connection fails (in fact KiTTY is trying to connect directly without the proxy).

Please try it! In this case I'm sure you can reproduce the bug.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cyd01/KiTTY/issues/298#issuecomment-847617263, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIESOBV6I643SMV7X3WC2JTTPNGA3ANCNFSM45H33QYA .

cyd01 avatar May 25 '21 08:05 cyd01

Hi @cyd01 ,

Yes, I see the limit of the 100 proxies in the list. And the name of the files are correct. The bug is in another point as the file is right readed. I compiled the current version without the encryption to read the dump file, and I see an interesting point in the dump:

...
@@@ RunningConfig @@@
...
proxy_type=0
proxy_host=127.0.0.1
proxy_port=1080
proxy_username=
proxy_password=
proxy_telnet_command=connect %host %port\n
proxy_log_to_term=1
...
proxyselection=Socks-1080 (cluster1)

What you can see here? All the proxy parameters are readed right. However, the proxyselection value has SPACES. So I chanded the name of the proxy filename to remove the spaces and... voilà! Now works! :smile:

So the bug is this: "Proxy choice" filenames can't have spaces. I hope you can fix it at some point (at time I'm changing all the filenames). Regards.

lars18th avatar May 25 '21 08:05 lars18th

Note: Why not add the option to disable (optionally) the encryption of the dump file? Then it will be more easy for the user to review the internals.

lars18th avatar May 25 '21 08:05 lars18th

I've just remember: portable mode code came originally from PuTTY tray. They chose that filenames does not have non-alphanumeric character. And I've chosen to keep that solution in KiTTY.
filenames are encoded/decoded with two functions mungestr/unmungestr. Basically spaces are replaced by %20. Can you try that ? I've added to command-line options:

  • -mungestr
  • -unmungestr to help with conversions. The result of conversion is in the clipboard.

cyd01 avatar May 26 '21 06:05 cyd01

Hi @cyd01 ,

kitty_portable.exe -mungestr

Shows a modal window with

%08%95%80

I don't understand what you want. Anyway, if you don't change anything then explain in the documentation: "Proxy files (and perhaps others) in the PORTABLE mode requires to not have spaces". When the problem is identified then it's easy to overcome it. Now all my proxy files doesn't have spaces. :wink:

Anyway, regarding the portable mode: I see that inside KiTTY is a lot of code that is more or less this: if registry then ... else (portable) then .... Perhaps in the future you'll want to rewrite the portable mode creating new abstract functions to read configuration values, and then implement two concrete managers: for registry and for files. Then it will be more easy to add new functionalities as then it will be not necessary to implement new code for portable and/or registry. What you think?

lars18th avatar May 26 '21 07:05 lars18th

It's not only spaces. It's all non alphanumeric characters. You have to convert the name first. And in the UI, the name will be decoded to be readable. And no, in the future I won't rewrite the portable mode.

Le mer. 26 mai 2021 à 09:22, Lars The @.***> a écrit :

Hi @cyd01 https://github.com/cyd01 ,

kitty_portable.exe -mungestr

Shows a modal window with

%08%95%80

I don't understand what you want. Anyway, if you don't change anything then explain in the documentation: "Proxy files (and perhaps others) in the PORTABLE mode requires to not have spaces". When the problem is identified then it's easy to overcome it. Now all my proxy files doesn't have spaces. 😉

Anyway, regarding the portable mode: I see that inside KiTTY is a lot of code that is more or less this: if registry then ... else (portable) then .... Perhaps in the future you'll want to rewrite the portable mode creating new abstract functions to read configuration values, and then implement two concrete managers: for registry and for files. Then it will be more easy to add new functionalities as then it will be not necessary to implement new code for portable and/or registry. What you think?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cyd01/KiTTY/issues/298#issuecomment-848532923, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIESOBRXAE32KMDNHQ22JZLTPSOU5ANCNFSM45H33QYA .

cyd01 avatar May 26 '21 10:05 cyd01

It's not only spaces. It's all non alphanumeric characters. You have to convert the name first. And in the UI, the name will be decoded to be readable.

So, I'll use only plain characters for proxy filenames.

And no, in the future I won't rewrite the portable mode.

Ok. No proglem!

lars18th avatar May 26 '21 11:05 lars18th