develooper Front page | perl.cvs.qpsmtpd | Postings from February 2007

[svn:qpsmtpd] r716 - contrib/hjp/config_me_localaddr

From:
hjp
Date:
February 25, 2007 12:03
Subject:
[svn:qpsmtpd] r716 - contrib/hjp/config_me_localaddr
Message ID:
20070225210348.D69F5CBA1B@x12.develooper.com
Author: hjp
Date: Sun Feb 25 13:03:48 2007
New Revision: 716

Added:
   contrib/hjp/config_me_localaddr/
   contrib/hjp/config_me_localaddr/Makefile
   contrib/hjp/config_me_localaddr/Makerules
   contrib/hjp/config_me_localaddr/config_me_localaddr
   contrib/hjp/config_me_localaddr/qpsmtpd-plugin-config_me_localaddr.spec

Log:
Added config_me_localaddr, a plugin to use the local address of the
current connection to determine the local hostname ("me")


Added: contrib/hjp/config_me_localaddr/Makefile
==============================================================================
--- (empty file)
+++ contrib/hjp/config_me_localaddr/Makefile	Sun Feb 25 13:03:48 2007
@@ -0,0 +1,12 @@
+NAME=config_me_localaddr
+FILES = $(PKG).spec \
+    Makefile \
+    Makerules \
+    config_me_localaddr \
+
+all:
+
+clean:
+	rm -f $(PKG).tar.gz *.tmp
+
+include Makerules

Added: contrib/hjp/config_me_localaddr/Makerules
==============================================================================
--- (empty file)
+++ contrib/hjp/config_me_localaddr/Makerules	Sun Feb 25 13:03:48 2007
@@ -0,0 +1,15 @@
+PKG = qpsmtpd-plugin-$(NAME)
+CONTRIB_BASE=~/wrk/qpsmtpd/contrib/hjp
+CONTRIB_FILES=$(patsubst %, $(CONTRIB_BASE)/$(NAME)/%, $(FILES))
+
+contrib: $(CONTRIB_FILES)
+
+$(CONTRIB_BASE)/$(NAME)/%: %
+	cp -p $^ $@
+
+rpm: $(PKG).tar.gz
+	rpmbuild -ta --clean --sign --rmsource $^
+
+$(PKG).tar.gz: $(FILES)
+	tar cfz $@ $^
+

Added: contrib/hjp/config_me_localaddr/config_me_localaddr
==============================================================================
--- (empty file)
+++ contrib/hjp/config_me_localaddr/config_me_localaddr	Sun Feb 25 13:03:48 2007
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+=head1 NAME
+
+config_me_localaddr
+
+=head1 DESCRIPTION
+
+Use the local address of the current connection to determine the local hostname ("me").
+
+=head1 CONFIG
+
+Nothing to configure. Just load the plugin.
+
+=head1 BUGS
+
+None known.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2006 Peter J. Holzer
+
+This plugin is licensed under the same terms as the qpsmtpd package
+itself.
+Please see the LICENSE file included with qpsmtpd for details.
+
+=cut
+use warnings;
+use strict;
+use Socket;
+
+sub hook_config {
+    my ($self, $transaction, $config) = @_; 
+    $self->log(LOGINFO, "config_me_localaddr called with $config");
+    return DECLINED unless $config eq 'me';
+    my $local_ip;
+    unless ($self->connection && $self->connection->local_ip) {
+	$self->log(LOGNOTICE, "cannot determnine locak IP address of connection");
+	return DECLINED;
+    }
+    $local_ip =  $self->connection->local_ip;
+    my $local_name = gethostbyaddr(inet_aton($local_ip), AF_INET);
+    $self->log(LOGINFO, "local name is $local_name");
+    return (OK, $local_name);
+}

Added: contrib/hjp/config_me_localaddr/qpsmtpd-plugin-config_me_localaddr.spec
==============================================================================
--- (empty file)
+++ contrib/hjp/config_me_localaddr/qpsmtpd-plugin-config_me_localaddr.spec	Sun Feb 25 13:03:48 2007
@@ -0,0 +1,40 @@
+Name: qpsmtpd-plugin-config_me_localaddr
+Version: 232
+Release: 1
+Packager: hjp@hjp.at
+Summary: plugin to determine local hostname from connection
+License: distributable
+Group: System Environment/Daemons
+URL: http://smtpd.develooper.com/
+BuildRoot: %{_tmppath}/%{name}-root
+Source0: %{name}.tar.gz
+BuildArch: noarch
+
+%description
+This plugin uses the local address of the current connection to
+determine the local hostname ("me").
+
+%prep
+%setup -q -c %{name}
+
+%build
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/usr/share/qpsmtpd/plugins
+cp config_me_localaddr* $RPM_BUILD_ROOT/usr/share/qpsmtpd/plugins
+
+[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress
+
+
+%files
+%defattr(-,root,root)
+/usr/share/qpsmtpd/plugins/config_me_localaddr
+
+%changelog
+* Fri Oct 27 2006 <hjp@hjp.at> 232-1
+- First RPM package.
+



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About