From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs 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 Message-ID: <87r1lt2s8k.fsf@neverwas.me> References: <875z355sh9.fsf@neverwas.me> <83pn1do008.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35650"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: 46342@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 06 15:21:18 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l8OSc-0009BT-1l for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Feb 2021 15:21:18 +0100 Original-Received: from localhost ([::1]:48518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l8OSb-0007Jz-0x for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 06 Feb 2021 09:21:17 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l8OSP-0007Ii-0T for bug-gnu-emacs@gnu.org; Sat, 06 Feb 2021 09:21:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33926) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l8OSN-0006ml-Ln for bug-gnu-emacs@gnu.org; Sat, 06 Feb 2021 09:21:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l8OSM-0006EB-Ho for bug-gnu-emacs@gnu.org; Sat, 06 Feb 2021 09:21:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Feb 2021 14:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46342 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46342-submit@debbugs.gnu.org id=B46342.161262120823854 (code B ref 46342); Sat, 06 Feb 2021 14:21:02 +0000 Original-Received: (at 46342) by debbugs.gnu.org; 6 Feb 2021 14:20:08 +0000 Original-Received: from localhost ([127.0.0.1]:45472 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8ORU-0006Cf-8E for submit@debbugs.gnu.org; Sat, 06 Feb 2021 09:20:08 -0500 Original-Received: from mail-108-mta27.mxroute.com ([136.175.108.27]:43337) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l8ORQ-0006CT-Qn for 46342@debbugs.gnu.org; Sat, 06 Feb 2021 09:20:07 -0500 Original-Received: from filter004.mxroute.com ([149.28.56.236] 149.28.56.236.vultr.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta27.mxroute.com (ZoneMTA) with ESMTPSA id 17777b6b8e20006238.001 for <46342@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sat, 06 Feb 2021 14:19:59 +0000 X-Zone-Loop: 898c3d798d1acd322ce130c3498d31f4d4a17e5072fb X-Originating-IP: [149.28.56.236] Original-Received: from eagle.mxlogin.com (23-92-74-70.static.hvvc.us [23.92.74.70]) by filter004.mxroute.com (Postfix) with ESMTPS id 579133E9F2; Sat, 6 Feb 2021 14:19:58 +0000 (UTC) In-Reply-To: <83pn1do008.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 06 Feb 2021 14:26:31 +0200") X-AuthUser: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199438 Archived-At: Hi Eli. Thanks for the quick reply. Eli Zaretskii 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!