Update to 0.44 with some patches from CVS.

Notable changes to the port:
- creates opennap user/group to run as
- tons of bugfixes, improved performance
- no longer hardcodes SYSCONFDIR to /etc/opennap

Submitted by Jolan Luff <jolan@pellaeon.com>.
This commit is contained in:
naddy 2002-08-10 01:14:04 +00:00
parent 66b2a1ee27
commit c208dc5df3
29 changed files with 1578 additions and 32 deletions

View File

@ -1,25 +1,31 @@
# $OpenBSD: Makefile,v 1.7 2002/07/30 14:36:49 brad Exp $
# $OpenBSD: Makefile,v 1.8 2002/08/10 01:14:04 naddy Exp $
COMMENT= "opensource Napster(tm) server"
DISTNAME= opennap-0.42
DISTNAME= opennap-0.44
CATEGORIES= audio net
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=opennap/}
HOMEPAGE= http://opennap.sourceforge.net/
MAINTAINER= Jolan Luff <jolan@cryptonomicon.org>
# GPL
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
SYSCONFDIR= /etc/opennap
SEPARATE_BUILD= concurrent
USE_GMAKE= Yes
CONFIGURE_STYLE= gnu
CONFIGURE_ARGS= --enable-resume
CONFIGURE_STYLE=gnu
CONFIGURE_ARGS= \
--enable-email \
--enable-resume \
--datadir=${SYSCONFDIR}
# --enable-chroot \ (breaks uid, gid, and ip lookup
DOCS= README napster.txt
DOCS= FAQ README manual.html napster.txt
post-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/opennap

View File

@ -1,3 +1,3 @@
MD5 (opennap-0.42.tar.gz) = fdea358b1beddec752d5515e1b53c823
RMD160 (opennap-0.42.tar.gz) = 927a283fd458dcfd117e77cac021e52bf42a1639
SHA1 (opennap-0.42.tar.gz) = cdc500f1a57c3efa94280971d335e869fe535ae9
MD5 (opennap-0.44.tar.gz) = 1dcce1826283888111fb9fbe0684f6f2
RMD160 (opennap-0.44.tar.gz) = af54ffb3b2183fe4858ec4548bdaeb177e566c79
SHA1 (opennap-0.44.tar.gz) = 2abd38d440087913bd711aa5a2eb54d0ec423501

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-FAQ,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- FAQ.orig Thu Mar 8 17:55:02 2001
+++ FAQ Tue Oct 16 23:02:47 2001
@@ -42,6 +42,16 @@ A: Find the people who run the server y
with them. If both parties agree you exchange a password and follow
the directions in the README for linking up.
+Q: What is a metaserver? Do I need to run one?
+A: A metaserver is a small server that attempts to provide load balancing
+ to a cluster of linked OpenNap servers. You give it a list of all the
+ servers in your cluster, and it will cycle through the list each time
+ a connection is made. Originally, the Napster client would connect to
+ the metaserver to find out which Napster server to connect to.
+ However, most clients these days just have support for a list of
+ servers to connect directly to, totally ignoring the metaserver.
+ Hence, running a metaserver is NOT required.
+
* Configuration - Win32
Q: How do I get more than 256 connections under Windows?

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-Makefile_am,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- Makefile.am.orig Tue Sep 25 23:59:56 2001
+++ Makefile.am Tue Oct 16 18:14:04 2001
@@ -1,5 +1,5 @@
-sbin_PROGRAMS=opennap metaserver setup #mkpass
-opennap_SOURCES=opennap.h main.c add_file.c search.c \
+sbin_PROGRAMS=opennap metaserver setup
+opennap_SOURCES=opennap.h main.c add_file.c discipline.c search.c \
motd.c hash.h hash.c privmsg.c browse.c \
debug.c debug.h login.c whois.c free_user.c \
join.c part.c public.c part_channel.c \
@@ -14,17 +14,16 @@ opennap_SOURCES=opennap.h main.c add_fil
napigator.c win32-support.h #fast_snprintf.c
opennap_LDADD=$(REGEX)
opennap_DEPENDENCIES=$(REGEX)
-#mkpass_SOURCES=mkpass.c md5.c debug.c util.c
metaserver_SOURCES=metaserver.c
setup_SOURCES=setup.c
EXTRA_opennap_SOURCES=regex.c _regex.h
EXTRA_DIST=sample.config sample.motd napster.txt .indent.pro \
FAQ spyserv.c opennap.dsw opennap.dsp \
opennap.opt sample.users sample.servers opennap.spec \
- getopt.c mkpass.dsp sample.channels \
- napchk logchk setup.dsp opennap.init sample.filter mkpass.c \
+ getopt.c sample.channels \
+ napchk logchk setup.dsp opennap.init sample.filter \
manual.html start_opennap sample.block win98se_max_conn.reg \
- notes.txt sample.block
+ notes.txt sample.block metaserver.dsp
INCLUDES=-DSHAREDIR=\"@SHAREDIR@\"
.PHONY: log

View File

