├── .gitignore ├── BattleCon.png ├── eadocs ├── BFBC2 │ ├── Playlists.pdf │ ├── ExampleConfigurationFiles │ │ ├── reservedslotslist.txt │ │ ├── maplist.txt │ │ ├── banlist.txt │ │ └── startup.txt │ ├── BFBC2 PC Server Administration.pdf │ ├── BFBC2 PC Server Administration Changes.pdf │ ├── BFBC2 PC Remote Administration Protocol.pdf │ ├── BFBC2 PC Remote Administration Protocol Changes.pdf │ ├── EventConsole.py │ └── CommandConsole.py ├── BF4 │ ├── R6 Document Changes.pdf │ ├── BF4 PC Server Administration.pdf │ ├── BF4 PC Base Game Maps and Modes.pdf │ ├── BF4 PC Server Remote Administration Protocol.pdf │ ├── BF4 PC Base Game Modes.csv │ └── BF4 PC Base Game Maps.csv ├── BF3 │ ├── BF3 PC Server Administration.pdf │ ├── BF3 PC Base Game Maps and Modes.pdf │ ├── BF3 PC XPACK1 Game Maps and Modes.pdf │ ├── BF3 PC XPACK2 Game Maps and Modes.pdf │ ├── BF3 PC Server Administration Changes.pdf │ ├── BF3 PC Server Remote Administration Protocol.pdf │ ├── BF3 PC Server Remote Administration Protocol Changes.pdf │ ├── BF3 PC XPACK2 Game Modes.csv │ ├── BF3 PC Base Game Modes.csv │ ├── BF3 PC XPACK2 Game Maps.csv │ ├── BF3 PC XPACK1 Game Modes.csv │ ├── BF3 PC XPACK1 Game Maps.csv │ └── BF3 PC Base Game Maps.csv └── README.txt ├── package.json ├── src ├── games │ ├── BF3.js │ ├── BF4.js │ ├── BF.js │ └── core.js ├── BattleCon │ └── Message.js └── BattleCon.js ├── example.js ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log 2 | config.json 3 | raw/ 4 | -------------------------------------------------------------------------------- /BattleCon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/BattleCon.png -------------------------------------------------------------------------------- /eadocs/BFBC2/Playlists.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BFBC2/Playlists.pdf -------------------------------------------------------------------------------- /eadocs/BFBC2/ExampleConfigurationFiles/reservedslotslist.txt: -------------------------------------------------------------------------------- 1 | SoldierName1 2 | SoldierName2 3 | SoldierName3 4 | -------------------------------------------------------------------------------- /eadocs/BF4/R6 Document Changes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF4/R6 Document Changes.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC Server Administration.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF3/BF3 PC Server Administration.pdf -------------------------------------------------------------------------------- /eadocs/BF4/BF4 PC Server Administration.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF4/BF4 PC Server Administration.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC Base Game Maps and Modes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF3/BF3 PC Base Game Maps and Modes.pdf -------------------------------------------------------------------------------- /eadocs/BF4/BF4 PC Base Game Maps and Modes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF4/BF4 PC Base Game Maps and Modes.pdf -------------------------------------------------------------------------------- /eadocs/BFBC2/BFBC2 PC Server Administration.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BFBC2/BFBC2 PC Server Administration.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC XPACK1 Game Maps and Modes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF3/BF3 PC XPACK1 Game Maps and Modes.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC XPACK2 Game Maps and Modes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF3/BF3 PC XPACK2 Game Maps and Modes.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC Server Administration Changes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF3/BF3 PC Server Administration Changes.pdf -------------------------------------------------------------------------------- /eadocs/BFBC2/ExampleConfigurationFiles/maplist.txt: -------------------------------------------------------------------------------- 1 | RUSH 2 | levels/mp_012gr 3 | levels/mp_002 4 4 | levels/mp_004 5 | levels/mp_009gr 6 | levels/mp_002 7 | -------------------------------------------------------------------------------- /eadocs/BFBC2/BFBC2 PC Server Administration Changes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BFBC2/BFBC2 PC Server Administration Changes.pdf -------------------------------------------------------------------------------- /eadocs/BFBC2/BFBC2 PC Remote Administration Protocol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BFBC2/BFBC2 PC Remote Administration Protocol.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC Server Remote Administration Protocol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF3/BF3 PC Server Remote Administration Protocol.pdf -------------------------------------------------------------------------------- /eadocs/BF4/BF4 PC Server Remote Administration Protocol.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF4/BF4 PC Server Remote Administration Protocol.pdf -------------------------------------------------------------------------------- /eadocs/BFBC2/BFBC2 PC Remote Administration Protocol Changes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BFBC2/BFBC2 PC Remote Administration Protocol Changes.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC Server Remote Administration Protocol Changes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dcodeIO/BattleCon/HEAD/eadocs/BF3/BF3 PC Server Remote Administration Protocol Changes.pdf -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC XPACK2 Game Modes.csv: -------------------------------------------------------------------------------- 1 | Engine Name;Human-Readable Name;Intended max player count 2 | Domination0;Conquest Domination;16 3 | GunMaster0;Gun master;16 4 | SquadDeathMatch0;Squad Deathmatch;16 5 | TeamDeathMatchC0;TDM Close Quarters;16 6 | -------------------------------------------------------------------------------- /eadocs/BFBC2/ExampleConfigurationFiles/banlist.txt: -------------------------------------------------------------------------------- 1 | guid 2 | EA_12345678123456781234567812345678 3 | perm 4 | 212139960249 5 | Banned for not being a good sport 6 | name 7 | SoldierName 8 | seconds 9 | 212139961246 10 | cool off for a bit please 11 | -------------------------------------------------------------------------------- /eadocs/README.txt: -------------------------------------------------------------------------------- 1 | Sources 2 | ------- 3 | 4 | * BF4 5 | http://www.fpsadmin.com/forum/showthread.php?t=25348 6 | 7 | * BF3 8 | http://www.fpsadmin.com/forum/showthread.php?t=24134 9 | 10 | * BFBC2 11 | http://www.fpsadmin.com/forum/showthread.php?t=21667 12 | 13 | -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC Base Game Modes.csv: -------------------------------------------------------------------------------- 1 | Engine Name;Human-Readable Name;Intended max player count 2 | ConquestLarge0;Conquest64;64 3 | ConquestSmall0;Conquest;32 4 | RushLarge0;Rush;32 5 | SquadRush0;Squad Rush;8 6 | SquadDeathMatch0;Squad Deathmatch;16 7 | TeamDeathMatch0;Team Deathmatch;24 8 | -------------------------------------------------------------------------------- /eadocs/BF4/BF4 PC Base Game Modes.csv: -------------------------------------------------------------------------------- 1 | Engine Name;Human-Readable Name;Intended max player count 2 | ConquestLarge0;Conquest;64 3 | ConquestSmall0;Conquest;32 4 | Domination0;Domination;20 5 | Elimination0;Defuse;10 6 | Obliteration;Obliteration;32 7 | RushLarge0;Rush;32 8 | SquadDeathMatch0;Squad Deathmatch;16 9 | TeamDeathMatch0;Team Deathmatch;24 10 | -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC XPACK2 Game Maps.csv: -------------------------------------------------------------------------------- 1 | Engine name;Human-readable name;Game modes 2 | XP2_Factory;Scrapmetal;TeamDeathMatchC0,GunMaster0,Domination0,SquadDeathMatch0 3 | XP2_Office;Operation 925;TeamDeathMatchC0,GunMaster0,Domination0,SquadDeathMatch0 4 | XP2_Palace;Donya Fortress;TeamDeathMatchC0,GunMaster0,Domination0,SquadDeathMatch0 5 | XP2_Skybar;Ziba Tower;TeamDeathMatchC0,GunMaster0,Domination0,SquadDeathMatch0 6 | -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC XPACK1 Game Modes.csv: -------------------------------------------------------------------------------- 1 | Engine Name;Human-Readable Name;Intended max player count 2 | ConquestLarge0;Conquest64;64 3 | ConquestSmall0;Conquest;32 4 | ConquestAssaultLarge0;Conquest Assault64;64 5 | ConquestAssaultSmall0;Conquest Assault;32 6 | ConquestAssaultSmall1;Conquest Assault alt.2;32 7 | RushLarge0;Rush;32 8 | SquadRush0;Squad Rush;8 9 | SquadDeathMatch0;Squad Deathmatch;16 10 | TeamDeathMatch0;Team Deathmatch;24 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "battlecon", 3 | "description": "A Battlefield / Frostbite engine RCON layer on node.js", 4 | "author": "Daniel Wirtz ", 5 | "version": "0.3.0", 6 | "main": "src/BattleCon.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/dcodeIO/BattleCon.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/dcodeIO/BattleCon/issues" 13 | }, 14 | "keywords": ["rcon", "utility", "frostbite", "battlefield"], 15 | "license": "Apache-2.0", 16 | "engines": { 17 | "node": ">=0.6" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC XPACK1 Game Maps.csv: -------------------------------------------------------------------------------- 1 | Engine name;Human-readable name;Game modes 2 | XP1_001;Strike At Karkand;ConquestAssaultLarge0,ConquestAssaultSmall0,ConquestAssaultSmall1,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 3 | XP1_002;Gulf of Oman;ConquestLarge0,ConquestSmall0,ConquestAssaultSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 4 | XP1_003;Sharqi Peninsula;ConquestAssaultLarge0,ConquestAssaultSmall0,ConquestAssaultSmall1,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 5 | XP1_004;Wake Island;ConquestAssaultLarge0,ConquestAssaultSmall0,ConquestAssaultSmall1,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 6 | -------------------------------------------------------------------------------- /src/games/BF3.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Daniel Wirtz 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * Loads the BF3 module. 19 | * @param {!BattleCon} bc 20 | */ 21 | module.exports = function(bc) { 22 | 23 | // Extends BF (common) 24 | bc.use("BF"); 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /src/games/BF4.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Daniel Wirtz 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * Loads the BF4 module. 19 | * @param {!BattleCon} bc 20 | */ 21 | module.exports = function(bc) { 22 | 23 | // Extends BF (common) 24 | bc.use("BF"); 25 | 26 | }; 27 | -------------------------------------------------------------------------------- /eadocs/BF3/BF3 PC Base Game Maps.csv: -------------------------------------------------------------------------------- 1 | Engine name;Human-readable name;Game modes 2 | MP_001;Grand Bazaar;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 3 | MP_003;Teheran Highway;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 4 | MP_007;Caspian Border;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 5 | MP_011;Seine Crossing;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 6 | MP_012;Operation Firestorm;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 7 | MP_013;Damavand Peak;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 8 | MP_017;Noshahr Canals;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 9 | MP_018;Kharg Island;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 10 | MP_Subway;Operation Metro;ConquestLarge0,ConquestSmall0,RushLarge0,SquadRush0,SquadDeathMatch0,TeamDeathMatch0 11 | -------------------------------------------------------------------------------- /eadocs/BFBC2/ExampleConfigurationFiles/startup.txt: -------------------------------------------------------------------------------- 1 | ################################################# 2 | ###### This is an example startup.txt 3 | 4 | # Set the name that the server will expose in the server browser 5 | vars.serverName "My Server" 6 | 7 | # Set URL for the server banner 8 | vars.bannerUrl "http://www.example.com/example.png" 9 | 10 | # Set server description (shown on the loading screen and in server info) - use "|" for line breaks 11 | vars.serverDescription "Welcome to my server|Stay a while, stay forever!" 12 | 13 | # Ranked mode on; this enforces PunkBuster on and game password off 14 | vars.ranked true 15 | 16 | # No friendly fire, please 17 | vars.friendlyFire false 18 | 19 | # Hardcore mode off 20 | vars.hardCore false 21 | 22 | # Profanity filter off, please 23 | vars.profanityFilter false 24 | 25 | # Set the initial spawn-timer to 30 seconds for all levels 26 | levelVars.set all startDelay 30 27 | 28 | # Increase tickets bleed speed by 20% on all Conquest levels 29 | levelVars.set gamemode CONQUEST ticketBleedSpeed 120 30 | 31 | 32 | -------------------------------------------------------------------------------- /eadocs/BF4/BF4 PC Base Game Maps.csv: -------------------------------------------------------------------------------- 1 | Engine name;Human-readable name;Game modes 2 | MP_Abandoned;Zavod 311;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 3 | MP_Damage;Lancang Dam;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 4 | MP_Flooded;Flood Zone;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 5 | MP_Journey;Golmud Railway;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 6 | MP_Naval;Paracel Storm;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 7 | MP_Prison;Operation Locker;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 8 | MP_Resort;Hainan Resort;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 9 | MP_Siege;Siege of Shanghai;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 10 | MP_TheDish;Rogue Transmission;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 11 | MP_Tremors;Dawnbreaker;ConquestLarge0,ConquestSmall0,Domination0,Elimination0,Obliteration,RushLarge0,SquadDeathMatch0,TeamDeathMatch0 12 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | var BattleCon = require("./src/BattleCon.js"), 2 | config = require("./config.json"), 3 | repl = require("repl"), 4 | bc = new BattleCon(config.host, config.port, config.pass).use("BF4"); 5 | 6 | bc.on("connect", function() { 7 | console.log("# Connected to "+bc.host+":"+bc.port); 8 | }); 9 | 10 | bc.on("login", function() { 11 | console.log("# Login successful"); 12 | }); 13 | 14 | bc.on("ready", function() { 15 | 16 | // Execute raw commands: 17 | 18 | bc.exec("version", function(err, msg) { 19 | console.log("# Server is running "+msg[0]+", version "+msg[1]); 20 | }); 21 | 22 | // Execute module commands (core.js): 23 | 24 | bc.serverInfo(function(err, info) { 25 | console.log("Server info:", info); 26 | }); 27 | 28 | bc.listPlayers(function(err, players) { 29 | console.log("There are "+players.length+" connected players:"); 30 | for (var i=0; i "+subset.join(' ')+": "+text); 53 | }); 54 | }); 55 | 56 | bc.on("close", function() { 57 | console.log("# Disconnected."); 58 | }); 59 | 60 | bc.on("error", function(err) { 61 | console.log("# Error: "+err.message, err.stack); 62 | }); 63 | 64 | bc.connect(); // Connects and logs in 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![BattleCon - BATTLEFIELD layer on node.js](https://raw.github.com/dcodeIO/BattleCon/master/BattleCon.png) 2 | ======================================== 3 | BattleCon is a Battlefield / Frostbite engine RCON layer built on top of nothing less than the excellent node.js 4 | platform. 5 | 6 | With BattleCon it's easy to create your very own server management interface, like automatic map votings, auto team 7 | balancing, live player stats and more. 8 | 9 | Usage 10 | ----- 11 | 12 | #### Executing commands: 13 | 14 | ```js 15 | var BattleCon = require("battlecon"), 16 | bc = new BattleCon("host", port, "pass").use("core"); 17 | 18 | bc.on("login", function() { 19 | bc.exec("version", function(err, res) { 20 | if (err) { 21 | console.log("Error: "+err); 22 | return; 23 | } 24 | console.log("version:", res); 25 | }); 26 | }); 27 | 28 | bc.connect(); // Connects and logs in 29 | ``` 30 | 31 | #### Processing (raw) server events: 32 | 33 | ```js 34 | ... 35 | bc.on("event", function(evt) { 36 | console.log("Event:", evt); 37 | }); 38 | ``` 39 | 40 | Core 41 | ---- 42 | The core module implements common commands used between Frostbite-driven games, like logging in and out, version and 43 | server info querying. 44 | 45 | Modules 46 | ------- 47 | Additionally, BattleCon supports game-specific modules, like the BF3 and BF4 modules. Loading modules is simple: 48 | 49 | ```js 50 | ... 51 | var bc = new BattleCon("host", port, "pass").use("BF4"); 52 | 53 | ...your logic... 54 | 55 | bc.connect(); 56 | ``` 57 | 58 | Currently, [the game modules](https://github.com/dcodeIO/BattleCon/tree/master/src/games) are quite basic and provide 59 | basic functionality only. Feel free to extend them and send me a pull request! 60 | 61 | Examples 62 | -------- 63 | There is a simple example of how to use BattleCon, like reacting to server events and issuing commands: 64 | 65 | * [example.js](https://github.com/dcodeIO/BattleCon/blob/master/example.js) 66 | 67 | License 68 | ------- 69 | Apache License, Version 2.0 70 | -------------------------------------------------------------------------------- /src/games/BF.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Daniel Wirtz 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * Loads the BF (common) module. 19 | * @param {!BattleCon} bc 20 | */ 21 | module.exports = function(bc) { 22 | 23 | // Extends core 24 | bc.use("core"); 25 | 26 | // Parse events 27 | bc.on("event", function(msg) { 28 | switch (msg.data[0]) { 29 | case "player.onJoin": 30 | bc.emit("player.join", /* name */ msg.data[1], /* uid */ msg.data[2]); 31 | break; 32 | case "player.onAuthenticated": 33 | bc.emit("player.authenticated", /* name */ msg.data[1]); 34 | break; 35 | case "player.onLeave": 36 | bc.emit("player.leave", /* name */ msg.data[1], /* info */ bc.tabulate(msg.data, 2)[0]); 37 | break; 38 | case "player.onSpawn": 39 | bc.emit("player.spawn", /* name */ msg.data[1], /* team */ parseInt(msg[2], 10)); 40 | break; 41 | case "player.onSquadChange": 42 | bc.emit("player.squadChange", /* name */ msg.data[1], /* team */ parseInt(msg.data[2], 10), /* squad */ parseInt(msg.data[3], 10)); 43 | break; 44 | case "player.onTeamChange": 45 | bc.emit("player.teamChange", /* name */ msg.data[1], /* team */ parseInt(msg.data[2], 10), /* squad */ parseInt(msg.data[3], 10)); 46 | break; 47 | case "player.onKill": 48 | bc.emit("player.kill", /* killer */ msg.data[1], /* victim */ msg.data[2], /* weapon */ msg.data[3], /* headshot */ msg.data[4] === "true"); 49 | break; 50 | case "player.onChat": 51 | bc.emit("player.chat", /* name */ msg.data[1], /* text */ msg.data[2], /* player subset */ msg.data.slice(3)); 52 | break; 53 | case "server.onLevelLoaded": 54 | bc.emit("server.levelLoaded", /* name */ msg.data[1], /* mode name */ msg.data[2], /* round no. */ parseInt(msg.data[3], 10), /* of total rounds */ parseInt(msg.data[4], 10)); 55 | break; 56 | case "server.onRoundOver": 57 | bc.emit("server.roundOver", /* winning team */ parseInt(msg.data[1], 10)); 58 | break; 59 | case "server.onRoundOverPlayers": 60 | bc.emit("server.roundOverPlayers", /* players */ bc.tabulate(msg.data, 1)); 61 | break; 62 | case "server.onRoundOverTeamScores": 63 | var n = parseInt(msg.data[1], 10), // # scores 64 | scores = []; 65 | for (var i=2; i<2+n; i++) { 66 | scores.push(parseFloat(msg.data[i])); 67 | } 68 | bc.emit("server.roundOverTeamScores", /* scores array */ scores, /* target score */ parseInt(msg.data[i], 10)); 69 | break; 70 | } 71 | }); 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /src/BattleCon/Message.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Daniel Wirtz 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /** 18 | * Constructs a new BattleCon Message. 19 | * @exports BattleCon.Message 20 | * @param {number} id Sequence id 21 | * @param {number} flags Flags 22 | * @param {string|!Array.} data Data 23 | * @constructor 24 | */ 25 | var Message = function(id, flags, data) { 26 | this.id = id & 0x3fffffff; 27 | this.flags = flags & 0x3; 28 | this.data = typeof data === 'string' ? data.split(' ') : data; 29 | }; 30 | 31 | /** 32 | * Message flags. 33 | * @type {!Object.} 34 | */ 35 | Message.FLAGS = {}; 36 | 37 | /** 38 | * Message is a response. 39 | * @type {number} 40 | * @const 41 | */ 42 | Message.FLAGS.RESPONSE = 0x01; 43 | 44 | /** 45 | * Message originated from the server. 46 | * @type {number} 47 | * @const 48 | */ 49 | Message.FLAGS.FROMSERVER = 0x02; 50 | 51 | /** 52 | * Encodes the Message. 53 | * @returns {!Buffer} 54 | */ 55 | Message.prototype.encode = function() { 56 | // First of all, construct the data part 57 | var data = [], 58 | dataLength = 0; 59 | for (var i=0; i> 30) & 0x3, 103 | dataLength = buf.readUInt32LE(8), 104 | data = [], 105 | offset = 12; 106 | for (var i=0; i 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | var crypto = require("crypto"); 18 | 19 | /** 20 | * Loads the core Frostbite module. 21 | * @param {!BattleCon} bc 22 | */ 23 | module.exports = function(bc) { 24 | 25 | /** 26 | * Available commands. 27 | * @type {Array.} 28 | */ 29 | bc.commands = []; 30 | 31 | /** 32 | * Available variables. 33 | * @type {Array.} 34 | */ 35 | bc.vars = []; 36 | 37 | /** 38 | * Server version. 39 | * @type {Array.} 40 | */ 41 | bc.serverVersion = null; 42 | 43 | bc.on("login", function() { 44 | 45 | // Enable events 46 | bc.eventsEnabled(true, function(err, enabled) {}); 47 | 48 | // Get list of available commands / vars 49 | bc.help(function(err, msg) { 50 | if (err) return; 51 | bc.commands = msg; 52 | var vars = []; 53 | for (var i=0; i=)} callback Callback 80 | */ 81 | bc.help = function(callback) { 82 | bc.exec("admin.help", function(err, res) { 83 | if (err) { 84 | callback(err); 85 | return; 86 | } 87 | callback(null, res); 88 | }); 89 | }; 90 | 91 | /** 92 | * Gets / sets if events are enabled. 93 | * @param {boolean|function(Error, boolean=)} enabled true to enable, false to disable 94 | * @param {function(Error, boolean=)} callback Callback 95 | */ 96 | bc.eventsEnabled = function(enabled, callback) { 97 | if (typeof enabled === 'function') { 98 | callback = enabled; 99 | enabled = null; 100 | } 101 | if (typeof enabled !== 'boolean') { // Just query 102 | bc.exec(["admin.eventsEnabled"], function(err, res) { 103 | if (err) { 104 | callback(err); 105 | return; 106 | } 107 | callback(null, res[0] === "true"); 108 | }); 109 | } else { // Set and query 110 | bc.exec(["admin.eventsEnabled", enabled ? "true" : "false"], function(err, res) { 111 | if (err) { 112 | callback(err); 113 | return; 114 | } 115 | bc.exec(["admin.eventsEnabled"], function(err, res) { 116 | if (err) { 117 | callback(err); 118 | return; 119 | } 120 | callback(null, res[0] === "true"); 121 | }); 122 | }); 123 | } 124 | }; 125 | 126 | /** 127 | * Gets the list of players. 128 | * @param {function(Error, Array.>=)} callback Callback 129 | */ 130 | bc.listPlayers = function(callback) { 131 | bc.exec(["listPlayers", "all"], function(err, res) { // BF4-like 132 | if (err) { 133 | bc.exec(["listPlayers"], function(err2, res2) { // Possible fallback 134 | if (err2) { 135 | callback(err); 136 | return; 137 | } 138 | callback(null, bc.tabulate(res2)); 139 | }); 140 | return; 141 | } 142 | callback(null, bc.tabulate(res)); 143 | }); 144 | }; 145 | 146 | /** 147 | * Gets information about the server. 148 | * @param {function(Error, Array.=)} callback Callback 149 | */ 150 | bc.serverInfo = function(callback) { 151 | bc.exec(["serverInfo"], function(err, res) { 152 | if (err) { 153 | callback(err); 154 | return; 155 | } 156 | callback(null, res); 157 | }); 158 | }; 159 | 160 | /** 161 | * Logs in. 162 | * @param {function(Error)=} callback Callback 163 | */ 164 | bc.login = function(callback) { 165 | this.exec(["login.hashed"], function(err, res) { 166 | if (err) { 167 | this.sock.end(); 168 | this.emit("error", err); 169 | if (callback) callback(err); 170 | return; 171 | } 172 | var md = crypto.createHash("md5"); 173 | md.update(res[0], "hex"); 174 | md.update(this.pass, "utf8"); 175 | this.exec(["login.hashed", md.digest("hex").toUpperCase()], function(err) { 176 | if (err) { 177 | this.sock.end(); 178 | this.emit("error", err); 179 | if (callback) callback(err); 180 | return; 181 | } 182 | this.loggedIn = true; 183 | this.emit("login"); 184 | if (callback) callback(null); 185 | }.bind(this)); 186 | }.bind(this)); 187 | }; 188 | 189 | /** 190 | * Logs out. 191 | * @param {function(Error)=} callback Callback 192 | */ 193 | bc.logout = function(callback) { 194 | this.exec(["logout"], function(err) { 195 | if (err) { 196 | if (callback) callback(err); 197 | return; 198 | } 199 | if (callback) callback(null); 200 | }); 201 | }; 202 | 203 | /** 204 | * Ends the session. 205 | * @param {function(Error)=} callback Callback 206 | */ 207 | bc.quit = function(callback) { 208 | bc.exec(["quit"], function(err, res) { 209 | if (err) { 210 | if (callback) callback(err); 211 | return; 212 | } 213 | if (callback) callback(null); 214 | }); 215 | }; 216 | }; 217 | -------------------------------------------------------------------------------- /src/BattleCon.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Daniel Wirtz 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | var events = require("events"), 18 | net = require("net"), 19 | Message = require("./BattleCon/Message.js"); 20 | 21 | /** 22 | * Constructs a new BattleCon instance. 23 | * @exports BattleCon 24 | * @param {string} host Hostname or IP 25 | * @param {number} port Port 26 | * @param {string} pass RCON password 27 | * @constructor 28 | * @extends events.EventEmitter 29 | */ 30 | var BattleCon = function(host, port, pass) { 31 | events.EventEmitter.call(this); 32 | 33 | // Connection parameters 34 | this.host = host; 35 | this.port = port; 36 | this.pass = pass; 37 | 38 | // Connection state 39 | this.loggedIn = false; 40 | this.sock = null; 41 | this.id = 0x3fffffff; 42 | this.buf = new Buffer(0); 43 | this.cbs = {}; 44 | }; 45 | 46 | // Event | Meaning 47 | // ------------------------|---------------------------------------- 48 | // connect | Connection established 49 | // login | Successfully logged in 50 | // ready | Ready to operate (after login), core.js 51 | // close | Connection closed 52 | // error | Error caught 53 | // event | Raw server event 54 | // message | Raw server response 55 | // exec | Raw client request (throw to abort) 56 | 57 | /** 58 | * @alias {BattleCon.Message} 59 | */ 60 | BattleCon.Message = Message; 61 | 62 | // Extends EventEmitter 63 | BattleCon.prototype = Object.create(events.EventEmitter.prototype); 64 | 65 | /** 66 | * Loads a game module. 67 | * @param {string|function(!BattleCon)} gameModule Plugin to use 68 | * @param {*=} options Module options 69 | * @returns {!BattleCon} this 70 | * @throws {Error} If the module could not be loaded 71 | */ 72 | BattleCon.prototype.use = function(gameModule, options) { 73 | if (typeof gameModule === 'function') { 74 | gameModule(this, options); 75 | } else if (typeof gameModule === 'string' && /^[a-zA-Z0-9_\-]+$/.test(gameModule)) { 76 | require("./games/"+gameModule+".js")(this, options); 77 | } 78 | return this; 79 | }; 80 | 81 | /** 82 | * Connects and logs in to the server. 83 | * @param {function(Error)=} callback Callback 84 | */ 85 | BattleCon.prototype.connect = function(callback) { 86 | if (this.sock !== null) return; 87 | this.sock = new net.Socket(); 88 | var cbCalled = false; 89 | this.sock.on("error", function(err) { 90 | if (!this.loggedIn && callback && !cbCalled) { 91 | cbCalled = true; 92 | callback(err); 93 | } 94 | this.emit("error", err); 95 | }.bind(this)); 96 | this.sock.on("close", function() { 97 | this.emit("close"); 98 | this.sock = null; 99 | }.bind(this)); 100 | this.sock.connect(this.port, this.host, function() { 101 | this.emit("connect"); 102 | this.sock.on("data", this._gather.bind(this)); 103 | if (this.login) this.login(callback); 104 | }.bind(this)); 105 | }; 106 | 107 | /** 108 | * Disconnects from the server. 109 | */ 110 | BattleCon.prototype.disconnect = function() { 111 | if (this.sock !== null) { 112 | this.sock.end(); 113 | } 114 | }; 115 | 116 | /** 117 | * Gathers more data. 118 | * @param {!Buffer} chunk Chunk of data 119 | * @private 120 | */ 121 | BattleCon.prototype._gather = function(chunk) { 122 | this.buf = Buffer.concat([this.buf, chunk]); 123 | do { 124 | if (this.buf.length < 8) return; 125 | var size = this.buf.readUInt32LE(4); 126 | if (this.buf.length < size) return; 127 | var data = this.buf.slice(0, size); 128 | this.buf = this.buf.slice(size, this.buf.length); 129 | try { 130 | this._process(Message.decode(data)); 131 | } catch (err) { 132 | this.emit("error", err); 133 | } 134 | } while (true); 135 | }; 136 | 137 | /** 138 | * Processes the next message. 139 | * @param {!Message} msg Message 140 | * @private 141 | */ 142 | BattleCon.prototype._process = function(msg) { 143 | if (msg.data.length == 0) { 144 | this.emit("error", "empty message received"); 145 | return; 146 | } 147 | if (msg.isFromServer()) { 148 | this.emit("event", /* raw event */ msg); 149 | } else { 150 | this.emit("message", /* raw message */ msg); 151 | if (this.cbs.hasOwnProperty("cb"+msg.id)) { 152 | var callback = this.cbs["cb"+msg.id]; 153 | delete this.cbs["cb"+msg.id]; 154 | if (msg.data[0] === "OK") { 155 | callback(null, msg.data.slice(1)); 156 | } else { 157 | callback(new Error(msg.data.join(' '))); 158 | } 159 | } 160 | } 161 | }; 162 | 163 | /** 164 | * Executes a command. 165 | * @param {string|!Array.} command Command 166 | * @param {function(Error, Message=)=} callback Callback 167 | */ 168 | BattleCon.prototype.exec = function(command, callback) { 169 | var msg = new Message(this.id, 0, command); 170 | if (typeof callback === 'function') { 171 | this.cbs["cb"+this.id] = callback; 172 | } 173 | try { 174 | this.emit("exec", msg); // May throw to abort 175 | } catch (aborted) { 176 | return; 177 | } 178 | this.sock.write(msg.encode()); 179 | this.id = (this.id+1)&0x3fffffff; 180 | }; 181 | 182 | /** 183 | * Tabulates a result containing columns and rows. 184 | * @param {!Array.} res Result to tabulate 185 | * @param {number=} offset Offset to start at, defaults to 0 186 | * @returns {!Array.>} 187 | */ 188 | BattleCon.tabulate = function(res, offset) { 189 | if (!offset) offset = 0; 190 | var nColumns = parseInt(res[offset], 10), 191 | columns = []; 192 | for (var i=offset+1; i<=nColumns; i++) { 193 | columns.push(res[i]); 194 | } 195 | var nRows = parseInt(res[i], 10), 196 | rows = []; 197 | for (var n=0; n} res 212 | * @returns {!Array.>} 213 | */ 214 | BattleCon.prototype.tabulate = BattleCon.tabulate; 215 | 216 | module.exports = BattleCon; 217 | -------------------------------------------------------------------------------- /eadocs/BFBC2/EventConsole.py: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/python 2 | from struct import * 3 | import md5 4 | import socket 5 | import sys 6 | import shlex 7 | import string 8 | import threading 9 | import os 10 | 11 | # This is an example program which shows game server events. 12 | # It logs in to the game server, enables eventa, and then prints out any events received (and responds to them). 13 | 14 | ############################################################################### 15 | 16 | # Packet encoding/decoding helper functions 17 | 18 | def EncodeHeader(isFromServer, isResponse, sequence): 19 | header = sequence & 0x3fffffff 20 | if isFromServer: 21 | header += 0x80000000 22 | if isResponse: 23 | header += 0x40000000 24 | return pack(' " ) 246 | words = shlex.split(command) 247 | 248 | if len(words) >= 1: 249 | 250 | if "quit" == words[0]: 251 | running = False 252 | 253 | # Send request to server on command channel 254 | request = EncodeClientRequest(words) 255 | serverSocket.send(request) 256 | 257 | # Wait for response from server 258 | [packet, receiveBuffer] = receivePacket(serverSocket, receiveBuffer) 259 | 260 | [isFromServer, isResponse, sequence, words] = DecodePacket(packet) 261 | 262 | # The packet from the server should 263 | # For now, we always respond with an "OK" 264 | if not isResponse: 265 | print 'Received an unexpected request packet from server, ignored:' 266 | 267 | printPacket(DecodePacket(packet)) 268 | 269 | 270 | except socket.error, detail: 271 | print 'Network error:', detail[1] 272 | 273 | except EOFError, KeyboardInterrupt: 274 | pass 275 | 276 | except: 277 | raise 278 | 279 | finally: 280 | try: 281 | # readline.write_history_file( history_file ) 282 | if serverSocket is not None: 283 | serverSocket.close() 284 | 285 | print "Done" 286 | except: 287 | raise 288 | 289 | sys.exit( 0 ) 290 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------