Sacha Ligthert 3 gadi atpakaļ
revīzija
c8465d5f94
16 mainītis faili ar 1540 papildinājumiem un 0 dzēšanām
  1. 20 0
      .gitignore
  2. 57 0
      GDCSST.sql
  3. 339 0
      LICENSE
  4. 55 0
      README.md
  5. 265 0
      backend.go
  6. 179 0
      frontend.go
  7. 63 0
      gdcsst.go
  8. 9 0
      go.mod
  9. 210 0
      go.sum
  10. 89 0
      helpers.go
  11. 60 0
      structs.go
  12. 52 0
      templates/about.html
  13. 34 0
      templates/server.html
  14. 27 0
      templates/servers.html
  15. 11 0
      templates/stats.html
  16. 70 0
      templates/template.html

+ 20 - 0
.gitignore

@@ -0,0 +1,20 @@
+# Binaries for programs and plugins
+*.exe
+*.exe~
+*.dll
+*.so
+*.dylib
+
+# Test binary, built with `go test -c`
+*.test
+
+# Output of the go coverage tool, specifically when used with LiteIDE
+*.out
+
+# Dependency directories (remove the comment below to include it)
+# vendor/
+
+# Private Project Stuff
+notes.txt
+GeoLite2-Country.mmdb
+run.sh

+ 57 - 0
GDCSST.sql