@ -0,0 +1,261 @@
$OpenBSD: patch-Makefile_in,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- Makefile.in.orig Sun Sep 30 17:13:45 2001
+++ Makefile.in Tue Oct 16 18:14:04 2001
@@ -65,16 +65,15 @@ REGEX = @REGEX@
SHAREDIR = @SHAREDIR@
VERSION = @VERSION@
-sbin_PROGRAMS = opennap metaserver setup #mkpass
-opennap_SOURCES = opennap.h main.c add_file.c search.c motd.c hash.h hash.c privmsg.c browse.c debug.c debug.h login.c whois.c free_user.c join.c part.c public.c part_channel.c announce.c kill_user.c remove_connection.c config.c download.c upload_complete.c topic.c muzzle.c level.c client_quit.c server_login.c server_connect.c synch.c util.c md5.c md5.h hotlist.c remove_file.c list_channels.c list_users.c ping.c resume.c change.c ban.c network.c buffer.c server_usage.c server_links.c init.c handler.c timer.c list.c list.h userdb.c serverlib.c kick.c usermode.c channel.c glob.c redirect.c filter.c hashlist.h hashlist.c class.c napigator.c win32-support.h #fast_snprintf.c
+sbin_PROGRAMS = opennap metaserver setup
+opennap_SOURCES = opennap.h main.c add_file.c discipline.c search.c motd.c hash.h hash.c privmsg.c browse.c debug.c debug.h login.c whois.c free_user.c join.c part.c public.c part_channel.c announce.c kill_user.c remove_connection.c config.c download.c upload_complete.c topic.c muzzle.c level.c client_quit.c server_login.c server_connect.c synch.c util.c md5.c md5.h hotlist.c remove_file.c list_channels.c list_users.c ping.c resume.c change.c ban.c network.c buffer.c server_usage.c server_links.c init.c handler.c timer.c list.c list.h userdb.c serverlib.c kick.c usermode.c channel.c glob.c redirect.c filter.c hashlist.h hashlist.c class.c napigator.c win32-support.h #fast_snprintf.c
opennap_LDADD = $(REGEX)
opennap_DEPENDENCIES = $(REGEX)
-#mkpass_SOURCES=mkpass.c md5.c debug.c util.c
metaserver_SOURCES = metaserver.c
setup_SOURCES = setup.c
EXTRA_opennap_SOURCES = regex.c _regex.h
-EXTRA_DIST = sample.config sample.motd napster.txt .indent.pro FAQ spyserv.c opennap.dsw opennap.dsp opennap.opt sample.users sample.servers opennap.spec getopt.c mkpass.dsp sample.channels napchk logchk setup.dsp opennap.init sample.filter mkpass.c manual.html start_opennap sample.block win98se_max_conn.reg notes.txt sample.block
+EXTRA_DIST = sample.config sample.motd napster.txt .indent.pro FAQ spyserv.c opennap.dsw opennap.dsp opennap.opt sample.users sample.servers opennap.spec getopt.c sample.channels napchk logchk setup.dsp opennap.init sample.filter manual.html start_opennap sample.block win98se_max_conn.reg notes.txt sample.block metaserver.dsp
INCLUDES = -DSHAREDIR=\"@SHAREDIR@\"
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -88,15 +87,15 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I.
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
-opennap_OBJECTS = main.o add_file.o search.o motd.o hash.o privmsg.o \
-browse.o debug.o login.o whois.o free_user.o join.o part.o public.o \
-part_channel.o announce.o kill_user.o remove_connection.o config.o \
-download.o upload_complete.o topic.o muzzle.o level.o client_quit.o \
-server_login.o server_connect.o synch.o util.o md5.o hotlist.o \
-remove_file.o list_channels.o list_users.o ping.o resume.o change.o \
-ban.o network.o buffer.o server_usage.o server_links.o init.o handler.o \
-timer.o list.o userdb.o serverlib.o kick.o usermode.o channel.o glob.o \
-redirect.o filter.o hashlist.o class.o napigator.o
+opennap_OBJECTS = main.o add_file.o discipline.o search.o motd.o hash.o \
+privmsg.o browse.o debug.o login.o whois.o free_user.o join.o part.o \
+public.o part_channel.o announce.o kill_user.o remove_connection.o \
+config.o download.o upload_complete.o topic.o muzzle.o level.o \
+client_quit.o server_login.o server_connect.o synch.o util.o md5.o \
+hotlist.o remove_file.o list_channels.o list_users.o ping.o resume.o \
+change.o ban.o network.o buffer.o server_usage.o server_links.o init.o \
+handler.o timer.o list.o userdb.o serverlib.o kick.o usermode.o \
+channel.o glob.o redirect.o filter.o hashlist.o class.o napigator.o
opennap_LDFLAGS =
metaserver_OBJECTS = metaserver.o
metaserver_LDADD = $(LDADD)
@@ -119,6 +118,23 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(
TAR = tar
GZIP_ENV = --best
+DEP_FILES = .deps/add_file.P .deps/announce.P .deps/ban.P \
+.deps/browse.P .deps/buffer.P .deps/change.P .deps/channel.P \
+.deps/class.P .deps/client_quit.P .deps/config.P .deps/debug.P \
+.deps/discipline.P .deps/download.P .deps/filter.P .deps/free_user.P \
+.deps/glob.P .deps/handler.P .deps/hash.P .deps/hashlist.P \
+.deps/hotlist.P .deps/init.P .deps/join.P .deps/kick.P \
+.deps/kill_user.P .deps/level.P .deps/list.P .deps/list_channels.P \
+.deps/list_users.P .deps/login.P .deps/main.P .deps/md5.P \
+.deps/metaserver.P .deps/motd.P .deps/muzzle.P .deps/napigator.P \
+.deps/network.P .deps/part.P .deps/part_channel.P .deps/ping.P \
+.deps/privmsg.P .deps/public.P .deps/redirect.P .deps/regex.P \
+.deps/remove_connection.P .deps/remove_file.P .deps/resume.P \
+.deps/search.P .deps/server_connect.P .deps/server_links.P \
+.deps/server_login.P .deps/server_usage.P .deps/serverlib.P \
+.deps/setup.P .deps/synch.P .deps/timer.P .deps/topic.P \
+.deps/upload_complete.P .deps/userdb.P .deps/usermode.P .deps/util.P \
+.deps/whois.P
SOURCES = $(opennap_SOURCES) $(EXTRA_opennap_SOURCES) $(metaserver_SOURCES) $(setup_SOURCES)
OBJECTS = $(opennap_OBJECTS) $(metaserver_OBJECTS) $(setup_OBJECTS)
@@ -126,9 +142,9 @@ all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
+ cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
@@ -193,9 +209,6 @@ uninstall-sbinPROGRAMS:
rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
done
-.c.o:
- $(COMPILE) -c $<
-
.s.o:
$(COMPILE) -c $<
@@ -291,6 +304,11 @@ distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
+ here=`cd $(top_builddir) && pwd`; \
+ top_distdir=`cd $(distdir) && pwd`; \
+ distdir=`cd $(distdir) && pwd`; \
+ cd $(top_srcdir) \
+ && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
@@ -301,74 +319,38 @@ distdir: $(DISTFILES)
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
-add_file.o: add_file.c config.h opennap.h hash.h list.h debug.h
-announce.o: announce.c config.h opennap.h hash.h list.h debug.h
-ban.o: ban.c config.h opennap.h hash.h list.h debug.h
-browse.o: browse.c config.h opennap.h hash.h list.h debug.h
-buffer.o: buffer.c config.h opennap.h hash.h list.h debug.h
-change.o: change.c config.h opennap.h hash.h list.h debug.h
-channel.o: channel.c config.h opennap.h hash.h list.h debug.h
-class.o: class.c config.h opennap.h hash.h list.h hashlist.h debug.h
-client_quit.o: client_quit.c opennap.h hash.h list.h debug.h
-config.o: config.c config.h opennap.h hash.h list.h debug.h
-debug.o: debug.c config.h debug.h
-download.o: download.c config.h opennap.h hash.h list.h debug.h
-filter.o: filter.c config.h opennap.h hash.h list.h debug.h
-free_user.o: free_user.c config.h opennap.h hash.h list.h hashlist.h \
- debug.h
-glob.o: glob.c config.h opennap.h hash.h list.h
-handler.o: handler.c config.h opennap.h hash.h list.h debug.h
-hash.o: hash.c config.h hash.h debug.h
-hashlist.o: hashlist.c config.h list.h hash.h hashlist.h opennap.h \
- debug.h
-hotlist.o: hotlist.c config.h opennap.h hash.h list.h hashlist.h debug.h
-init.o: init.c config.h opennap.h hash.h list.h hashlist.h debug.h
-join.o: join.c config.h opennap.h hash.h list.h debug.h
-kick.o: kick.c config.h opennap.h hash.h list.h debug.h
-kill_user.o: kill_user.c config.h opennap.h hash.h list.h debug.h
-level.o: level.c config.h opennap.h hash.h list.h debug.h
-list.o: list.c config.h list.h debug.h
-list_channels.o: list_channels.c config.h opennap.h hash.h list.h \
- debug.h
-list_users.o: list_users.c config.h opennap.h hash.h list.h debug.h
-login.o: login.c config.h opennap.h hash.h list.h hashlist.h debug.h
-main.o: main.c config.h opennap.h hash.h list.h debug.h
-md5.o: md5.c config.h md5.h
-metaserver.o: metaserver.c config.h
-motd.o: motd.c config.h opennap.h hash.h list.h debug.h
-muzzle.o: muzzle.c config.h opennap.h hash.h list.h debug.h
-napigator.o: napigator.c config.h opennap.h hash.h list.h debug.h md5.h
-network.o: network.c config.h opennap.h hash.h list.h debug.h
-part.o: part.c config.h opennap.h hash.h list.h debug.h
-part_channel.o: part_channel.c config.h opennap.h hash.h list.h debug.h
-ping.o: ping.c config.h opennap.h hash.h list.h debug.h
-privmsg.o: privmsg.c config.h opennap.h hash.h list.h debug.h
-public.o: public.c config.h opennap.h hash.h list.h debug.h
-redirect.o: redirect.c config.h opennap.h hash.h list.h
-remove_connection.o: remove_connection.c config.h opennap.h hash.h \
- list.h hashlist.h debug.h
-remove_file.o: remove_file.c config.h opennap.h hash.h list.h debug.h
-resume.o: resume.c config.h opennap.h hash.h list.h debug.h
-search.o: search.c config.h opennap.h hash.h list.h debug.h
-server_connect.o: server_connect.c config.h opennap.h hash.h list.h \
- debug.h
-server_links.o: server_links.c config.h opennap.h hash.h list.h debug.h
-server_login.o: server_login.c config.h opennap.h hash.h list.h debug.h \
- md5.h
-server_usage.o: server_usage.c config.h opennap.h hash.h list.h \
- hashlist.h debug.h
-serverlib.o: serverlib.c config.h opennap.h hash.h list.h debug.h
-setup.o: setup.c config.h
-synch.o: synch.c config.h opennap.h hash.h list.h debug.h
-timer.o: timer.c config.h opennap.h hash.h list.h debug.h
-topic.o: topic.c config.h opennap.h hash.h list.h debug.h
-upload_complete.o: upload_complete.c config.h opennap.h hash.h list.h \
- debug.h
-userdb.o: userdb.c config.h opennap.h hash.h list.h debug.h
-usermode.o: usermode.c config.h opennap.h hash.h list.h debug.h
-util.o: util.c config.h md5.h opennap.h hash.h list.h debug.h
-whois.o: whois.c config.h opennap.h hash.h list.h debug.h
+DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
+
+-include $(DEP_FILES)
+
+mostlyclean-depend:
+
+clean-depend:
+
+distclean-depend:
+ -rm -rf .deps
+
+maintainer-clean-depend:
+
+%.o: %.c
+ @echo '$(COMPILE) -c $<'; \
+ $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-cp .deps/$(*F).pp .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm .deps/$(*F).pp
+
+%.lo: %.c
+ @echo '$(LTCOMPILE) -c $<'; \
+ $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
+ @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
+ < .deps/$(*F).pp > .deps/$(*F).P; \
+ tr ' ' '\012' < .deps/$(*F).pp \
+ | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+ >> .deps/$(*F).P; \
+ rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
@@ -409,25 +391,27 @@ distclean-generic:
maintainer-clean-generic:
mostlyclean-am: mostlyclean-hdr mostlyclean-sbinPROGRAMS \
- mostlyclean-compile mostlyclean-tags \
+ mostlyclean-compile mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-hdr clean-sbinPROGRAMS clean-compile clean-tags \
- clean-generic mostlyclean-am
+ clean-depend clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-hdr distclean-sbinPROGRAMS distclean-compile \
- distclean-tags distclean-generic clean-am
+ distclean-tags distclean-depend distclean-generic \
+ clean-am
distclean: distclean-am
-rm -f config.status
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-sbinPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
- maintainer-clean-generic distclean-am
+ maintainer-clean-depend maintainer-clean-generic \
+ distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
@@ -439,10 +423,12 @@ mostlyclean-sbinPROGRAMS distclean-sbinP
maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
install-sbinPROGRAMS mostlyclean-compile distclean-compile \
clean-compile maintainer-clean-compile tags mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
-dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
-install-exec-am install-exec install-data-am install-data install-am \
-install uninstall-am uninstall all-redirect all-am all installdirs \
+distclean-tags clean-tags maintainer-clean-tags distdir \
+mostlyclean-depend distclean-depend clean-depend \
+maintainer-clean-depend info-am info dvi-am dvi check check-am \
+installcheck-am installcheck all-recursive-am install-exec-am \
+install-exec install-data-am install-data install-am install \
+uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean

View File

@ -0,0 +1,134 @@
$OpenBSD: patch-add_file_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- add_file.c.orig Sat Sep 29 00:21:51 2001
+++ add_file.c Wed Oct 17 13:19:27 2001
@@ -233,6 +233,7 @@ sNewDatum (char *filename, char *hash)
FREE (info);
return 0;
}
+ strlower (info->hash);
#endif
return info;
}
@@ -248,8 +249,8 @@ sBitrateToMask (int bitrate, USER * user
if (bitrate <= BitRate[i])
return i;
}
- log_message ("sBitrateToMask(): invalid bit rate %d (%s, \"%s\")", bitrate,
- user->nick, user->clientinfo);
+ log_message ("sBitrateToMask(): invalid bit rate %d (%s, \"%s\")",
+ bitrate, user->nick, user->clientinfo);
return 0; /* invalid bitrate */
}
@@ -287,6 +288,8 @@ HANDLER (add_file)
if (!option (ON_ALLOW_SHARE))
return;
+ if(con->user->level==LEVEL_LEECH)
+ return;
if (Max_Shared && con->user->shared >= Max_Shared)
{
@@ -376,6 +379,8 @@ HANDLER (share_file)
if (!option (ON_ALLOW_SHARE))
return;
+ if(con->user->level==LEVEL_LEECH)
+ return;
if (Max_Shared && con->user->shared >= Max_Shared)
{
log_message ("add_file(): %s is already sharing %d files",
@@ -466,6 +471,8 @@ HANDLER (add_directory)
CHECK_USER_CLASS ("add_directory");
if (!option (ON_ALLOW_SHARE))
return;
+ if(con->user->level==LEVEL_LEECH)
+ return;
dir = next_arg (&pkt); /* directory */
if (!dir)
{
@@ -653,8 +660,40 @@ HANDLER (user_sharing)
user->libsize);
}
+void
+unshare_all_internal (USER * user)
+{
+ if (user->shared)
+ {
+#ifndef ROUTING_ONLY
+ if (ISUSER (user->con))
+ {
+ /* local user */
+ free_hash (user->con->uopt->files);
+ user->con->uopt->files = 0;
+ ASSERT (Local_Files >= user->shared);
+ Local_Files -= user->shared;
+ }
+#endif /* !ROUTING_ONLY */
+ if (user->libsize > Num_Gigs)
+ {
+ log_message ("unshare_all: sender->libsize=%u Num_Gigs=%f",
+ user->libsize, Num_Gigs);
+ Num_Gigs = user->libsize;
+ }
+ ASSERT (Num_Gigs >= user->libsize);
+ Num_Gigs -= user->libsize;
+ ASSERT (Num_Files >= user->shared);
+ Num_Files -= user->shared;
+ user->libsize = 0;
+ user->shared = 0;
+ }
+}
+
/* 110 [:sender]
- * unshare all files
+ * unshare all files. this will handle the case of a remote server forcing
+ * a local client to unshare all files as well, so we can have the hub
+ * perform this action.
*/
HANDLER (unshare_all)
{
@@ -664,33 +703,18 @@ HANDLER (unshare_all)
(void) len;
if (pop_user_server (con, tag, &pkt, &sender_name, &sender))
return;
- ASSERT (sender != 0);
-#ifndef ROUTING_ONLY
+ if (!sender)
+ {
+ log_message ("unshare_all: error: received unshare message from server %s",
+ sender_name);
+ return;
+ }
if (ISUSER (con))
{
- if (!con->uopt->files)
- {
- ASSERT (sender->shared == 0);
- return; /* nothing shared */
- }
+ if (sender->shared == 0)
+ return; /* nothing to unshare */
send_cmd (con, tag, "%d", sender->shared);
- free_hash (con->uopt->files);
- con->uopt->files = 0;
- ASSERT (Local_Files >= sender->shared);
- Local_Files -= sender->shared;
}
-#endif /* !ROUTING_ONLY */
- if (sender->libsize > Num_Gigs)
- {
- log_message ("unshare_all: sender->libsize=%u Num_Gigs=%f",
- sender->libsize, Num_Gigs);
- Num_Gigs = sender->libsize;
- }
- ASSERT (Num_Gigs >= sender->libsize);
- Num_Gigs -= sender->libsize;
- ASSERT (Num_Files >= sender->shared);
- Num_Files -= sender->shared;
- sender->libsize = 0;
- sender->shared = 0;
+ unshare_all_internal (sender);
pass_message_args (con, tag, ":%s", sender->nick);
}

View File

@ -0,0 +1,30 @@
$OpenBSD: patch-browse_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- browse.c.orig Sat Sep 22 00:54:13 2001
+++ browse.c Tue Oct 16 18:14:04 2001
@@ -87,6 +87,12 @@ HANDLER (browse)
}
ASSERT (validate_user (user));
+ if (sender->level == LEVEL_LEECH)
+ {
+ send_user (sender, MSG_SERVER_BROWSE_END, "%s 0", nick);
+ return;
+ }
+
if (pkt)
{
result = atoi (pkt);
@@ -349,6 +355,13 @@ HANDLER (browse_direct)
if (!user)
{
nosuchuser (con);
+ return;
+ }
+
+ if (sender->level == LEVEL_LEECH)
+ {
+ send_user(sender,MSG_SERVER_BROWSE_DIRECT_ERR,
+ "%s \"permission denied: you are a leech\"", user->nick);
return;
}

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-channel_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- channel.c.orig Sat Sep 22 00:54:13 2001
+++ channel.c Mon Oct 15 15:18:44 2001
@@ -155,7 +155,7 @@ dump_channels (void)
HANDLER (channel_ban)
{
CHANNEL *chan;
- char *av[2], *sender;
+ char *av[3], *sender;
int ac = -1;
LIST **list, *tmp;
BAN *b = 0;

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-config_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- config.c.orig Sat Sep 22 01:04:26 2001
+++ config.c Tue Oct 16 16:13:02 2001
@@ -65,6 +65,7 @@ static struct config Vars[] = {
#endif
{"auto_link", VAR_TYPE_BOOL, ON_AUTO_LINK, 0, 0},
{"auto_register", VAR_TYPE_BOOL, ON_AUTO_REGISTER, 0, 0},
+ {"block_winmx", VAR_TYPE_INT, UL & gBlockWinMX, 0, 0},
{"client_queue_length", VAR_TYPE_INT, UL & Client_Queue_Length, 102400,
0},
{"compression_level", VAR_TYPE_INT, UL & Compression_Level, 1, CF_ONCE},

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-config_h_in,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- config.h.in.orig Sat Sep 22 02:23:14 2001
+++ config.h.in Tue Oct 16 16:13:03 2001
@@ -24,6 +24,9 @@
/* Define if you have the alarm function. */
#undef HAVE_ALARM
+/* Define if you have the getloadavg function. */
+#undef HAVE_GETLOADAVG
+
/* Define if you have the getopt function. */
#undef HAVE_GETOPT

View File

@ -1,12 +1,30 @@
$OpenBSD: patch-configure,v 1.2 2001/07/11 02:10:06 brad Exp $
--- configure.orig Tue Mar 6 01:49:52 2001
+++ configure Tue Jul 10 21:15:04 2001
@@ -1875,7 +1875,7 @@ EOF
else
rm -rf conftest*
- SHAREDIR=\${pkgdatadir}
+ SHAREDIR=\${sysconfdir}
$OpenBSD: patch-configure,v 1.3 2002/08/10 01:14:04 naddy Exp $
--- configure.orig Sun Sep 30 17:12:46 2001
+++ configure Mon Aug 5 19:59:27 2002
@@ -1802,7 +1802,7 @@ else
echo "$ac_t""no" 1>&6
fi
rm -f conftest*
-for ac_func in mlockall poll
+for ac_func in mlockall poll getloadavg
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1809: checking for $ac_func" >&5
@@ -2003,7 +2003,7 @@ EOF
else
cat >> confdefs.h <<EOF
-#define USE_UID "nobody"
+#define USE_UID "opennap"
EOF
fi
@@ -2017,7 +2017,7 @@ EOF
else
cat >> confdefs.h <<EOF
-#define USE_GID "nobody"
+#define USE_GID "opennap"
EOF
fi

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-configure_in,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- configure.in.orig Sat Sep 29 00:21:51 2001
+++ configure.in Sun Aug 4 00:09:53 2002
@@ -28,7 +28,7 @@ fi
AC_CHECK_LIB(xnet,gethostbyname)
AC_CHECK_LIB(nsl,socket)
AC_CHECK_LIB(socket,gethostbyname)
-AC_CHECK_FUNCS(mlockall poll)
+AC_CHECK_FUNCS(mlockall poll getloadavg)
dnl see if we are compiling under Win32 or Unix
AC_MSG_CHECKING(for default config directory)
@@ -97,9 +97,9 @@ AC_ARG_ENABLE(chroot, [ --enable-chroot
AC_ARG_WITH(uid, [ --with-uid=UID Switch to UID if run as root],
[AC_DEFINE_UNQUOTED(USE_UID,"$withval")],
- [AC_DEFINE_UNQUOTED(USE_UID,"nobody")])
+ [AC_DEFINE_UNQUOTED(USE_UID,"opennap")])
AC_ARG_WITH(gid, [ --with-gid=GID Switch to GID if run as root],
[AC_DEFINE_UNQUOTED(USE_GID,"$withval")],
- [AC_DEFINE_UNQUOTED(USE_GID,"nobody")])
+ [AC_DEFINE_UNQUOTED(USE_GID,"opennap")])
AC_OUTPUT(Makefile)

View File

@ -0,0 +1,75 @@
$OpenBSD: patch-discipline_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- discipline.c.orig Fri Aug 2 22:15:44 2002
+++ discipline.c Wed Oct 17 13:19:27 2001
@@ -0,0 +1,71 @@
+/* discipline.c,v 1.3 2001/10/17 18:19:27 drscholl Exp
+ *
+ * Open Source Napster Server - Peer-To-Peer Indexing/Chat Daemon
+ * Copyright (C) 2001 drscholl@users.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "opennap.h"
+
+#ifndef NULL
+#define NULL ((void*)0)
+#endif
+
+void
+discipline_user (USER * user)
+{
+ USERDB *db;
+
+ if (gBlockWinMX > 1)
+ kill_user_internal (user->con, user, Server_Name, 0, "");
+ else
+ {
+ /* set the user to LEECH */
+
+ if (ISUSER (user->con))
+ {
+ /* remove from local mods+ list */
+ if (user->level > LEVEL_USER)
+ Mods = list_delete (Mods, user->con);
+ }
+
+ /* if the user is sharing any files, remove them now */
+ if (user->shared)
+ {
+ unshare_all_internal (user);
+ pass_message_args (NULL, MSG_CLIENT_UNSHARE_ALL, ":%s",
+ user->nick);
+ }
+
+ user->level = LEVEL_LEECH;
+ if (user->cloaked)
+ {
+ notify_mods (CHANGELOG_MODE, "%s has decloaked", user->nick);
+ user->cloaked = 0;
+ }
+
+ db = hash_lookup (User_Db, user->nick);
+ if (!db)
+ db = create_db (user); /* not registered, force it now */
+ db->level = LEVEL_LEECH;
+
+ notify_mods (LEVELLOG_MODE, "Server %s set %s's level to Leech (0)",
+ Server_Name, user->nick);
+
+ pass_message_args (NULL, MSG_CLIENT_SETUSERLEVEL, ":%s %s Leech",
+ Server_Name, user->nick);
+ }
+}

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-download_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- download.c.orig Sat Sep 22 00:54:13 2001
+++ download.c Tue Oct 16 18:14:04 2001
@@ -35,6 +35,12 @@ HANDLER (download)
return;
}
+ if (sender->level == LEVEL_LEECH)
+ {
+ send_user (sender, MSG_SERVER_NOSUCH, "permission denied: you are a leech");
+ return;
+ }
+
/* find the user to download from */
user = hash_lookup (Users, av[0]);
if (!user)

View File

@ -0,0 +1,239 @@
$OpenBSD: patch-fast_snprintf_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- fast_snprintf.c.orig Fri Aug 2 22:15:44 2002
+++ fast_snprintf.c Tue Mar 6 00:49:52 2001
@@ -0,0 +1,235 @@
+/* Copyright (C) 2000-1 drscholl@users.sourceforge.net
+ This is free software distributed under the terms of the
+ GNU Public License. See the file COPYING for details.
+
+ fast_snprintf.c,v 1.12 2001/03/06 06:49:52 drscholl Exp */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdarg.h>
+#include <assert.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdio.h>
+
+#define DIGIT(n,ui) \
+ if(ui>=(n)) { *out++ = '0' + (ui / (n)) % 10; if (--outsize == 0) break; }
+
+void fast_vsnprintf (char *out, size_t outsize, const char *fmt, va_list ap);
+void fast_snprintf (char *out, size_t outsize, const char *fmt, ...);
+
+void
+fast_vsnprintf (char *out, size_t outsize, const char *fmt, va_list ap)
+{
+ unsigned int ui;
+ unsigned short us;
+ int i, len;
+ char *s;
+ char c;
+
+ if (outsize == 0)
+ return;
+
+ outsize--;
+
+ while (*fmt && outsize > 0)
+ {
+ if ((c = *fmt++) != '%')
+ {
+ *out++ = c;
+ outsize--;
+ }
+ else
+ {
+ c = *fmt++;
+ if (c == 's')
+ {
+ s = va_arg (ap, char *);
+
+ if (s == NULL)
+ {
+ if (outsize < 6)
+ break;
+ strcpy (out, "{null}");
+ out+=6;
+ outsize-=6;
+ }
+ else
+ while (*s && outsize > 0)
+ {
+ *out++ = *s++;
+ outsize--;
+ }
+ }
+ else if (c == 'd')
+ {
+ i = va_arg (ap, int);
+
+ if (i == 0)
+ {
+ /* zero occurs often, so optimize for it */
+ *out++ = '0';
+ outsize--;
+ }
+ else
+ {
+ /* optimized for small ints */
+ if (i < 0)
+ {
+ /* handle negative numbers */
+ *out++ = '-';
+ if (--outsize == 0)
+ break;
+ i *= -1;
+ }
+ DIGIT (100000000, i);
+ DIGIT (10000000, i);
+ DIGIT (1000000, i);
+ DIGIT (100000, i);
+ DIGIT (10000, i);
+ DIGIT (1000, i);
+ DIGIT (100, i);
+ DIGIT (10, i);
+ *out++ = '0' + i % 10;
+ outsize--;
+ }
+ }
+ else if (c == 'h' && *fmt == 'u')
+ {
+ fmt++;
+ /* have to promote short to int */
+ us = (unsigned short) va_arg (ap, unsigned int);
+
+ DIGIT (10000, us);
+ DIGIT (1000, us);
+ DIGIT (100, us);
+ DIGIT (10, us);
+ *out++ = '0' + us % 10;
+ outsize--;
+ }
+ /* %u . assume 10 digit number. this is typically used
+ * to either print a time_t or an ip address.
+ */
+ else if (c == 'u')
+ {
+ ui = va_arg (ap, unsigned int);
+
+#if 1
+ /* this appears to be faster than the other way. my guess
+ * is that the store of the leading 0's takes much longer
+ * than doing ten if() evaluations. The performance is only
+ * slightly better, and solves the problem of those ugly
+ * leading zeros
+ */
+ DIGIT (1000000000, ui);
+ DIGIT (100000000, ui);
+ DIGIT (10000000, ui);
+ DIGIT (1000000, ui);
+ DIGIT (100000, ui);
+ DIGIT (10000, ui);
+ DIGIT (1000, ui);
+ DIGIT (100, ui);
+ DIGIT (10, ui);
+ *out++ = '0' + ui % 10;
+ outsize--;
+#else
+ if (outsize < 10)
+ break;
+ *out++ = '0' + (ui / 1000000000) % 10;
+ *out++ = '0' + (ui / 100000000) % 10;
+ *out++ = '0' + (ui / 10000000) % 10;
+ *out++ = '0' + (ui / 1000000) % 10;
+ *out++ = '0' + (ui / 100000) % 10;
+ *out++ = '0' + (ui / 10000) % 10;
+ *out++ = '0' + (ui / 1000) % 10;
+ *out++ = '0' + (ui / 100) % 10;
+ *out++ = '0' + (ui / 10) % 10;
+ *out++ = '0' + ui % 10;
+ outsize -= 10;
+#endif
+ }
+ else if (c == 'c')
+ {
+ /* va_arg only takes fully promoted types, so we need
+ * a cast here
+ */
+ c = (char) va_arg (ap, int);
+
+ *out++ = c;
+ outsize--;
+ }
+ /* %f is typically used to print an integer larger than a %u */
+ else if (c == 'f')
+ {
+ double f = va_arg (ap, double);
+
+ snprintf (out, outsize, "%.0f", f);
+ len = strlen (out);
+ out += len;
+ outsize -= len;
+ }
+ else
+ assert (0); /* not supported */
+ }
+ }
+ *out = 0;
+}
+
+void
+fast_snprintf (char *out, size_t outsize, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ fast_vsnprintf (out, outsize, fmt, ap);
+ va_end (ap);
+}
+
+#if TEST
+
+#if 1
+#define FUNC fast_snprintf
+#else
+#define FUNC snprintf
+#endif
+
+int
+main (int argc, char **argv)
+{
+ char buf[1024];
+ char *fmt1 = "The %s brown %s jumped %s the %s dogs.";
+ char *fmt2 = "%d %d %d %d";
+ char *fmt3 = "blah blah blah";
+ char *fmt4 = "%u %hu";
+ char *fmt5 = "%d";
+ char *fmt6 = "%u %u %u %u";
+ int i;
+ struct timeval s, e;
+ char small[16];
+
+ memset(small,0xff,sizeof(small));
+ fast_snprintf(small,sizeof(small)-1,"this is a very long string");
+ memset(small,0xff,sizeof(small));
+ fast_snprintf(small,sizeof(small)-1,"this is a ver%d", 123456);
+ memset(small,0xff,sizeof(small));
+ fast_snprintf(small,sizeof(small)-1,"this is a ver%s", "blah blah blah");
+
+ gettimeofday (&s, 0);
+ for (i = 0; i < 10000; i++)
+ {
+ //FUNC (buf, sizeof (buf), fmt1, "quick", "fox", "over", "lazy");
+ //FUNC (buf, sizeof (buf), fmt2, 1, 11, 111, 1111);
+ //FUNC (buf, sizeof (buf), fmt3);
+ //FUNC (buf, sizeof (buf), fmt4, 0x7fffffff, 0xffff);
+ //FUNC (buf, sizeof (buf), fmt5, -10134);
+ FUNC(buf,sizeof(buf),fmt6,0x7fffffff,0x0fffffff,0x00ffffff,0x000fffff);
+ puts(buf);
+ }
+ gettimeofday (&e, 0);
+
+ printf ("%d\n",
+ (e.tv_sec - s.tv_sec) * 1000000 + (e.tv_usec - s.tv_usec));
+}
+#endif

View File

@ -0,0 +1,33 @@
$OpenBSD: patch-init_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- init.c.orig Sun Sep 23 18:09:04 2001
+++ init.c Fri Aug 2 23:11:23 2002
@@ -121,8 +121,8 @@ drop_privs (void)
struct passwd *pw;
struct group *gr;
- n = strtol (USE_GID, &p, 10);
- if (p)
+ n = strtoul (USE_GID, &p, 10);
+ if (*p)
{
/* probably a string */
gr = getgrnam (USE_GID);
@@ -139,8 +139,8 @@ drop_privs (void)
return -1;
}
- n = strtol (USE_UID, &p, 10);
- if (p)
+ n = strtoul (USE_UID, &p, 10);
+ if (*p)
{
/* probably a string */
pw = getpwnam (USE_UID);
@@ -317,6 +317,7 @@ init_server (void)
hash_set_hash_func (File_Table, hash_string, hash_compare_string);
#if RESUME
MD5 = hash_init (4001, 0);
+ hash_set_hash_func (MD5, hash_string, hash_compare_string);
#endif
load_bans ();
load_block ();

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-level_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- level.c.orig Sat Sep 22 00:54:13 2001
+++ level.c Wed Oct 17 13:19:27 2001
@@ -84,7 +84,8 @@ HANDLER (level)
else
{
ASSERT (ISSERVER (con));
- log_message ("level: invalid level %s from server %s", av[1], con->host);
+ log_message ("level: invalid level %s from server %s", av[1],
+ con->host);
}
return;
}
@@ -144,7 +145,7 @@ HANDLER (level)
{
log_message ("level: %s is desynched", con->host);
log_message ("level: %s -> %s %s", sender->nick, av[0],
- Levels[level]);
+ Levels[level]);
if (curlevel != -1)
{
/* reset the user's level on the remote site

View File

@ -0,0 +1,43 @@
$OpenBSD: patch-main_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- main.c.orig Sun Sep 30 17:12:37 2001
+++ main.c Tue Oct 16 18:14:04 2001
@@ -51,6 +51,7 @@ LIST *UserClass = 0;
char Buf[2048]; /* global scratch buffer */
+int gBlockWinMX;
HASH *Channel_Db;
int Client_Queue_Length;
HASH *Channels = 0; /* global channel list */
@@ -330,7 +331,7 @@ report_stats (int fd)
int n;
struct sockaddr_in sin;
socklen_t sinsize = sizeof (sin);
- float loadavg = 0;
+ double loadavg = 0;
n = accept (fd, (struct sockaddr *) &sin, &sinsize);
if (n == -1)
@@ -340,7 +341,10 @@ report_stats (int fd)
}
log_message ("report_stats: connection from %s:%d", inet_ntoa (sin.sin_addr),
htons (sin.sin_port));
-#ifdef linux
+#if HAVE_GETLOADAVG
+ if (getloadavg (&loadavg, 1) < 0)
+ log_message ("report_stats: getloadavg: %s (errno %d)", strerror (errno), errno);
+#elif defined(linux)
{
FILE *f = fopen ("/proc/loadavg", "r");
@@ -356,8 +360,8 @@ report_stats (int fd)
}
}
#endif /* linux */
- snprintf (Buf, sizeof (Buf), "%d %d %.2f %.0f 0\n", Users->dbsize,
- Num_Files, loadavg, Num_Gigs * 1024.);
+ snprintf (Buf, sizeof (Buf), "%d %d %0.2f %.0f %d\n", Users->dbsize,
+ Num_Files, loadavg, Num_Gigs * 1024., global.clients_num - list_count(Servers));
WRITE (n, Buf, strlen (Buf));
CLOSE (n);
}

