Index: ChangeLog
===================================================================
RCS file: /cvsroot/apps/nomail/ChangeLog,v
retrieving revision 1.1.1.1
retrieving revision 1.3
diff -u -r1.1.1.1 -r1.3
--- ChangeLog	2002/01/15 07:43:46	1.1.1.1
+++ ChangeLog	2002/01/15 08:26:18	1.3
@@ -1,3 +1,13 @@
+2002-01-15  YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
+
+	* nosend: $VERSION = "0.4.10-v6"
+	IPv6 support.
+	To use this feature, you need Socket6 package.
+
+	Introduced -c option to specify configuration file.
+	Introduced -p option and smtpport to specify remote SMTP 
+	port.
+
 2000-12-15  Masahito Ohtsuka  <negi@KU3G.org>
 
 	* nosend: $VERSION = "0.4.10"
Index: README
===================================================================
RCS file: /cvsroot/apps/nomail/README,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- README	2002/01/15 07:43:46	1.1.1.1
+++ README	2002/01/15 07:50:44	1.2
@@ -59,6 +59,9 @@
   てください。（多くの Linux ディストリビューションは最初からイ
   ンストールされています）
 
+  IPv6を用いた配送には、Socket6パッケージが必要です。お近くの
+  CPANサイトから入手可能です。
+
 
 o 使い方
 
Index: nomail.8
===================================================================
RCS file: /cvsroot/apps/nomail/nomail.8,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- nomail.8	2002/01/15 07:43:46	1.1.1.1
+++ nomail.8	2002/01/15 07:56:43	1.2
@@ -66,6 +66,10 @@
 .BI smtphost
 プロバイダの SMTP ホストを指定します。
 .TP
+.BI smtpport
+プロバイダの SMTP ポート番号を指定します。特殊用途のために用意
+されているもので、通常、変更する必要はありません。
+.TP
 .BI rewriteaddr
 インターネットにメールを出す時に From: のメールアドレスを
 .B internetaddr
Index: nomail.conf
===================================================================
RCS file: /cvsroot/apps/nomail/nomail.conf,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- nomail.conf	2002/01/15 07:43:46	1.1.1.1
+++ nomail.conf	2002/01/15 07:56:43	1.2
@@ -12,6 +12,9 @@
 # プロバイダの SMTP ホスト（必須）
 smtphost	smtp.provider.ne.jp
 
+# プロバイダの SMTP ポート（通常変更不要）
+#smtpport	25
+
 # インターネットにメールを出す時にヘッダのアドレスを書換える
 #rewriteaddr	yes
 
Index: nosend
===================================================================
RCS file: /cvsroot/apps/nomail/nosend,v
retrieving revision 1.1.1.1
retrieving revision 1.5
diff -u -r1.1.1.1 -r1.5
--- nosend	2002/01/15 07:43:46	1.1.1.1
+++ nosend	2002/04/11 09:48:13	1.5
@@ -5,19 +5,25 @@
 #
 # Copyright(C) 2000, Masahito Ohtsuka <negi@KU3G.org>,
 # Created 2000. All rights reserved.
+# 
+# IPv6 support by YOSHIFUJI Hideaki / USAGI Project
+# Copyright (C)2002 USAGI/WIDE Project.
 #
 # $Id: nosend,v 1.13 2000/12/14 16:34:59 negi Exp $
 
 use Getopt::Std;
 use Fcntl ':flock';
 use Socket;
+eval "use Socket6";
 use Sys::Hostname;
 
-$VERSION = "0.4.10";
+$VERSION = "0.4.10-v6";
 $CODENAME = "Caravanserai";
 $CONF_FILE = "/etc/nomail.conf";
 $MAILQ = "/var/nomail/";
 $OPTION{timeout} = 40;
