wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src/server game.cpp game.hpp input_stre...


From: ott
Subject: [Wesnoth-cvs-commits] wesnoth/src/server game.cpp game.hpp input_stre...
Date: Wed, 20 Jul 2005 03:51:48 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     ott <address@hidden>    05/07/20 07:51:47

Modified files:
        src/server     : game.cpp game.hpp input_stream.cpp 
                         input_stream.hpp metrics.cpp metrics.hpp 
                         player.cpp player.hpp server.cpp variable.cpp 

Log message:
        add copyright notice to server files (and deDOSify)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/game.cpp.diff?tr1=1.38&tr2=1.39&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/game.hpp.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/input_stream.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/input_stream.hpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/metrics.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/metrics.hpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/player.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/player.hpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/server.cpp.diff?tr1=1.82&tr2=1.83&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/server/variable.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: wesnoth/src/server/game.cpp
diff -u wesnoth/src/server/game.cpp:1.38 wesnoth/src/server/game.cpp:1.39
--- wesnoth/src/server/game.cpp:1.38    Sat Jul  2 21:37:20 2005
+++ wesnoth/src/server/game.cpp Wed Jul 20 07:51:46 2005
@@ -1,3 +1,16 @@
+/* $Id: game.cpp,v 1.39 2005/07/20 07:51:46 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #include "../global.hpp"
 
 #include "game.hpp"
Index: wesnoth/src/server/game.hpp
diff -u wesnoth/src/server/game.hpp:1.21 wesnoth/src/server/game.hpp:1.22
--- wesnoth/src/server/game.hpp:1.21    Wed Jun  8 21:10:39 2005
+++ wesnoth/src/server/game.hpp Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: game.hpp,v 1.22 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #ifndef GAME_HPP_INCLUDED
 #define GAME_HPP_INCLUDED
 
Index: wesnoth/src/server/input_stream.cpp
diff -u wesnoth/src/server/input_stream.cpp:1.5 
wesnoth/src/server/input_stream.cpp:1.6
--- wesnoth/src/server/input_stream.cpp:1.5     Sat Jun  4 19:16:06 2005
+++ wesnoth/src/server/input_stream.cpp Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: input_stream.cpp,v 1.6 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #include "../global.hpp"
 
 #include "input_stream.hpp"
Index: wesnoth/src/server/input_stream.hpp
diff -u wesnoth/src/server/input_stream.hpp:1.1 
wesnoth/src/server/input_stream.hpp:1.2
--- wesnoth/src/server/input_stream.hpp:1.1     Tue Jul 27 00:51:45 2004
+++ wesnoth/src/server/input_stream.hpp Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: input_stream.hpp,v 1.2 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #ifndef INPUT_STREAM_HPP_INCLUDED
 #define INPUT_STREAM_HPP_INCLUDED
 
Index: wesnoth/src/server/metrics.cpp
diff -u wesnoth/src/server/metrics.cpp:1.5 wesnoth/src/server/metrics.cpp:1.6
--- wesnoth/src/server/metrics.cpp:1.5  Tue May 10 22:15:57 2005
+++ wesnoth/src/server/metrics.cpp      Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: metrics.cpp,v 1.6 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #include "../global.hpp"
 
 #include "metrics.hpp"
Index: wesnoth/src/server/metrics.hpp
diff -u wesnoth/src/server/metrics.hpp:1.3 wesnoth/src/server/metrics.hpp:1.4
--- wesnoth/src/server/metrics.hpp:1.3  Sun Oct 31 15:21:04 2004
+++ wesnoth/src/server/metrics.hpp      Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: metrics.hpp,v 1.4 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #ifndef METRICS_HPP_INCLUDED
 #define METRICS_HPP_INCLUDED
 
Index: wesnoth/src/server/player.cpp
diff -u wesnoth/src/server/player.cpp:1.4 wesnoth/src/server/player.cpp:1.5
--- wesnoth/src/server/player.cpp:1.4   Thu Dec  2 01:59:05 2004
+++ wesnoth/src/server/player.cpp       Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: player.cpp,v 1.5 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #include "../global.hpp"
 
 #include "player.hpp"
Index: wesnoth/src/server/player.hpp
diff -u wesnoth/src/server/player.hpp:1.3 wesnoth/src/server/player.hpp:1.4
--- wesnoth/src/server/player.hpp:1.3   Tue Jul 20 11:56:58 2004
+++ wesnoth/src/server/player.hpp       Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: player.hpp,v 1.4 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #ifndef PLAYER_HPP_INCLUDED
 #define PLAYER_HPP_INCLUDED
 
Index: wesnoth/src/server/server.cpp
diff -u wesnoth/src/server/server.cpp:1.82 wesnoth/src/server/server.cpp:1.83
--- wesnoth/src/server/server.cpp:1.82  Sun Jul  3 16:19:49 2005
+++ wesnoth/src/server/server.cpp       Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: server.cpp,v 1.83 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #include "../global.hpp"
 
 #include "../config.hpp"
@@ -9,10 +22,10 @@
 
 #include "SDL.h"
 
-#include "game.hpp"
+#include "game.hpp"
 #include "filesystem.hpp"
 #include "input_stream.hpp"
-#include "metrics.hpp"
+#include "metrics.hpp"
 #include "serialization/parser.hpp"
 #include "player.hpp"
 
@@ -89,7 +102,7 @@
 
        const network::manager net_manager_;
        const network::server_manager server_;
-
+
        config version_query_response_;
        config login_response_;
        config join_lobby_response_;
@@ -109,41 +122,41 @@
 
        input_stream& input_;
 
-       metrics metrics_;
-
-       const config& cfg_;
-
-       std::set<std::string> accepted_versions_;
-       std::map<std::string,config> redirected_versions_; 
+       metrics metrics_;
+
+       const config& cfg_;
+
+       std::set<std::string> accepted_versions_;
+       std::map<std::string,config> redirected_versions_;
 
        bool is_ip_banned(const std::string& ip);
        std::string ban_ip(const std::string& mask);
        std::vector<std::string> bans_;
 };
 
-server::server(int port, input_stream& input, const config& cfg) : 
net_manager_(5), server_(port),
+server::server(int port, input_stream& input, const config& cfg) : 
net_manager_(5), server_(port),
     not_logged_in_(players_), lobby_players_(players_), 
last_stats_(time(NULL)), input_(input), cfg_(cfg)
-{
-       version_query_response_.add_child("version");
+{
+       version_query_response_.add_child("version");
+
+       login_response_.add_child("mustlogin");
 
-       login_response_.add_child("mustlogin");
-
-       const std::string& versions = cfg_["versions_accepted"];
-       if(versions.empty() == false) {
-               const std::vector<std::string> accepted(utils::split(versions));
-               for(std::vector<std::string>::const_iterator i = 
accepted.begin(); i != accepted.end(); ++i) {
-                       accepted_versions_.insert(*i);
-               }
-       } else {
-               accepted_versions_.insert(game_config::version);
-       }
-
-       const config::child_list& redirects = cfg_.get_children("redirect");
-       for(config::child_list::const_iterator i = redirects.begin(); i != 
redirects.end(); ++i) {
-               const std::vector<std::string> 
versions(utils::split((**i)["version"]));
-               for(std::vector<std::string>::const_iterator j = 
versions.begin(); j != versions.end(); ++j) {
-                       redirected_versions_[*j] = **i;
-               }
+       const std::string& versions = cfg_["versions_accepted"];
+       if(versions.empty() == false) {
+               const std::vector<std::string> accepted(utils::split(versions));
+               for(std::vector<std::string>::const_iterator i = 
accepted.begin(); i != accepted.end(); ++i) {
+                       accepted_versions_.insert(*i);
+               }
+       } else {
+               accepted_versions_.insert(game_config::version);
+       }
+
+       const config::child_list& redirects = cfg_.get_children("redirect");
+       for(config::child_list::const_iterator i = redirects.begin(); i != 
redirects.end(); ++i) {
+               const std::vector<std::string> 
versions(utils::split((**i)["version"]));
+               for(std::vector<std::string>::const_iterator j = 
versions.begin(); j != versions.end(); ++j) {
+                       redirected_versions_[*j] = **i;
+               }
        }
 
        join_lobby_response_.add_child("join_lobby");
@@ -391,42 +404,42 @@
 }
 
 void server::process_login(const network::connection sock, const config& data, 
config& gamelist)
-{
-       //see if client is sending their version number
-       const config* const version = data.child("version");
-       if(version != NULL) {
-               const std::string& version_str = (*version)["version"];
-
-               if(accepted_versions_.count(version_str)) {
-                       std::cerr << "player joined using accepted version " << 
version_str << ": telling them to log in\n";
-                       network::send_data(login_response_,sock);
-               } else {
-                       const std::map<std::string,config>::const_iterator i = 
redirected_versions_.find(version_str);
-                       if(i != redirected_versions_.end()) {
-                               std::cerr << "player joined using version " << 
version_str << ": redirecting them to "
-                                         << i->second["host"] << ":" << 
i->second["port"] << "\n";
-                               config response;
-                               response.add_child("redirect",i->second);
-                               network::send_data(response,sock);
-                       } else {
-                               std::cerr << "player joined using unknown 
version " << version_str << ": rejecting them\n";
-                               config response;
-                               if(accepted_versions_.empty() == false) {
-                                       response["version"] = 
*accepted_versions_.begin();
-                               } else if(redirected_versions_.empty() == 
false) {
-                                       response["version"] = 
redirected_versions_.begin()->first;
-                               } else {
-                                       std::cerr << "this server doesn't 
accept any versions at all\n";
-                                       response["version"] = "null";
-                               }
-
-                               network::send_data(response,sock);
-                       }
-               }
-               
-               return;
-       }
-
+{
+       //see if client is sending their version number
+       const config* const version = data.child("version");
+       if(version != NULL) {
+               const std::string& version_str = (*version)["version"];
+
+               if(accepted_versions_.count(version_str)) {
+                       std::cerr << "player joined using accepted version " << 
version_str << ": telling them to log in\n";
+                       network::send_data(login_response_,sock);
+               } else {
+                       const std::map<std::string,config>::const_iterator i = 
redirected_versions_.find(version_str);
+                       if(i != redirected_versions_.end()) {
+                               std::cerr << "player joined using version " << 
version_str << ": redirecting them to "
+                                         << i->second["host"] << ":" << 
i->second["port"] << "\n";
+                               config response;
+                               response.add_child("redirect",i->second);
+                               network::send_data(response,sock);
+                       } else {
+                               std::cerr << "player joined using unknown 
version " << version_str << ": rejecting them\n";
+                               config response;
+                               if(accepted_versions_.empty() == false) {
+                                       response["version"] = 
*accepted_versions_.begin();
+                               } else if(redirected_versions_.empty() == 
false) {
+                                       response["version"] = 
redirected_versions_.begin()->first;
+                               } else {
+                                       std::cerr << "this server doesn't 
accept any versions at all\n";
+                                       response["version"] = "null";
+                               }
+
+                               network::send_data(response,sock);
+                       }
+               }
+
+               return;
+       }
+
 
        const config* const login = data.child("login");
 
@@ -951,8 +964,8 @@
 {
        int port = 15000;
 
-       network::set_default_send_size(4096);
-
+       network::set_default_send_size(4096);
+
        config configuration;
 
 #ifndef FIFODIR
@@ -965,20 +978,20 @@
                if(val.empty()) {
                        continue;
                }
-
-               if((val == "--config" || val == "-c") && arg+1 != argc) {
-                       scoped_istream stream = istream_file(argv[++arg]);
-
-                       std::string errors;
-                       try {
-                               read(configuration,*stream,&errors);
-                               if(errors.empty() == false) {
-                                       std::cerr << "WARNING: errors reading 
configuration file: " << errors << "\n";
-                               }
-                       } catch(config::error& e) {
-                               std::cerr << "ERROR: could not read 
configuration file: '" << e.message << "'\n";
-                               return -1;
-                       }
+
+               if((val == "--config" || val == "-c") && arg+1 != argc) {
+                       scoped_istream stream = istream_file(argv[++arg]);
+
+                       std::string errors;
+                       try {
+                               read(configuration,*stream,&errors);
+                               if(errors.empty() == false) {
+                                       std::cerr << "WARNING: errors reading 
configuration file: " << errors << "\n";
+                               }
+                       } catch(config::error& e) {
+                               std::cerr << "ERROR: could not read 
configuration file: '" << e.message << "'\n";
+                               return -1;
+                       }
                } else if((val == "--max_packet_size" || val == "-m") && arg+1 
!= argc) {
                        
network::set_default_send_size(size_t(atoi(argv[++arg])));
                }
Index: wesnoth/src/server/variable.cpp
diff -u wesnoth/src/server/variable.cpp:1.5 wesnoth/src/server/variable.cpp:1.6
--- wesnoth/src/server/variable.cpp:1.5 Thu Dec  2 01:59:05 2004
+++ wesnoth/src/server/variable.cpp     Wed Jul 20 07:51:47 2005
@@ -1,3 +1,16 @@
+/* $Id: variable.cpp,v 1.6 2005/07/20 07:51:47 ott Exp $ */
+/*
+   Copyright (C) 2003-5 by David White <address@hidden>
+   Part of the Battle for Wesnoth Project http://www.wesnoth.org/
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY.
+
+   See the COPYING file for more details.
+*/
+
 #include "../global.hpp"
 
 #include "../game_events.hpp"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]