View File

@ -0,0 +1,110 @@
$OpenBSD: patch-metaserver_dsp,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- metaserver.dsp.orig Fri Aug 2 22:15:44 2002
+++ metaserver.dsp Sun Sep 30 17:07:07 2001
@@ -0,0 +1,106 @@
+# Microsoft Developer Studio Project File - Name="metaserver" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=metaserver - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "metaserver.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "metaserver.mak" CFG="metaserver - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "metaserver - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "metaserver - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "metaserver - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "metaserver___Win32_Release"
+# PROP BASE Intermediate_Dir "metaserver___Win32_Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "metaserver___Win32_Release"
+# PROP Intermediate_Dir "metaserver___Win32_Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../zlib/zlib-1.1.3" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STDC_HEADERS=1 /D REGEX_MALLOC=1 /D FD_SETSIZE=4096 /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 zlib.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../zlib/dll32"
+
+!ELSEIF "$(CFG)" == "metaserver - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "metaserver___Win32_Debug"
+# PROP BASE Intermediate_Dir "metaserver___Win32_Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "metaserver___Win32_Debug"
+# PROP Intermediate_Dir "metaserver___Win32_Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../zlib/" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D STDC_HEADERS=1 /D REGEX_MALLOC=1 /D FD_SETSIZE=4096 /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 zlib.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../zlib/dll32"
+
+!ENDIF
+
+# Begin Target
+
+# Name "metaserver - Win32 Release"
+# Name "metaserver - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\getopt.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\metaserver.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project

