Skip to content

Commit

Permalink
Merge pull request #11 from v4Guard/develop
Browse files Browse the repository at this point in the history
v4Guard Plugin v1.1.2b
  • Loading branch information
samfces authored Sep 1, 2022
2 parents 041ba00 + 81591b6 commit ed90777
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.v4guard</groupId>
<artifactId>v4guard-plugin</artifactId>
<version>1.1.2</version>
<version>1.1.2b</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void onPreLogin(String username, Object event) {
String address = e.getConnection().getAddress().getAddress().getHostAddress();
v4GuardBungee.getCoreInstance().getCheckManager().cleanupChecks(username);

if(v4GuardBungee.getCoreInstance().getBackendConnector() == null|| v4GuardBungee.getCoreInstance().getBackendConnector().getSettings() == null) return;
final boolean wait = (boolean) v4GuardBungee.getCoreInstance().getBackendConnector().getSettings().getOrDefault("waitResponse", false);
if (wait) {
e.registerIntent(v4GuardBungee.getV4Guard());
Expand All @@ -33,7 +34,7 @@ public void onPreLogin(String username, Object event) {
@Override
public void complete(boolean nameIsValid) {
if(nameIsValid){
new CompletableIPCheckTask(address, e.getConnection().getName(), e.getConnection().getVersion()){
new CompletableIPCheckTask(address, e.getConnection().getName(), e.getConnection().getVersion(), e.getConnection().getVirtualHost().getHostString()){
@Override
public void complete() {
VPNCheck check = this.getCheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class CompletableIPCheckTask implements CompletableTask {
private final ConcurrentHashMap<String, Object> data;
private VPNCheck check;

public CompletableIPCheckTask(String address, String username, int version) {
public CompletableIPCheckTask(String address, String username, int version, String virtualHost) {
this.address = address;
this.username = username;
this.version = version;
Expand All @@ -34,6 +34,7 @@ public CompletableIPCheckTask(String address, String username, int version) {
doc.put("username", this.username);
doc.put("version", this.version);
doc.put("timestamp", System.currentTimeMillis());
doc.put("virtualHost", virtualHost);
v4GuardCore.getInstance().getBackendConnector().send("check", doc);
new Timer().schedule(new TimerTask(){

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/v4guard/plugin/core/v4GuardCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class v4GuardCore {
private BackendConnector backendConnector;
private CheckManager checkManager;

public static final String pluginVersion = "1.1.2";
public static final String pluginVersion = "1.1.2b";

private boolean debug = false;
private v4GuardMode pluginMode = v4GuardMode.UNKNOWN;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ public void onPreLogin(String username, Object event) {
String address = e.getAddress().getHostAddress();
v4GuardSpigot.getCoreInstance().getCheckManager().cleanupChecks(username);

if(v4GuardSpigot.getCoreInstance().getBackendConnector() == null|| v4GuardSpigot.getCoreInstance().getBackendConnector().getSettings() == null) return;
final boolean wait = (boolean) v4GuardSpigot.getCoreInstance().getBackendConnector().getSettings().getOrDefault("waitResponse", false);;
new CompletableNameCheckTask(e.getName()) {
@Override
public void complete(boolean nameIsValid) {
if(nameIsValid){
new CompletableIPCheckTask(address, e.getName(), -1) {
new CompletableIPCheckTask(address, e.getName(), -1, "spigot") {
@Override
public void complete() {
new BukkitRunnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public void onPreLoginWithContinuation(Object event, Continuation continuation)
String address = e.getConnection().getRemoteAddress().getAddress().getHostAddress();
v4GuardVelocity.getCoreInstance().getCheckManager().cleanupChecks(e.getUsername());

final boolean wait = (boolean) v4GuardVelocity.getCoreInstance().getBackendConnector().getSettings().getOrDefault("waitResponse", false);;
if(v4GuardVelocity.getCoreInstance().getBackendConnector() == null|| v4GuardVelocity.getCoreInstance().getBackendConnector().getSettings() == null) return;
final boolean wait = (boolean) v4GuardVelocity.getCoreInstance().getBackendConnector().getSettings().getOrDefault("waitResponse", false);
if (!wait) {
if(continuation != null) continuation.resume();
return;
Expand All @@ -41,6 +42,7 @@ public void onPreLogin(String username, Object event) {
String address = e.getConnection().getRemoteAddress().getAddress().getHostAddress();
v4GuardVelocity.getCoreInstance().getCheckManager().cleanupChecks(e.getUsername());

if(v4GuardVelocity.getCoreInstance().getBackendConnector() == null|| v4GuardVelocity.getCoreInstance().getBackendConnector().getSettings() == null) return;
final boolean wait = (boolean) v4GuardVelocity.getCoreInstance().getBackendConnector().getSettings().getOrDefault("waitResponse", false);;
if(wait) return;
doChecks(e, null);
Expand Down Expand Up @@ -81,7 +83,8 @@ private void doChecks(PreLoginEvent e, Continuation continuation) {
@Override
public void complete(boolean nameIsValid) {
if(nameIsValid){
new CompletableIPCheckTask(e.getConnection().getRemoteAddress().getAddress().getHostAddress(), e.getUsername(), e.getConnection().getProtocolVersion().getProtocol()){
new CompletableIPCheckTask(e.getConnection().getRemoteAddress().getAddress().getHostAddress(), e.getUsername(), e.getConnection().getProtocolVersion().getProtocol(),
e.getConnection().getVirtualHost().isPresent() ? e.getConnection().getVirtualHost().get().getHostString() : "notFound") {
@Override
public void complete() {
VPNCheck check = this.getCheck();
Expand Down

0 comments on commit ed90777

Please sign in to comment.