From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/34031 Path: main.gmane.org!not-for-mail From: Jake Colman Newsgroups: gmane.emacs.gnus.general Subject: Help defadvising nnimap-open-connection Date: 03 Jan 2001 13:42:28 -0500 Sender: owner-ding@hpc.uh.edu Message-ID: <767l4c5vfv.fsf@newjersey.ppllc.com> NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1035170032 28298 80.91.224.250 (21 Oct 2002 03:13:52 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 03:13:52 +0000 (UTC) Cc: Simon Josefsson Return-Path: Original-Received: from spinoza.math.uh.edu (spinoza.math.uh.edu [129.7.128.18]) by mailhost.sclp.com (Postfix) with ESMTP id D377BD049D for ; Wed, 3 Jan 2001 15:43:46 -0500 (EST) Original-Received: from sina.hpc.uh.edu (lists@Sina.HPC.UH.EDU [129.7.3.5]) by spinoza.math.uh.edu (8.9.1/8.9.1) with ESMTP id OAB29766; Wed, 3 Jan 2001 14:43:08 -0600 (CST) Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Wed, 03 Jan 2001 14:42:17 -0600 (CST) Original-Received: from epithumia.math.uh.edu (IDENT:root@epithumia.math.uh.edu [129.7.128.2]) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id OAA20781 for ; Wed, 3 Jan 2001 14:42:10 -0600 (CST) Original-Received: (from tibbs@localhost) by epithumia.math.uh.edu (8.9.3/8.9.3) id OAA25853 for ding@hpc.uh.edu; Wed, 3 Jan 2001 14:42:35 -0600 Original-Received: from mailhost.sclp.com (postfix@66-209.196.61.interliant.com [209.196.61.66] (may be forged)) by sina.hpc.uh.edu (8.9.3/8.9.3) with ESMTP id NAA19999 for ; Wed, 3 Jan 2001 13:42:59 -0600 (CST) Original-Received: from newjersey.ppllc.com (unknown [209.208.206.221]) by mailhost.sclp.com (Postfix) with ESMTP id E9174D049F for ; Wed, 3 Jan 2001 13:42:28 -0500 (EST) Original-Received: (from colman@localhost) by newjersey.ppllc.com (8.9.3/8.9.3) id NAA20080; Wed, 3 Jan 2001 13:42:28 -0500 (EST) X-Authentication-Warning: newjersey.ppllc.com: colman set sender to colman@ppllc.com using -f X-Draft-From: ("nnimap+truman:INBOX/Emacs/Ding" "") Original-To: ding@gnus.org User-Agent: Gnus/5.090001 (Oort Gnus v0.01) XEmacs/21.1 (Channel Islands) Precedence: list X-Majordomo: 1.94.jlt7 Original-Lines: 66 Xref: main.gmane.org gmane.emacs.gnus.general:34031 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:34031 In a previous post on this list, Christoph Conrad discusses a problem with nntp-open-network-stream with respect to hangs when a connection problem occurs. He resolved the problem with with the following piece of advice: (defadvice open-network-stream ( before nntp-open-network-stream-resolve act ) (when (not (string-match "[0-9.]+" (ad-get-arg 2))) (ad-set-arg 2 (cc-resolve-address nntp-address)))) The function cc-resolve-address converts a host name to a host IP address using nslookup. Since I see the same problem quite regularly when connecting to my imap server, I attempted the following piece of advice: (defadvice nnimap-open-connection (before nnimap-open-connection-resolve act) (when (not (string-match "[0-9.]+" (ad-get-arg 0))) (ad-set-arg 0 (cc-resolve-address nnimap-address)))) When I do this, I end up crashing because nnimap-server-buffer is nil in nnimap-open-server. Can someone (Simon?) help me figure out how to do this? Basically, I want to transparently replace the imap host name with the imap IP address so that the actual connection is done via the address. For completeness sake, here is the cc-resolve-address function: (defun cc-resolve-address( domain ) "Helper function for advised open-network-stream function" (save-excursion (let ((output-buf (generate-new-buffer " *resolve-address*"))) (unwind-protect (progn (set-buffer output-buf) (and (eq (call-process "/usr/sbin/nslookup" nil output-buf nil "-retries=1" domain) 0) (> (point-max) 2) (goto-char (point-max)) (when (re-search-backward (concat "^Name: [ ]*" domain "\n" "Address: [ ]*\\(.*\\)$") nil t) (match-string 1)))) ;; unwind-protect cleanup (kill-buffer output-buf))))) TIA! -- Jake Colman Principia Partners LLC Phone: (201) 946-0300 Harborside Financial Center Fax: (201) 946-0320 902 Plaza II Beeper: (800) 928-4640 Jersey City, NJ 07311 E-mail: colman@ppllc.com E-mail: jcolman@jnc.com web: http://www.ppllc.com microsoft: "where do you want to go today?" linux: "where do you want to go tomorrow?" BSD: "are you guys coming, or what?"