View File

@ -0,0 +1,66 @@
$OpenBSD: patch-opennap_h,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- opennap.h.orig Sun Sep 30 17:12:37 2001
+++ opennap.h Tue Oct 16 18:14:04 2001
@@ -143,8 +143,25 @@ struct _user
NOTE. this is a pointer to an entry in
Server_Names, and not malloc'd. */
+ time_t connected; /* time at which the user connected */
+ LIST *channels; /* channels of which this user is a member */
+ CONNECTION *con; /* local connection, or server which this
+ user is behind */
+
+ unsigned int libsize; /* approximate size of shared files in kB */
+ unsigned int ip; /* ip of user in network byte order */
+
unsigned short uploads; /* no. of uploads in progress */
unsigned short downloads; /* no. of downloads in progress */
+ unsigned short port; /* data port client is listening on */
+ unsigned short conport; /* remote port for connection to server */
+ unsigned short totalup; /* total number of uploads */
+ unsigned short totaldown; /* total number of downloads */
+
+ unsigned short shared; /* # of shared files */
+ unsigned short wantPong; /* # of outstanding PONGs */
+
+ unsigned short yyy; /* unused */
unsigned int level:3; /* user level */
unsigned int speed:4; /* link speed */
@@ -154,20 +171,6 @@ struct _user
unsigned int unsharing:1;
unsigned int cloaked:1;
unsigned int xxx:4; /* unused */
- unsigned short shared; /* # of shared files */
-
- unsigned short totalup; /* total number of uploads */
- unsigned short totaldown; /* total number of downloads */
-
- unsigned int libsize; /* approximate size of shared files in kB */
- unsigned int ip; /* ip of user in network byte order */
-
- unsigned short port; /* data port client is listening on */
- unsigned short conport; /* remote port for connection to server */
- time_t connected; /* time at which the user connected */
- LIST *channels; /* channels of which this user is a member */
- CONNECTION *con; /* local connection, or server which this
- user is behind */
};
enum
@@ -486,6 +489,7 @@ extern HASH *MD5;
extern int Stats_Port;
#endif
+extern int gBlockWinMX;
extern HASH *Channel_Db;
extern int Client_Queue_Length;
extern HASH *Client_Versions;
@@ -835,6 +839,7 @@ int config (int);
void config_defaults (void);
USERDB *create_db (USER *);
void destroy_connection (CONNECTION *);
+void discipline_user (USER *);
void dump_channels (void);
void exec_timers (time_t);
void expand_hex (char *, int);

