bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#46342: 28.0.50; socks-send-command munges IP address bytes to UTF-8


From: J.P.
Subject: bug#46342: 28.0.50; socks-send-command munges IP address bytes to UTF-8
Date: Sat, 06 Feb 2021 06:19:55 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Hi Eli. Thanks for the quick reply.

Eli Zaretskii <eliz@gnu.org> writes:

> What I don't understand is what is the "appropriate" encoding in this
> case. Can you explain why you use literal bytes in the test?  What
> are those bytes supposed to stand for, and which program is supposed
> to receive this sequence of bytes on the other end of the connect
> command?

Re appropriate encoding: correct me if I'm wrong (internet), but among
the Emacs coding systems, it'd be latin-1. In the proposed patch for
socks-send-command, swapping out the call to unibyte-string with
(encode-coding-string address 'latin-1) has the same effect of
preserving, say, char 216 as the single byte "\330" and not "\303\230".

Re literal bytes in test(s): I'm assuming you mean all the vectors. If
that's annoying or distracting, my apologies. I used them for no other
reason than I thought them easier to read. I also found them less error
prone than octal or hex escapes in strings, as warned about in (info
"(elisp) Non-ASCII in Strings"). However, I'm happy to follow whatever
the convention is.

Re meaning of the bytes: they stand for the fields in SOCKS 4 messages.
The protocol is byte oriented, so it's easy enough to read with tcpdump
since there's no meticulous packing going on when serializing, just
verbatim octets. Not the most economical, but after a brief negotiation,
it's off to proxying.

For example, you'd read

  4 1 0 80 93 184 216 34

as version 4, command 1 (connect), port 80 (2 bytes, big endian to 65535),
IPv4 address 93.184.216.34

Re program on the other end: this would be any program offering a proxy
service that speaks the same protocol. Popular ones include tor and ssh.
There's also a "bind" command that allows your client (Emacs) to act as
a server and listen/accept connections on the remote end as if they were
present on your local network.

I'm no expert, but I'll do my best to answer any further questions.
Thanks so much and enjoy your weekend!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]