+$OPTION{smtpport} = 25;
+$OPTION{inet6} = defined(&getaddrinfo);
 
 # split @mail_data to @header and @body
 sub split_mail_data{
@@ -92,16 +98,43 @@
 
 #
 sub chat_smtp{
+    my $family;
+
     local $SIG{ALRM} = sub { die "Connection Timeout\n" };
     alarm $OPTION{timeout};
-    socket(S, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
-    my $addr = inet_aton($OPTION{smtphost})
-	or die "$OPTION{smtphost} ... Unknown Host\n";
-    my $ent = sockaddr_in(25, $addr);
-    print STDERR "Connect to $OPTION{smtphost} ... ";
-    connect(S, $ent) or die "Can't connect\n";
-    print STDERR "Ok!\n";
+
+    if ($OPTION{inet6}) {
+	my @res = getaddrinfo($OPTION{smtphost}, $OPTION{smtpport}, AF_UNSPEC, SOCK_STREAM);
+	unless (@res) {
+	    die "$OPTION{smtphost} port $OPTION{smtpport} ... Unknown host or port\n";
+	}
+
+	my ($socktype,$proto,$saddr,$cname,$host,$port);
+	$family = -1;
+
+	while(scalar(@res) >= 5) {
+	    ($family,$socktype,$proto,$saddr,$cname, @res) = @res;
+	    ($host, $port) = getnameinfo($saddr, NI_NUMERICHOST | NI_NUMERICSERV);
+	    socket(S, $family,$socktype,$proto) or next;
+	    print STDERR "Connect to $host port $port ... ";
+	    connect(S, $saddr) and last;
+	    close(S);
+	    $family = -1;
+	}
+    } else {
+	$family = PF_INET;
+	socket(S, $family, SOCK_STREAM, getprotobyname('tcp'));
+ 	my $addr = inet_aton($OPTION{smtphost})
+	    or die "$OPTION{smtphost} ... Unknown Host\n";
+	my $ent = sockaddr_in($OPTION{smtpport}, $addr);
+	print STDERR "Connect to $OPTION{smtphost} ... ";
+	connect(S, $ent) or $family = -1;
+    }
     alarm 0;
+    if ($family == -1) {
+	die "Can't connect\n";
+    }
+    print STDERR "Ok!\n";   
     select(S); $| = 1;
     while (<S>) {
 	last if /^220\ .*\r\n/;
@@ -155,18 +188,22 @@
 #
 # MAIN
 #
-getopts('f:s:rmh');
+getopts('c:f:s:p:rmh');
 if($opt_h){
     select STDERR;
     print "Usage: nosend [OPTION]\n";
+    print "\t-c\tconfiguration file\n";
     print "\t-f\toverride internetaddr\n";
     print "\t-s\toverride smtphost\n";
+    print "\t-p\toverride smtpport\n";
     print "\t-r\trewriteaddr is 'yes'\n";
     print "\t-m\tinvalid_msgid is 'yes'\n";
     print "\t-h\tprint this message\n";
     exit;
 }
 
+$CONF_FILE = $opt_c if $opt_c;
+
 if(open(CONF, $CONF_FILE)){
     while(<CONF>){
 	chomp;
@@ -180,11 +217,13 @@
 
 $OPTION{internetaddr} = $opt_f if $opt_f;
 $OPTION{smtphost} = $opt_s if $opt_s;
+$OPTION{smtpport} = $opt_p if $opt_p;
 $OPTION{rewriteaddr} = "yes" if $opt_r;
 $OPTION{invalid_msgid} = "yes" if $opt_m;
 
 die "internetaddr is not set\n" unless($OPTION{internetaddr});
 die "smtphost is not set\n" unless($OPTION{smtphost});
+die "smtpport is not set\n" unless($OPTION{smtpport});
 opendir(DIR, $MAILQ) or die "$MAILQ: $!\n";
 @files = readdir DIR;
 closedir DIR;
Index: nosend.8
===================================================================
RCS file: /cvsroot/apps/nomail/nosend.8,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- nosend.8	2002/01/15 07:43:46	1.1.1.1
+++ nosend.8	2002/01/15 07:56:43	1.2
@@ -13,11 +13,17 @@
 ておくと便利でしょう。
 .SH オプション
 .TP
+.BI -c
+読み込む設定ファイルをデフォルトから変更します。
+.TP
 .BI -f
 internetaddr を上書きします。
 .TP
 .BI -s
 smtphost を上書きします。
+.TP
+.BI -p
+smtpport を上書きします。
 .TP
 .BI -r
 rewriteaddr を有効にします。
