Giter Site home page Giter Site logo

vpnblocker's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vpnblocker's Issues

Be careful about kicking players based on ID

I need to be careful about kicking players. While in this example, it looks like a partial join, don't kick solely based on the ID and confirm we're kicking the same player.

Because API calls are delayed, if a person leaves and another person joins with the same ID while the API call is happening the wrong person will get kicked.

2017-08-11 00:19:56: Player Green Manalishi [1] has joined from [redacted 1] at 2017-08-11 00:19:56 with token "940804132"
2017-08-11 00:19:58: Player Green Manalishi [1] removed at 2017-08-11 00:19:58: unidentified
2017-08-11 00:20:05: Player [1] accept() from [redacted 2]:36490 on 7
2017-08-11 00:20:05: Player [1] submitted reverse resolve query
2017-08-11 00:20:05: Player [1] resolved to [redacted 2 host]
2017-08-11 00:20:05: Player slot 1 inbound UDP up [redacted 2]:36490 actual 36490
2017-08-11 00:20:06: Player 1 outbound UDP up
2017-08-11 00:20:07: Player  [1] removed at 2017-08-11 00:20:07: Your host has been detected as a VPN.
2017-08-11 00:20:07: NOTICE :: VPN Blocker :: Player Green Manalishi ([redacted 1]) removed for VPN usage

Support for Ubuntu 18.04+

Going off of allejo/LeagueOverseer#51, in order to compile on Ubuntu 18.04+ and likely whatever the new Debian LTS is, you must install libjson-c-dev and apply the following changes.

diff --git a/Makefile.am b/Makefile.am
index 871946d..a24a552 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,7 +2,7 @@ lib_LTLIBRARIES = VPNBlocker.la

 VPNBlocker_la_SOURCES = VPNBlocker.cpp JsonObject/JsonObject.h JsonObject/JsonObject.cpp
 VPNBlocker_la_CPPFLAGS= -I$(top_srcdir)/include -I$(top_srcdir)/plugins/plugin_utils
-VPNBlocker_la_LDFLAGS = -module -avoid-version -shared -ljson
+VPNBlocker_la_LDFLAGS = -module -avoid-version -shared -ljson-c
 VPNBlocker_la_LIBADD = $(top_builddir)/plugins/plugin_utils/libplugin_utils.la

 AM_CPPFLAGS = $(CONF_CPPFLAGS)
diff --git a/VPNBlocker.cpp b/VPNBlocker.cpp
index 948f837..34a152e 100644
--- a/VPNBlocker.cpp
+++ b/VPNBlocker.cpp
@@ -21,7 +21,7 @@ THE SOFTWARE.
 */

 #include <cstdarg>
-#include <json/json.h>
+#include <json-c/json.h>
 #include <queue>

 #include "bzfsAPI.h"
diff --git a/JsonObject/JsonObject.cpp b/JsonObject/JsonObject.cpp
index 42f1222..e8ea7ba 100644
--- a/JsonObject.cpp
+++ b/JsonObject.cpp
@@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 */

-#include <json/json.h>
+#include <json-c/json.h>
 #include <map>
 #include <string>
 #include <vector>
diff --git a/JsonObject/JsonObject.h b/JsonObject/JsonObject.h
index 95b8394..43a6461 100644
--- a/JsonObject.h
+++ b/JsonObject.h
@@ -23,7 +23,7 @@ THE SOFTWARE.
 #ifndef __JsonObject_H_
 #define __JsonObject_H_

-#include <json/json.h>
+#include <json-c/json.h>
 #include <string>
 #include <vector>
 #include <map>

While I investigate a way of possibly maintaining backward-compatibility with Ubuntu 16.04 LTS, these changes need to be made manually.

libjson0-dev has libjson-c-dev as a dependency, so I would hope that a swap to json-c in the #include would be ok and potentially -ljson too?

For now, consider this plug-in untested on 18.04+

Add `/vpnunblock` command

In case an IP is marked as a VPN, there should be a way to remove an IP from the plugin cache of VPN IPs

Add support for nested JSON response

In some APIs, such as AbuseIPDB, the JSON response has some nested data. There's no way to currently access nested values via our custom API configurations. The proposed syntax is to add support for dot notation of nested information.

For example, given the following JSON response:

{
    "data": {
      "ipAddress": "118.25.6.39",
      "isPublic": true,
      "ipVersion": 4,
      "isWhitelisted": false,
      "abuseConfidenceScore": 100,
      "countryCode": "CN",
      "countryName": "China",
      "usageType": "Data Center/Web Hosting/Transit",
      "isp": "Tencent Cloud Computing (Beijing) Co. Ltd",
      "domain": "tencent.com",
      "hostnames": [],
      "totalReports": 1,
      "numDistinctUsers": 1,
      "lastReportedAt": "2018-12-20T20:55:14+00:00",
      "reports": [
        {
          "reportedAt": "2018-12-20T20:55:14+00:00",
          "comment": "Dec 20 20:55:14 srv206 sshd[13937]: Invalid user oracle from 118.25.6.39",
          "categories": [
            18,
            22
          ],
          "reporterId": 1,
          "reporterCountryCode": "US",
          "reporterCountryName": "United States"
        }
      ]
    }
  }

A key of data.usageType would allow us to access the "Data Center/Web Hosting/Transit" value.

Explore new JSON implementation

Though I doubt that the libjson-c-dev will change names again, the fact remains that it's not easy to use and requires my JsonObject wrapper to make JSON usable.

There's a new contender over at nlohmann/json that:

  • is distributed as a single .hpp file meaning it can be dropped in this repo and you'll never have to worry about external dependencies for compiling this plug-in ever again
  • allows JSON to be accessed like a first-class data type in C++
  • does not require linking in any of our build systems

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.