View File

@ -0,0 +1,33 @@
$OpenBSD: patch-ping_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- ping.c.orig Tue Mar 6 00:49:53 2001
+++ ping.c Wed Oct 17 13:19:27 2001
@@ -39,11 +39,29 @@ HANDLER (ping)
return;
}
+ if (gBlockWinMX > 0 && user != orig)
+ {
+ if (tag == MSG_CLIENT_PING)
+ user->wantPong++;
+ else if (orig->wantPong == 0)
+ {
+ if (orig->level < LEVEL_MODERATOR)
+ {
+ discipline_user (orig);
+ return;
+ }
+ }
+ else
+ orig->wantPong--;
+ }
+
if (ISUSER (user->con))
{
if (!is_ignoring (user->con->uopt->ignore, orig->nick))
+ {
send_cmd (user->con, tag, "%s%s%s", orig->nick, pkt ? " " : "",
NONULL (pkt));
+ }
else
send_user (orig, MSG_SERVER_NOSUCH, "%s is ignoring you",
user->nick);

View File

@ -0,0 +1,27 @@
$OpenBSD: patch-privmsg_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- privmsg.c.orig Sat Sep 22 00:54:13 2001
+++ privmsg.c Tue Oct 16 23:02:48 2001
@@ -348,7 +348,7 @@ HANDLER (privmsg)
/* prevent DoS attack againt windows napster client */
if (len - (pkt - ptr) > 180)
{
- log_message ("privmsg(): truncated %d byte message from %s", len,
+ log_message ("privmsg: truncated %d byte message from %s", len,
sender->nick);
pkt[180] = 0;
}
@@ -385,6 +385,14 @@ HANDLER (privmsg)
if (!user)
{
nosuchuser (con);
+ return;
+ }
+
+ if (gBlockWinMX > 0 &&
+ !strncmp ("//WantQueue", pkt, sizeof("//WantQueue")-1))
+ {
+ if (sender->level < LEVEL_MODERATOR)
+ discipline_user (sender);
return;
}

View File

@ -0,0 +1,183 @@
$OpenBSD: patch-proxy-client_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- proxy-client.c.orig Fri Aug 2 22:15:44 2002
+++ proxy-client.c Tue Mar 6 00:49:53 2001
@@ -0,0 +1,179 @@
+/* Copyright (C) 2000-1 drscholl@users.sourceforge.net
+ This is free software distributed under the terms of the
+ GNU Public License. See the file COPYING for details.
+
+ proxy-client.c,v 1.3 2001/03/06 06:49:53 drscholl Exp */
+
+/* a simple proxy server to spy on the traffic between clients. this
+ is a lot easier than using tcpdump. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <errno.h>
+
+unsigned char buf[2048];
+
+int
+pass_message (const char *id, int s, int d)
+{
+ int len;
+ int i;
+
+ len = read (s, buf, sizeof (buf));
+ if (len <= 0)
+ {
+ if (len == -1)
+ printf ("%s: %s\n", id, strerror (errno));
+ else
+ printf ("%s: EOF\n", id);
+ return -1;
+ }
+ buf[len] = 0;
+
+ for (i = 0; i < len; i++)
+ if (buf[i] == '\r')
+ buf[i] = 'M';
+
+ printf ("%s: len=%d, data=%s\n", id, len, buf);
+
+ write (d, buf, len);
+
+ return 0;
+}
+
+static void
+usage (void)
+{
+ puts ("usage: spyserv [ -s client ] [ -p clientport ] [ -l localport ]");
+ exit (0);
+}
+
+int
+main (int argc, char **argv)
+{
+ int s;
+ int c;
+ int r;
+ int localport = 6699;
+ size_t sinsize;
+ struct sockaddr_in sin;
+ fd_set fds;
+ char *host = "192.168.0.101";
+ int port = 6699;
+
+ while ((r = getopt (argc, argv, "hs:p:l:")) != EOF)
+ {
+ switch (r)
+ {
+ case 'l':
+ localport = atoi (optarg);
+ break;
+ case 's':
+ host = optarg;
+ break;
+ case 'p':
+ port = atoi (optarg);
+ break;
+ default:
+ usage ();
+ }
+ }
+
+ /* accept connection from client */
+ s = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (s < 0)
+ {
+ perror ("socket");
+ exit (1);
+ }
+ c = 1;
+ if (setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &c, sizeof (c)) != 0)
+ {
+ perror ("setsockopt");
+ exit (1);
+ }
+ memset (&sin, 0, sizeof (sin));
+ sin.sin_port = htons (localport);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = INADDR_ANY;
+ if (bind (s, &sin, sizeof (sin)) < 0)
+ {
+ perror ("bind");
+ exit (1);
+ }
+ if (listen (s, 1) < 0)
+ {
+ perror ("listen");
+ exit (1);
+ }
+
+ for (;;)
+ {
+ puts ("waiting for connection");
+ sinsize = sizeof (sin);
+ c = accept (s, &sin, &sinsize);
+ if (c < 0)
+ {
+ perror ("accept");
+ exit (1);
+ }
+ puts ("got incoming connection");
+
+ /* make connection to server */
+ printf ("connecting to client...");
+ fflush (stdout);
+ r = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (r < 0)
+ {
+ perror ("socket");
+ exit (1);
+ }
+ memset (&sin, 0, sizeof (sin));
+ sin.sin_port = htons (port);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = inet_addr (host);
+ if (connect (r, &sin, sizeof (sin)) < 0)
+ {
+ perror ("connect");
+ exit (1);
+ }
+ puts ("connected");
+
+ for (;;)
+ {
+ FD_ZERO (&fds);
+ FD_SET (r, &fds);
+ FD_SET (c, &fds);
+ puts ("Waiting for input");
+ if (select (((r > c) ? r : c) + 1, &fds, 0, 0, 0) < 0)
+ {
+ perror ("select");
+ break;
+ }
+ if (FD_ISSET (c, &fds))
+ {
+ if (pass_message ("remote", c, r) != 0)
+ break;
+ }
+ if (FD_ISSET (r, &fds))
+ {
+ if (pass_message ("local", r, c) != 0)
+ break;
+ }
+ }
+
+ close (r);
+ close (c);
+ }
+ close (s);
+
+ exit (0);
+}

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-resume_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- resume.c.orig Tue Mar 6 00:49:53 2001
+++ resume.c Mon Oct 1 12:06:34 2001
@@ -17,8 +17,8 @@ HANDLER (resume)
{
#if RESUME
char *av[2];
- FLIST *flist;
- LIST *ptr;
+ FileList *flist;
+ DList *ptr;
DATUM *d;
int fsize;
#endif /* RESUME */
@@ -41,6 +41,9 @@ HANDLER (resume)
send_cmd (con, MSG_SERVER_NOSUCH, "invalid file size");
return;
}
+
+ /* md5 value is stored using all lowercase hex */
+ strlower (av[0]);
/* search the database for a list of all files which match this hash */
flist = hash_lookup (MD5, av[0]);

