/** ** File ......... newpeer.cpp ** Published .... 2005-06-14 ** Author ....... grymse@alhem.net **/ /* Copyright (C) 2005 Anders Hedstrom 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. */ #ifdef _WIN32 #pragma warning(disable:4786) #endif #include #include #include #include "BTDictionary.h" #include "BString.h" #include "PeerHandler.h" #include "pSocket.h" #include "MetainfoSocket.h" #include "StatusSocket.h" #include "MyLog.h" int main(int argc,char *argv[]) { MyLog log; int port = 6881; if (argc > 1) { port = atoi(argv[1]); } // PeerHandler scope { PeerHandler h(&log); ListenSocket l(h); ListenSocket l2(h); ListenSocket l3(h); // settings h.SetExternIP("213.199.75.18"); h.SetListenPort( port ); h.SetTorrentDirectory("Torrent"); h.SetChokeTimer(300); // seconds h.SetMinPeers(50); h.SetMaxPeers(100); h.SetIgnoreChoke(); h.SetMaxRequestAge(30); h.SetDownloaders(4); // keep the X best h.SetOptimistic(1); // drop Y worst // peer l2.Bind(h.GetListenPort()); h.Add(&l2); // inject l.Bind(16969); h.Add(&l); // status l3.Bind(8008); h.Add(&l3); h.Select(1,0); time_t t0 = time(NULL); time_t ts = time(NULL); while (!h.Quit()) { h.Select(1,0); time_t t = time(NULL); if (t != t0) { h.Tick(t); t0 = t; } if (t - ts > 60) { h.Save(); h.Show(); ts = t; } } h.Save(); } // SocketHandler scope printf("Shutdown\n"); return 0; }