@@ -0,0 +1,57 @@
+DROP TABLE IF EXISTS `scenarios`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `scenarios` (
+  `instance_id` varchar(21) DEFAULT NULL,
+  `players` int(3) DEFAULT NULL,
+  `mission_name` varchar(255) DEFAULT NULL,
+  `mission_time` int(11) DEFAULT NULL,
+  `mission_time_formatted` varchar(21) DEFAULT NULL,
+  `start` int(11) DEFAULT '0',
+  `end` int(11) DEFAULT '0',
+  KEY `index_instance_id` (`instance_id`,`start`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+
+DROP TABLE IF EXISTS `scenarios_log`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `scenarios_log` (
+  `instance_id` varchar(21) DEFAULT NULL,
+  `timestamp` int(11) DEFAULT NULL,
+  `players` int(3) DEFAULT NULL,
+  `players_max` int(3) DEFAULT NULL,
+  `mission_name` varchar(255) DEFAULT NULL,
+  `mission_time` int(11) DEFAULT NULL,
+  `mission_time_formatted` varchar(21) DEFAULT NULL,
+  KEY `index_instance_id` (`instance_id`),
+  KEY `index_players` (`players`),
+  KEY `index_mission_name` (`mission_name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+
+DROP TABLE IF EXISTS `servers`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `servers` (
+  `INSTANCE_ID` varchar(21) DEFAULT NULL,
+  `timestamp` int(11) DEFAULT NULL,
+  `status` varchar(4) DEFAULT NULL,
+  `NAME` varchar(255) DEFAULT NULL,
+  `DESCRIPTION` text,
+  `IP_ADDRESS` varchar(16) DEFAULT NULL,
+  `PORT` varchar(5) DEFAULT NULL,
+  `PASSWORD` varchar(3) DEFAULT NULL,
+  `PLAYERS` int(3) DEFAULT NULL,
+  `PLAYERS_MAX` int(3) DEFAULT NULL,
+  `MISSION_NAME` varchar(255) DEFAULT NULL,
+  `MISSION_TIME` int(11) DEFAULT NULL,
+  `MISSION_TIME_FORMATTED` varchar(21) DEFAULT NULL,
+  `country_iso` varchar(7) DEFAULT NULL,
+  `country_name` varchar(100) DEFAULT NULL,
+  KEY `index_status` (`status`),
+  KEY `index_players` (`PLAYERS`),
+  KEY `index_name` (`NAME`),
+  KEY `index_mission_name` (`MISSION_NAME`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 339 - 0
LICENSE

@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.

+ 55 - 0
README.md

@@ -0,0 +1,55 @@
+# GDCSST
+Digital Combat Simulator Server Tracker written in Go
+
+## About
+The goal of GDCSST is to capture server information from the [DCS](digitalcombatsimulator.com/) website, store and visualize it in a human readable format.
+
+## Requirements
+To run this use any recent versions of the following:
+- [Prometheus](https://github.com/prometheus/prometheus)
+- [Redis](https://redis.io/)
+- [Prometheus-PNG](https://github.com/lomik/prometheus-png/)
+
+## Installation and Configuration
+### 1. Setup a Redis server
+This step is easy straightforward, either install one from scratch or reuse an existing instance and give it a new DB for gdcsst.
+
+### 2. Get a copy of the GeoLite2 Free GeoLocation Data
+Go to https://dev.maxmind.com/geoip/geolite2-free-geolocation-data?lang=en, register and download `GeoLite2-Country_20yymmdd.tar.gz`. Unpack it and chuck the .mmdb-file in the same folder of the next step.
+
+### 2. Install and run the GDCSST
+Copy the binary (you may need to make it with `go build .`) and the `template/` folder to some place nice and comfy where it can run from.
+
+Set the following environmental variables:
+#### DCS Account
+Login credentials to login at www.digitalcombatsimulator.com and get the list of servers
+* `DCS_SERVER_TRACKER_ED_USER`
+* `DCS_SERVER_TRACKER_ED_PASS`
+
+#### Redis
+Redis server, port and db #
+* `DCS_SERVER_TRACKER_REDIS_IP`
+* `DCS_SERVER_TRACKER_REDIS_PORT`
+* `DCS_SERVER_TRACKER_PASSWORD`
+* `DCS_SERVER_TRACKER_REDIS_DB`
+
+#### GeoIP2
+Point this to where your GeoLite2-Country.mmdb is stored
+* `DCS_SERVER_TRACKER_GEOIP2_FILE`
+
+Finally, chuck these environments in a shell-script of a service file and then run `GDCSST` binary. Once running curl/browse to `host:port/metrics` to see if all goes well, or check the application output.
+
+
+### 3. Setup Prometheus and point it to your gdcsst install
+Install Prometheus and configure a job to scrape GDCSST.
+```
+scrape_configs:
+- job_name: "dcstracker"
+  static_configs:
+    - targets: ["localhost:9200"]
+```
+
+### 4. Install and configure Prometheus-PNG
+Download and compile the binary from https://github.com/lomik/prometheus-png/ or run the Docker image:
+`docker run --rm -p 8080:8080 lomik/prometheus-png:latest -prometheus "http://127.0.0.1:9090/"`
+Pick the right port and point to the right prometheus installation.

+ 265 - 0
backend.go

@@ -0,0 +1,265 @@
+package main
+
+import (
+	"encoding/json"
+	"io/ioutil"
+	"log"
+	"math"
+	"net"
+	"net/http"
+	"net/url"
+	"strconv"
+	"strings"
+	"time"
+
+	"github.com/go-redis/redis/v8"
+	"github.com/oschwald/geoip2-golang"
+)
+
+var servers DCSServers
+
+func updateServers() {
+
+	data := url.Values{
+		"AUTH_FORM":     {"Y"},
+		"TYPE":          {"AUTH"},
+		"backurl":       {"/en/personal/server/?ajax=y"},
+		"USER_LOGIN":    {AppConfig.EDUser},
+		"USER_PASSWORD": {AppConfig.EDPass},
+		"USER_REMEMBER": {"Y"},
+	}
+
+	for {
+		t := time.Now()
+		currDate := int(t.Unix())
+
+		log.Println("Fetching server meta-data")
+
+		resp, err := http.PostForm("https://www.digitalcombatsimulator.com/en/personal/server/?ajax=y", data)
+		if err != nil {
+			log.Fatalln(err)
+		}
+
+		body, _ := ioutil.ReadAll(resp.Body)
+		err = json.Unmarshal(body, &servers)
+		if err != nil {
+			log.Fatalln(err)
+		}
+
+		log.Println("Fetched server meta-data")
+
+		// serverID Unique identifier for a server
+		var serverID string
+
+		// Clean up first
+		for _, server := range servers.Servers {
+			serverID = server.IPAddress + ":" + server.Port
+			GdcsstPlayers.WithLabelValues(serverID).Set(float64(0))
+		}
+
+		GdcsstOnline.WithLabelValues("servers").Set(math.Round(float64(len(servers.Servers))))
+		GdcsstOnline.WithLabelValues("players").Set(math.Round(float64(servers.PlayersCount)))
+
+		for _, server := range servers.Servers {
+			p, _ := strconv.ParseFloat(server.Players, 32)
+			serverID = server.IPAddress + ":" + server.Port
+			GdcsstPlayers.WithLabelValues(serverID).Set(p)
+		}
+
+		//log.Println("Num Servers", len(servers.Servers))
+
+		// Connect to the GeoIP2 database
+		db, err := geoip2.Open(AppConfig.GeoIP2File)
+		if err != nil {
+			log.Fatal(err)
+		}
+		defer db.Close()
+
+		// Connect to Redis
+		RedisDB, _ := strconv.ParseInt(AppConfig.RedisDB, 10, 8)
+		rdb := redis.NewClient(&redis.Options{
+			Addr:     AppConfig.RedisIP + ":" + AppConfig.RedisPort,
+			Password: AppConfig.RedisPassword,
+			DB:       int(RedisDB),
+		})
+		defer db.Close()
+
+		// Required for the next step
+		cacheIgnored := 0
+		cacheResolved := 0
+
+		var ServerList []ServerMeta
+		var metadata ServerMeta
+
+		// Compare with Redis + Provide data for webpage
+		for _, server := range servers.Servers {
+			// Create the unique serverID
+			serverID = server.IPAddress + ":" + server.Port
+
+			// Server Password
+			var serverPassword bool
+
+			// Server stuff
+			serverMissionTime, _ := strconv.ParseInt(server.MissionTime, 10, 8)
+			serverPlayers, _ := strconv.ParseInt(server.Players, 10, 8)
+			serverPlayersMax, _ := strconv.ParseInt(server.PlayersMax, 10, 8)
+
+			if server.Password == "Yes" {
+				serverPassword = true
+			} else {
+				serverPassword = false
+			}
+
+			// Do IP stuff
+			ip := net.ParseIP(server.IPAddress)
+			record, err := db.Country(ip)
+			if err != nil {
+				log.Fatal(err)
+			}
+
+			// Get record from Redis
+			redisServer, err := rdb.Get(ctx, serverID).Result()
+			if err == redis.Nil {
+
+				metadata = ServerMeta{
+					Name:                 server.Name,
+					IPAddress:            server.IPAddress,
+					Port:                 server.Port,
+					MissionName:          server.MissionName,
+					MissionTime:          int(serverMissionTime),
+					Players:              int(serverPlayers),
+					PlayersMax:           int(serverPlayersMax),
+					Password:             serverPassword,
+					Description:          server.Description,
+					MissionTimeFormatted: server.MissionTimeFormatted,
+					CountryName:          record.Country.Names["en"],
+					ISO:                  strings.ToLower(record.Country.IsoCode),
+					LastUpdate:           currDate,
+				}
+
+				msg, errr := json.Marshal(metadata)
+				if errr != nil {
+					log.Fatal(errr)
+				}
+
+				err = rdb.Set(ctx, serverID, msg, 750*time.Hour).Err()
+				if err != nil {
+					panic(err)
+				}
+
+				cacheResolved++
+			} else if err != nil {
+				panic(err)
+			} else {
+				redisServerB := []byte(redisServer)
+				json.Unmarshal(redisServerB, &metadata)
+
+				metadata = ServerMeta{
+					Name:                 server.Name,
+					IPAddress:            server.IPAddress,
+					Port:                 server.Port,
+					MissionName:          server.MissionName,
+					MissionTime:          int(serverMissionTime),
+					Players:              int(serverPlayers),
+					PlayersMax:           int(serverPlayersMax),
+					Password:             serverPassword,
+					Description:          server.Description,
+					MissionTimeFormatted: server.MissionTimeFormatted,
+					CountryName:          record.Country.Names["en"],
+					ISO:                  strings.ToLower(record.Country.IsoCode),
+					LastUpdate:           currDate,
+				}
+
+				// Write stuff
+				msg, errr := json.Marshal(metadata)
+				if errr != nil {
+					log.Fatal(errr)
+				}
+
+				err = rdb.Set(ctx, serverID, msg, 750*time.Hour).Err()
+				if err != nil {
+					panic(err)
+				}
+
+				cacheIgnored++
+			}
+			if strings.Contains(server.Name, AppConfig.BlackList) == false {
+				ServerList = append(ServerList, metadata)
+			}
+		} // End of Server processing function
+		log.Printf("Done processing servers: %d processed and %d ignored.", cacheResolved, cacheIgnored)
+
+		msg, err := json.Marshal(ServerList)
+		if err != nil {
+			panic(err)
+		}
+		redisSet("metadata", msg, time.Hour)
+
+		// Handle max:
+		var maxPlayers int
+		var maxServers int
+		var maxUpdate int
+
+		for _, server := range servers.Servers {
+			players, _ := strconv.ParseInt(server.Players, 10, 8)
+			maxPlayers += int(players)
+			maxServers++
+		}
+
+		var localMaxims GlobalMaxims
+
+		maximsJSON, err := rdb.Get(ctx, "maxims").Result()
+		if err == redis.Nil {
+			log.Println("Maxims not found. Initalizing.")
+			localMaxims := GlobalMaxims{MaxServers: maxServers, MaxServersTime: currDate, MaxPlayers: maxPlayers, MaxPlayersTime: currDate}
+
+			msg, errr := json.Marshal(localMaxims)
+			if errr != nil {
+				log.Fatal(errr)
+			}
+
+			err = rdb.Set(ctx, "maxims", msg, 0).Err()
+			if err != nil {
+				panic(err)
+			}
+
+		} else if err != nil {
+			panic(err)
+		} else {
+			maximsB := []byte(maximsJSON)
+			json.Unmarshal(maximsB, &localMaxims)
+
+			if localMaxims.MaxServers < maxServers {
+				log.Printf("Servers %d > %d", maxServers, localMaxims.MaxServers)
+				localMaxims.MaxServers = maxServers
+				localMaxims.MaxServersTime = currDate
+				maxUpdate = 1
+			}
+
+			if localMaxims.MaxPlayers < maxPlayers {
+				log.Printf("Players %d > %d", maxPlayers, localMaxims.MaxPlayers)
+				localMaxims.MaxPlayers = maxPlayers
+				localMaxims.MaxPlayersTime = currDate
+				maxUpdate = 1
+			}
+
+			if maxUpdate == 1 {
+				log.Println("New Maxims found, updating! \\o/")
+				msg, errr := json.Marshal(localMaxims)
+				if errr != nil {
+					log.Fatal(errr)
+				}
+
+				err = rdb.Set(ctx, "maxims", msg, 0).Err()
+				if err != nil {
+					panic(err)
+				}
+			}
+		}
+
+		redisSet("LastUpdate", []byte(strconv.Itoa(currDate)), 0)
+
+		// Sleep a minute
+		time.Sleep(60 * time.Second)
+	} // For-loop
+} // Function

+ 179 - 0
frontend.go

@@ -0,0 +1,179 @@
+package main
+
+import (
+	"bytes"
+	"encoding/json"
+	"io/ioutil"
+	"log"
+	"net/http"
+	"sort"
+	"strconv"
+	"strings"
+	"text/template"
+	"time"
+)
+
+func compileTemplate(w http.ResponseWriter, title string, content string) {
+	type TemplateData struct {
+		Title          string
+		Content        string
+		Active_Servers bool
+		Active_Stats   bool
+		Active_About   bool
+		LastUpdate     string
+	}
+
+	var Active_Servers bool
+	var Active_Stats bool
+	var Active_About bool
+
+	LastUpdate, _ := strconv.ParseInt(redisGet("LastUpdate"), 10, 64)
+	t := time.Unix(LastUpdate, 0)
+
+	switch title {
+	case "About":
+		Active_About = true
+	case "Stats":
+		Active_Stats = true
+	default:
+		Active_Servers = true
+
+	}
+
+	data := TemplateData{
+		Title:          title,
+		Content:        content,
+		Active_Servers: Active_Servers,
+		Active_Stats:   Active_Stats,
+		Active_About:   Active_About,
+		LastUpdate:     t.Format(time.RFC3339),
+	}
+
+	tmpl := template.Must(template.ParseFiles("templates/template.html"))
+	tmpl.Execute(w, data)
+
+}
+
+func handleServers(w http.ResponseWriter, r *http.Request) {
+
+	var err error
+
+	type serversStruct struct {
+		ServerCount int
+		PlayerCount int
+		Servers     []ServerMeta
+	}
+
+	// Fetch the data from Redis and Unmarshal it
+	metadata := redisGet("metadata")
+	var ServerMetaData []ServerMeta
+	err = json.Unmarshal([]byte(metadata), &ServerMetaData)
+	if err != nil {
+		panic(err)
+	}
+
+	var playerCount int
+
+	for i, server := range ServerMetaData {
+		playerCount += server.Players
+		if server.Description == "No" {
+			ServerMetaData[i].Description = ""
+		} else {
+			ServerMetaData[i].Description = strings.ReplaceAll(ServerMetaData[i].Description, "<br />", "")
+			ServerMetaData[i].Description = strings.ReplaceAll(ServerMetaData[i].Description, "__", "")
+			ServerMetaData[i].Description = strings.ReplaceAll(ServerMetaData[i].Description, "  ", "")
+		}
+	}
+
+	var sortfields string
+
+	keys, ok := r.URL.Query()["sort"]
+	if !ok || len(keys[0]) < 1 {
+		sortfields = "Players:DESC"
+	} else {
+		sortfields = keys[0]
+	}
+
+	switch sortfields {
+	case "Country:DESC":
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].ISO > ServerMetaData[j].ISO })
+	case "Country:ASC":
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].ISO < ServerMetaData[j].ISO })
+	case "Server:DESC":
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].Name > ServerMetaData[j].Name })
+	case "Server:ASC":
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].Name < ServerMetaData[j].Name })
+	case "Scenario:DESC":
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].MissionName > ServerMetaData[j].MissionName })
+	case "Scenario:ASC":
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].MissionName < ServerMetaData[j].MissionName })
+	case "Players:ASC":
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].Players < ServerMetaData[j].Players })
+	default:
+		sort.Slice(ServerMetaData, func(i, j int) bool { return ServerMetaData[i].Players > ServerMetaData[j].Players })
+	}
+
+	serversContent := serversStruct{len(ServerMetaData), playerCount, ServerMetaData}
+
+	var tpl bytes.Buffer
+
+	parsedTemplate, _ := template.ParseFiles("templates/servers.html")
+	err = parsedTemplate.Execute(&tpl, serversContent)
+	if err != nil {
+		log.Println("Error executing template :", err)
+		return
+	}
+
+	compileTemplate(w, "Servers", tpl.String())
+
+}
+
+func handleServer(w http.ResponseWriter, r *http.Request) {
+	url := r.URL.String()
+
+	// Redirect /servers/ -> /servers
+	if url == "/servers/" {
+		http.Redirect(w, r, "/servers", 301)
+	}
+
+	// Parse data
+	server := url[9:]
+	ServerInfo := redisGet(server)
+	var ServerDataMeta ServerMeta
+	err := json.Unmarshal([]byte(ServerInfo), &ServerDataMeta)
+	if err != nil {
+		log.Println("Server nofound")
+	}
+
+	var tpl bytes.Buffer
+	parsedTemplate, _ := template.ParseFiles("templates/server.html")
+	err = parsedTemplate.Execute(&tpl, ServerDataMeta)
+	if err != nil {
+		log.Println("Error executing template :", err)
+		return
+	}
+
+	compileTemplate(w, "Servers", tpl.String())
+
+}
+
+func handlerStats(w http.ResponseWriter, r *http.Request) {
+	metrics := struct{ stuff int }{stuff: 0}
+	var tpl bytes.Buffer
+	parsedTemplate, _ := template.ParseFiles("templates/stats.html")
+	err := parsedTemplate.Execute(&tpl, metrics)
+	if err != nil {
+		log.Println("Error executing template :", err)
+		return
+	}
+
+	compileTemplate(w, "Servers", tpl.String())
+}
+
+func handlerAbout(w http.ResponseWriter, r *http.Request) {
+	content, err := ioutil.ReadFile("templates/about.html")
+	if err != nil {
+		log.Fatal(err)
+	}
+	compileTemplate(w, "About", string(content))
+}

+ 63 - 0
gdcsst.go

@@ -0,0 +1,63 @@
+package main
+
+// Imports
+import (
+	"context"
+	"log"
+	"net/http"
+
+	"github.com/prometheus/client_golang/prometheus"
+	"github.com/prometheus/client_golang/prometheus/promhttp"
+)
+
+var AppConfig Config
+
+var (
+	// GdcsstOnline Online servers or players
+	GdcsstOnline = prometheus.NewGaugeVec(prometheus.GaugeOpts{
+		Name: "gdcsst_online",
+		Help: "Online",
+	},
+		[]string{"scope"},
+	)
+
+	// GdcsstPlayers -- Players on Servers
+	GdcsstPlayers = prometheus.NewGaugeVec(prometheus.GaugeOpts{
+		Name: "gdcsst_players",
+		Help: "All players on a server",
+	},
+		[]string{"server"},
+	)
+)
+
+func init() {
+	prometheus.MustRegister(GdcsstOnline)
+	prometheus.MustRegister(GdcsstPlayers)
+	AppConfig = processConfig()
+}
+
+// Required for Redis
+var ctx = context.Background()
+
+// Main function
+func main() {
+	// The Main loop to update servers
+	// Handled in "backend.go"
+	go updateServers()
+
+	// Configure the net/http module
+	// Handled in "frontend.go"
+	http.Handle("/", http.RedirectHandler("/servers", 301))
+	http.HandleFunc("/servers", handleServers)
+	http.HandleFunc("/servers/", handleServer)
+	http.HandleFunc("/stats", handlerStats)
+	http.HandleFunc("/about", handlerAbout)
+
+	http.Handle("/metrics", promhttp.HandlerFor(
+		prometheus.DefaultGatherer,
+		promhttp.HandlerOpts{
+			EnableOpenMetrics: true,
+		},
+	))
+	log.Fatal(http.ListenAndServe(AppConfig.ListenAddress, nil))
+}

+ 9 - 0
go.mod

@@ -0,0 +1,9 @@
+module github.com/GlowieXYZ/GDCSST
+
+go 1.16
+
+require (
+	github.com/go-redis/redis/v8 v8.11.4
+	github.com/oschwald/geoip2-golang v1.5.0
+	github.com/prometheus/client_golang v1.11.0
+)

+ 210 - 0
go.sum

@@ -0,0 +1,210 @@
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
+github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
+github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
+github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
+github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
+github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
+github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
+github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
+github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
+github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
+github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
+github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
+github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
+github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
+github.com/go-redis/redis/v8 v8.11.4 h1:kHoYkfZP6+pe04aFTnhDH6GDROa5yJdHJVNxV3F46Tg=
+github.com/go-redis/redis/v8 v8.11.4/go.mod h1:2Z2wHZXdQpCDXEGzqMockDpNyYvi2l4Pxt6RJr792+w=
+github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
+github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
+github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
+github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
+github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
+github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
+github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
+github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
+github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
+github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
+github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
+github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
+github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
+github.com/onsi/gomega v1.16.0 h1:6gjqkI8iiRHMvdccRJM8rVKjCWk6ZIm6FTm3ddIe4/c=
+github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
+github.com/oschwald/geoip2-golang v1.5.0 h1:igg2yQIrrcRccB1ytFXqBfOHCjXWIoMv85lVJ1ONZzw=
+github.com/oschwald/geoip2-golang v1.5.0/go.mod h1:xdvYt5xQzB8ORWFqPnqMwZpCpgNagttWdoZLlJQzg7s=
+github.com/oschwald/maxminddb-golang v1.8.0 h1:Uh/DSnGoxsyp/KYbY1AuP0tYEwfs0sCph9p/UMXK/Hk=
+github.com/oschwald/maxminddb-golang v1.8.0/go.mod h1:RXZtst0N6+FY/3qCNmZMBApR19cdQj43/NM9VkrNAis=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
+github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
+github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=
+github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
+github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
+github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
+github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ=
+github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
+github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
+github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
+github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
+github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
+github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
+github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
+golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
+golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191224085550-c709ea063b76/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q=
+golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
+gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

+ 89 - 0
helpers.go

@@ -0,0 +1,89 @@
+package main
+
+import (
+	"fmt"
+	"log"
+	"os"
+	"strconv"
+	"time"
+
+	"github.com/go-redis/redis/v8"
+)
+
+func connectRedis() redis.Client {
+	// Connect to Redis
+	RedisDB, _ := strconv.ParseInt(AppConfig.RedisDB, 10, 8)
+	rdb := redis.NewClient(&redis.Options{
+		Addr:     AppConfig.RedisIP + ":" + AppConfig.RedisPort,
+		Password: AppConfig.RedisPassword, // no password set
+		DB:       int(RedisDB),            // use default DB
+	})
+	return *rdb
+}
+
+func closeRedis(rdb *redis.Client) {
+	rdb.Close()
+}
+
+// Helper Functions
+func redisGet(key string) string {
+	rdb := connectRedis()
+	redisData, err := rdb.Get(ctx, key).Result()
+	closeRedis(&rdb)
+
+	if err != nil {
+		panic(err)
+	}
+
+	if err == redis.Nil {
+		return ""
+	}
+	return redisData
+
+}
+
+func redisSet(key string, data []byte, ttl time.Duration) {
+	rdb := connectRedis()
+	err := rdb.Set(ctx, key, data, ttl).Err()
+	closeRedis(&rdb)
+	if err != nil {
+		panic(err)
+	}
+}
+
+func fetchEnv(variable string, defaultVar string) string {
+	val, ok := os.LookupEnv(variable)
+	if ok {
+		return val
+	}
+	return defaultVar
+
+}
+
+func processConfig() Config {
+
+	AppConfig := Config{
+		ListenAddress: ":9200",
+		EDUser:        fetchEnv("DCS_SERVER_TRACKER_ED_USER", ""),
+		EDPass:        fetchEnv("DCS_SERVER_TRACKER_ED_PASS", ""),
+		RedisIP:       fetchEnv("DCS_SERVER_TRACKER_REDIS_IP", "localhost"),
+		RedisPort:     fetchEnv("DCS_SERVER_TRACKER_REDIS_PORT", "6379"),
+		RedisPassword: fetchEnv("DCS_SERVER_TRACKER_REDIS_PASSWORD", ""),
+		RedisDB:       fetchEnv("DCS_SERVER_TRACKER_REDIS_DB", "0"),
+		GeoIP2File:    fetchEnv("DCS_SERVER_TRACKER_GEOIP2_FILE", "GeoLite2-Country.mmdb"),
+		BlackList:     fetchEnv("DCS_SERVER_TRACKER_BLACKLIST", ""),
+		PromPNGURL:    fetchEnv("DCS_SERVER_TRACKER_PROMPNG_URL", "http://localhost:8080/"),
+	}
+
+	log.Println("Using the following config:")
+	fmt.Println("DCS_SERVER_TRACKER_ED_USER:", AppConfig.EDUser)
+	fmt.Println("DCS_SERVER_TRACKER_ED_PASS: ****")
+	fmt.Println("DCS_SERVER_TRACKER_REDIS_IP", AppConfig.RedisIP)
+	fmt.Println("DCS_SERVER_TRACKER_REDIS_PORT", AppConfig.RedisPort)
+	fmt.Println("DCS_SERVER_TRACKER_REDIS_PASSWORD: ****")
+	fmt.Println("DCS_SERVER_TRACKER_REDIS_DB", AppConfig.RedisDB)
+	fmt.Println("DCS_SERVER_TRACKER_GEOIP2_FILE", AppConfig.GeoIP2File)
+	fmt.Println("DCS_SERVER_TRACKER_BLACKLIST:", AppConfig.BlackList)
+
+	return AppConfig
+}

+ 60 - 0
structs.go

@@ -0,0 +1,60 @@
+package main
+
+// Config This contains all the application specific config
+type Config struct {
+	ListenAddress string
+	EDUser        string
+	EDPass        string
+	RedisIP       string
+	RedisPort     string
+	RedisPassword string
+	RedisDB       string
+	GeoIP2File    string
+	PromPNGURL    string
+	BlackList     string
+}
+
+// DCSServers is struct to capture the JSON data returning from DCS.com
+type DCSServers struct {
+	ServersMaxCount int           `json:"SERVERS_MAX_COUNT"`
+	ServersMaxDate  string        `json:"SERVERS_MAX_DATE"`
+	PlayersCount    int           `json:"PLAYERS_COUNT"`
+	MyServers       []interface{} `json:"MY_SERVERS"`
+	Servers         []struct {
+		Name                 string `json:"NAME"`
+		IPAddress            string `json:"IP_ADDRESS"`
+		Port                 string `json:"PORT"`
+		MissionName          string `json:"MISSION_NAME"`
+		MissionTime          string `json:"MISSION_TIME"`
+		Players              string `json:"PLAYERS"`
+		PlayersMax           string `json:"PLAYERS_MAX"`
+		Password             string `json:"PASSWORD"`
+		Description          string `json:"DESCRIPTION"`
+		MissionTimeFormatted string `json:"MISSION_TIME_FORMATTED"`
+	} `json:"SERVERS"`
+}
+
+// ServerMeta Metadate of servers stored in Redis
+type ServerMeta struct {
+	Name                 string
+	IPAddress            string
+	Port                 string
+	MissionName          string
+	MissionTime          int    // Convert
+	Players              int    // Convert
+	PlayersMax           int    // Convert
+	Password             bool   // "Yes"/"No"
+	Description          string // "No"
+	MissionTimeFormatted string
+	CountryName          string // These are new
+	ISO                  string
+	LastUpdate           int
+}
+
+// GlobalMaxims Maxims recorded for storage in Redis
+type GlobalMaxims struct {
+	MaxServers     int
+	MaxServersTime int
+	MaxPlayers     int
+	MaxPlayersTime int
+}

+ 52 - 0
templates/about.html

@@ -0,0 +1,52 @@
+<div class="text-left">
+<h3>Acknowledgement</h3>
+<p><small>A 100% inspired by the fine work and services provided by <a href="https://arma3.swec.se/">https://arma3.swec.se/</a> (while it was still up).</small></p>
+<h3>About</h3>
+<p>DCS Server Tracker (DCST) is a tool that allows you to keep track of <a href="https://www.digitalcombatsimulator.com/">DCS World</a> online servers. It tracks the servers, the number of players and which scenarios are played on them and tries to present all the information gathered in something that is easy to see at a glance.</p>
+<h3>Development</h3>
+<p>Made using the following tools:
+  <ul>
+    <li><a href="https://atom.io/">Atom Editor</a></li>
+    <li><a href="https://git-scm.com/">Git</a></li>
+    <li><a href="https://golang.org/">Go</a></li>
+    <li><a href="https://prometheus.io/">Prometheus</a></li>
+    <li><a href="https://github.com/lomik/prometheus-png/">Prometheus-PNG</a></li>
+    <li><a href="https://redis.io/">Redis</a></li>
+    <li><a href="https://aws.amazon.com/cloudfront/">AWS CloudFront</a> (Which as a pain to setup the first time)</li>
+  </ul>
+<p>Questions? Bugs? Contribute? Run your own instance? <a href="https://github.com/GlowieXYZ/GDCSST/">Check this out at GitHub.</a></p>
+<p>TODO:
+  <ul>
+    <li>Add nice server filters (need Javascript skills for that)</li>
+    <li>Have a dedicated server detector running.</li>
+  </ul>
+</p>
+<p>&nbsp;</p>
+<h3>Changelog</h3>
+<h4>2021-10-19: Rewrite in Go</h4>
+<ul>
+  <li>Finally got the time to rewrite this application in Go and use tech that allows it to continue for extended periods of time without my intervention. I am so lazy, so if I get this right I shouldn't have to bother unless the monitoring starts alerting me. :-)</li>
+</ul>
+<h4>2019-09-16: Improving one line at the time!</h4>
+<ul>
+  <li>MySQL queries go through redis now to improve query speed.</li>
+</ul>
+<h4>2019-09-15: Lets try again..</h4>
+<ul>
+  <li>Replaced DynamoDB and memcached in favour of redis.</li>
+  <li>Dumped all the MySQL related queries into a function. Makes it SLOW AF. But should cause less trouble in the long run.</li>
+</ul>
+<h4>2019-03-16: I needed a global CDN for this?</h4>
+<ul>
+  <li>Show country-flags of where the servers are hosted.</li>
+  <li>Cached IP->Country results into memcached</li>
+</ul>
+<h4>2019-03-15: The great "What is sleep?" rewrite!</h4>
+<ul>
+  <li><b>Rewrote and relaunched the application</b></li>
+  <li>Moved server-data to MySQL from DynamoDB</li>
+  <li>Moved session-data to MySQL for later processing</li>
+  <li>Moved player-data to MySQL for later processing</li>
+</ul>
+
+</div>

+ 34 - 0
templates/server.html

@@ -0,0 +1,34 @@
+{{ if .Name }}
+<div class="text-center">
+  <table width="80%" align="center">
+    <tr style="background-color: #f2f2f2">
+      <th valign="top" align="right">Name</th>
+      <td align="left"><img src="https://cdn.glowie.xyz/icons/flags/{{.ISO}}.gif" title="{{.CountryName}}" /> {{ if .Password }}<span title="Server has a password">🔒</span>{{ else }}<span title="Server is public">🌏</span>{{ end }} {{ if .LastUpdate }}<span title="Server is up">✈</span>{{ else }}<span title="Server is down">:-()</span>{{ end }}&nbsp;{{.Name}}</td>
+    </tr>
+    <tr>
+      <th valign="top" align="right">Scenario:</th>
+      <td align="left">{{.MissionName}} ({{.MissionTimeFormatted}})</td>
+    </tr>
+    <tr>
+      <td colspan="2"><img src="http://img.glowie.xyz/?width=900&height=450&g0.expr=gdcsst_players{server=%22{{.IPAddress}}:{{.Port}}%22}&g0.legend=Players%20Online"></td>
+    </tr>
+    <tr style="background-color: #f2f2f2">
+      <th valign="top" align="right">Players&nbsp;(max)</th>
+      <td align="left">{{.Players}} ({{.PlayersMax}})</td>
+    </tr>
+    <tr>
+      <th valign="top" align="right">Description:</th>
+      <td align="left">{{.Description}}</td>
+    </tr>
+    <!--
+    <tr style="background-color: #f2f2f2">
+      <th valign="top" align="right">Related&nbsp;Servers</th>
+      <td align="left"><ul><li><a href="/servers/host.IP_ADDRESS:host.PORT">host.NAME</a></li></ul></td>
+    </tr>
+    -->
+  </table>
+</div>
+
+{{ else }}
+  <div class="text-center">Server not found. Is it on? Try again in a few minutes.</div>
+{{ end }}

+ 27 - 0
templates/servers.html

@@ -0,0 +1,27 @@
+<div class="text-center">
+  <table style="border: 1px solid black;" width="100%" align="center">
+    <tr>
+      <td align="right"><b>Currently Active Servers:</b></td><td align="left">{{.ServerCount}}</td>
+      <td align="right"><b>Players:</b></td><td align="left">{{.PlayerCount}}</td>
+    </tr>
+  </table>
+</div>
+&nbsp;
+<div class="text-center">
+  <table style="border: 1px solid black;" width="100%" align="center">
+    <tr>
+      <td><a href="/servers?sort=Country:DESC">&#9660;</a>&nbsp;<a href="/servers?sort=Country:ASC">&#9650;</a></td>
+      <td><b>Server Name <a href="/servers?sort=Server:DESC">&#9660;</a>&nbsp;<a href="/servers?sort=Server:ASC">&#9650;</a></b></td>
+      <td><b>Scenario<a href="/servers?sort=Scenario:DESC">&#9660;</a>&nbsp;<a href="/servers?sort=Scenario:ASC">&#9650;</a></b></td>
+      <td><a href="/servers?sort=Players:DESC">&#9660;</a>&nbsp;<a href="/servers?sort=Players:ASC">&#9650;</a></td>
+    </tr>
+    {{ range .Servers }}
+    <tr class="servers" style="background-color: #{ loop.cycle('ffffff', 'f2f2f2')}">
+      <td>{{ if .Password }}<span title="Server has a password">🔒</span>{{ else }}<span title="Server is public">🌏</span>{{ end }}</td>
+      <td align="left"><img src="https://cdn.glowie.xyz/icons/flags/{{.ISO}}.gif" title="{{.CountryName}}" />&nbsp;<a href="/servers/{{.IPAddress}}:{{.Port}}" title="{{.Description}}">{{.Name}}</a></td>
+      <td align="left"><a href="/servers/{{.IPAddress}}:{{.Port}}" title="{{.Description}}">{{.MissionName}}</a></td>
+      <td>{{.Players}}</td>
+    </tr>
+    {{ end }}
+  </table>
+</div>

+ 11 - 0
templates/stats.html

@@ -0,0 +1,11 @@
+<div class="text-center">
+  <table width="80%" align="center" border="1">
+    <tr><td align="center"><b>Servers and Players</b></td></tr>
+    <tr><td align="center"><div id="meta-data"></div></td></tr>
+    <tr><td align="center" valign="top"><img src="http://img.glowie.xyz/?width=900&height=450&g0.expr=gdcsst_online{scope=%22players%22}&g0.legend=Players%20Online&g1.expr=gdcsst_online{scope=%22servers%22}&g1.legend=Players%20Online"></div></td></tr>
+    <!--
+    <tr><td align="center" valign="top"><div id="country-data-players" style="height: 1000px"></div></td></tr>
+    <tr><td align="center" valign="top"><div id="country-data-all" style="height: 1500px"></div></td></tr>
+    -->
+  </table>
+</div>

+ 70 - 0
templates/template.html

@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <!-- Required meta tags -->
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+
+    <!-- Bootstrap CSS -->
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
+    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
+    <link rel="shortcut icon" href="https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/google/298/light-bulb_1f4a1.png" />
+    <link rel="icon" type="image/png" href="https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/google/298/light-bulb_1f4a1.png"/>
+    <style media="screen">
+      tr.servers {font-size: 14px;}
+    </style>
+    <title>DCS Server Tracker: {{.Title}}</title>
+    <!-- Global site tag (gtag.js) - Google Analytics -->
+    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-110465380-2"></script>
+    <script>
+      window.dataLayer = window.dataLayer || [];
+      function gtag(){dataLayer.push(arguments);}
+      gtag('js', new Date());
+      gtag('config', 'UA-110465380-2');
+    </script>
+  </head>
+  <body>
+
+    <!-- Navigation -->
+    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
+      <div class="container">
+        <a class="navbar-brand" href="/servers">DCS Server Tracker</a>
+        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
+          <span class="navbar-toggler-icon"></span>
+        </button>
+        <div class="collapse navbar-collapse" id="navbarResponsive">
+          <ul class="navbar-nav ml-auto">
+            <li class="nav-item {{ if .Active_Servers }}active{{end}}"><a class="nav-link" href="/servers">Servers</a></li>
+            <li class="nav-item {{ if .Active_Stats }}active{{end}}"><a class="nav-link" href="/stats">Stats</a></li>
+            <li class="nav-item {{ if .Active_About }}active{{end}}"><a class="nav-link" href="/about">About</a></li>
+          </ul>
+        </div>
+      </div>
+    </nav>
+
+    <!-- Page Content -->
+    <div class="container">
+      <div class="row">
+        <div class="col-lg-12">
+          <p>&nbsp;</p><p>&nbsp;</p>
+          {{.Content}}
+        </div>
+      </div>
+    </div>
+
+    <div class="text-center">
+      <hr width="80%" />
+        <p><small>This page is created and maintained by Glowie.<br>The data may be used freely for non commercial purposes.<br>
+        Contact me on Discord (<i>Glowie#9836</i>) or <a href="mailto:glowie.xyz@protonmail.com">send me an email</a> if you have any questions or requests.<br>This product includes GeoLite2 data created by MaxMind, available from
+<a href="https://www.maxmind.com">https://www.maxmind.com</a>.</small></p>
+      <hr width="80%" />
+      <p>Last update: {{.LastUpdate}}</p>
+    </div>
+
+    <!-- Optional JavaScript -->
+    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
+    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script>
+    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script>
+  </body>
+</html>