View File

@ -0,0 +1,75 @@
$OpenBSD: patch-search_c,v 1.1 2002/08/10 01:14:04 naddy Exp $
--- search.c.orig Fri Sep 28 23:34:23 2001
+++ search.c Tue Oct 16 18:14:04 2001
@@ -304,6 +304,9 @@ free_datum (DATUM * d)
{
int i;
TokenRef *ref;
+#if RESUME
+ FileList *flist;
+#endif
for (i = 0; i < d->numTokens; i++)
{
@@ -342,13 +345,31 @@ free_datum (DATUM * d)
FREE (d->tokens);
- /* XXX broken */
#if RESUME
flist = hash_lookup (MD5, d->hash);
if (flist)
{
+ DList *list;
+
ASSERT (validate_flist (flist));
- flist->list = list_delete (flist->list, d);
+ for (list = flist->list; list; list = list->next)
+ {
+ if (list->data == d)
+ {
+ if (list->prev)
+ list->prev->next = list->next;
+ else
+ {
+ /* element is head of list, update the flist pointer */
+ flist->list = list->next;
+ }
+ if (list->next)
+ list->next->prev = list->prev;
+ FREE (list);
+ break;
+ }
+ }
+
flist->count--;
/* if there are no more files in this bin, erase it */
if (flist->count == 0)
@@ -944,6 +965,13 @@ HANDLER (search)
return;
}
+ /* NO SOUP FOR YOU!!! */
+ if (con->user->level == LEVEL_LEECH)
+ {
+ send_cmd (con, MSG_SERVER_SEARCH_END, "");
+ return;
+ }
+
/* if Max_Searches is > 0, we only allow clients to have a certain small
* number of pending search requests. Some abusive clients will tend
* to issues multiple search requests at a time.
@@ -1015,6 +1043,13 @@ HANDLER (remote_search)
if (! option (ON_ALLOW_SHARE))
{
/* sharing is not allowed on this server */
+ send_cmd (con, MSG_SERVER_REMOTE_SEARCH_END, "%s", id);
+ return;
+ }
+
+ if (user->level == LEVEL_LEECH)
+ {
+ /* user is not allowed to search this server */
send_cmd (con, MSG_SERVER_REMOTE_SEARCH_END, "%s", id);
return;
}

View File

@ -1,12 +1,14 @@
#!/bin/sh
# $OpenBSD: DEINSTALL,v 1.1 2001/03/31 22:41:49 brad Exp $
# $OpenBSD: DEINSTALL,v 1.2 2002/08/10 01:14:04 naddy Exp $
#
# opennap de-installation
set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
CONFIG_DIR=${SYSCONFDIR}
CONFIG_DIR=${SYSCONFDIR}/opennap
OPENNAPUSER=opennap
OPENNAPGROUP=opennap
if [ -d $CONFIG_DIR ]; then
echo
@ -14,7 +16,9 @@ if [ -d $CONFIG_DIR ]; then
echo "| To completely deinstall the $1 package you need to perform"
echo "| this step as root:"
echo "|"
echo "| rm -rf $CONFIG_DIR"
echo "| userdel $OPENNAPUSER"
echo "| groupdel $OPENNAPGROUP"
echo "| rm -rf $CONFIG_DIR"
echo "|"
echo "| Do not do this if you plan on re-installing $1"
echo "| at some future time."

View File

@ -1,21 +1,40 @@
#!/bin/sh
# $OpenBSD: INSTALL,v 1.1 2001/03/31 22:41:49 brad Exp $
# $OpenBSD: INSTALL,v 1.2 2002/08/10 01:14:04 naddy Exp $
#
# Pre/post-installation setup of opennap
# exit on errors, use a sane path and install prefix
#
set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
CONFIG_DIR=${SYSCONFDIR}
CONFIG_DIR=${SYSCONFDIR}/opennap
SAMPLE_CONFIG_DIR=$PREFIX/share/examples/opennap
OPENNAPUSER=opennap
OPENNAPGROUP=opennap
do_usergroup_install()
{
# Create Opennap user and group
groupinfo -e $OPENNAPGROUP
if [ $? -eq 0 ]; then
echo "===> Using $OPENNAPGROUP group for Opennap"
else
echo "===> Creating $OPENNAPGROUP group for Opennap"
groupadd $OPENNAPGROUP
fi
userinfo -e $OPENNAPUSER
if [ $? -eq 0 ]; then
echo "===> Using $OPENNAPUSER user for Opennap"
else
echo "===> Creating $OPENNAPUSER user for Opennap"
useradd -g $OPENNAPGROUP -d /nonexistent -L daemon -c 'Opennap Account' -s /sbin/nologin $OPENNAPUSER
fi
}
do_notice()
{
echo
echo "+---------------"
echo "| The existing $1 configuration files in $CONFIG_DIR,"
echo "| The existing opennap configuration files in $CONFIG_DIR,"
echo "| have NOT been changed. You may want to compare them to the"
echo "| current sample files in $SAMPLE_CONFIG_DIR,"
echo "| and update your configuration as needed."
@ -25,9 +44,9 @@ do_notice()
do_install()
{
install -d -o nobody -g nogroup -m 700 $CONFIG_DIR
install -d -o opennap -g opennap -m 700 $CONFIG_DIR
echo "admin opennap email@here.com Elite 0 0" > $CONFIG_DIR/users
chown nobody:nogroup $CONFIG_DIR/users
chown opennap:opennap $CONFIG_DIR/users
chmod 600 $CONFIG_DIR/users
echo
echo "+---------------"
@ -54,7 +73,7 @@ fi
#
case $2 in
PRE-INSTALL)
: nothing to pre-install for this port
do_usergroup_install
;;
POST-INSTALL)
if [ ! -d $CONFIG_DIR ]; then

14
audio/opennap/pkg/MESSAGE Normal file
View File

@ -0,0 +1,14 @@
Configuring Opennap on OpenBSD
------------------------------
- configuration files are in ${SYSCONFDIR}/opennap
- documentation is installed in ${PREFIX}/doc/opennap
- sample configuration files are in ${PREFIX}/share/examples/opennap
Additionally, you may wish to start opennap at system start-up
via the /etc/rc.local script:
if [ -x ${PREFIX}/sbin/opennap ]; then
echo -n ' opennap'; ${PREFIX}/sbin/opennap -b > /dev/null
fi

View File

@ -1,8 +1,10 @@
@comment $OpenBSD: PLIST,v 1.4 2001/07/11 02:10:07 brad Exp $
@comment $OpenBSD: PLIST,v 1.5 2002/08/10 01:14:04 naddy Exp $
sbin/metaserver
sbin/opennap
sbin/setup
share/doc/opennap/FAQ
share/doc/opennap/README
share/doc/opennap/manual.html
share/doc/opennap/napster.txt
share/examples/opennap/sample.block
share/examples/opennap/sample.channels