some tweaks

This commit is contained in:
ZeroEpoch1969 2019-01-21 14:43:25 -07:00
parent 1e642ae243
commit dded19e254
No known key found for this signature in database
GPG key ID: A7BAB4E14F089CF3
13 changed files with 101 additions and 7 deletions

4
.gitignore vendored
View file

@ -1 +1,3 @@
/target/ /target
.idea/workspace.xml

1
.idea/.name Normal file
View file

@ -0,0 +1 @@
Capatchafy

View file

@ -0,0 +1,38 @@
<component name="ArtifactManager">
<artifact type="jar" build-on-make="true" name="Capatchafy">
<output-path>$PROJECT_DIR$/target/</output-path>
<root id="archive" name="Capatchafy.jar">
<element id="module-output" name="Capatchafy" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/grizzly/grizzly-http-server/2.4.0/grizzly-http-server-2.4.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/commons-io/commons-io/2.6/commons-io-2.6.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/el/javax.el-api/3.0.0/javax.el-api-3.0.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/enterprise/cdi-api/2.0/cdi-api-2.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/inject/javax.inject/1/javax.inject-1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/interceptor/javax.interceptor-api/1.2/javax.interceptor-api-1.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/json/bind/javax.json.bind-api/1.0/javax.json.bind-api-1.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/json/javax.json-api/1.1/javax.json-api-1.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/ws/rs/javax.ws.rs-api/2.1/javax.ws.rs-api-2.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/eclipse/yasson/1.0/yasson-1.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/grizzly/grizzly-framework/2.4.0/grizzly-framework-2.4.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/grizzly/grizzly-http/2.4.0/grizzly-http-2.4.0.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/hk2/external/aopalliance-repackaged/2.5.0-b42/aopalliance-repackaged-2.5.0-b42.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/hk2/external/javax.inject/2.5.0-b42/javax.inject-2.5.0-b42.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-api/2.5.0-b42/hk2-api-2.5.0-b42.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-locator/2.5.0-b42/hk2-locator-2.5.0-b42.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/hk2/hk2-utils/2.5.0-b42/hk2-utils-2.5.0-b42.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/hk2/osgi-resource-locator/1.0.1/osgi-resource-locator-1.0.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/jersey/containers/jersey-container-grizzly2-http/2.26/jersey-container-grizzly2-http-2.26.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-client/2.26/jersey-client-2.26.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-common/2.26/jersey-common-2.26.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/jersey/core/jersey-server/2.26/jersey-server-2.26.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/jersey/inject/jersey-hk2/2.26/jersey-hk2-2.26.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-jaxb/2.26/jersey-media-jaxb-2.26.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/jersey/media/jersey-media-json-binding/2.26/jersey-media-json-binding-2.26.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/glassfish/javax.json/1.1/javax.json-1.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/javassist/javassist/3.22.0-CR2/javassist-3.22.0-CR2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/javax/activation/activation/1.1.1/activation-1.1.1.jar" path-in-jar="/" />
</root>
</artifact>
</component>

13
.idea/compiler.xml Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Capatchafy" />
</profile>
</annotationProcessing>
</component>
</project>

6
.idea/encodings.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
</component>
</project>

14
.idea/misc.xml Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View file

@ -16,6 +16,10 @@
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository>
<id>maven-central</id>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories> </repositories>
<dependencyManagement> <dependencyManagement>
@ -49,6 +53,11 @@
<version>4.9</version> <version>4.9</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>

View file

@ -69,7 +69,7 @@ public class Capatchafy extends JavaPlugin
Bukkit.getLogger().severe("[Capatchafy] The 'security-level' config field was not between 1 and 3. Setting security level to 2."); Bukkit.getLogger().severe("[Capatchafy] The 'security-level' config field was not between 1 and 3. Setting security level to 2.");
} }
enabled = configs.config.getBoolean("always-on"); enabled = configs.config.getBoolean("always-on");
server = HttpdServer.startServer(); server = HttpdServer.getServer();
listeners.setURLMessage(); listeners.setURLMessage();
Bukkit.getLogger().info("[Capatchafy] Running in security level " + securityLevel + "."); Bukkit.getLogger().info("[Capatchafy] Running in security level " + securityLevel + ".");
} }
@ -81,7 +81,6 @@ public class Capatchafy extends JavaPlugin
{ {
return; //Prevents errors on the first startup. return; //Prevents errors on the first startup.
} }
try try
{ {
configs.saveNames(true); configs.saveNames(true);
@ -91,7 +90,7 @@ public class Capatchafy extends JavaPlugin
{ {
e.printStackTrace(); e.printStackTrace();
} }
server.stop(); server.shutdownNow();
configs.ipList.clear(); //TODO See if removing this line affects functionality. configs.ipList.clear(); //TODO See if removing this line affects functionality.
} }
} }

View file

@ -139,6 +139,11 @@ public class Configuration
return config.getString("hostname"); return config.getString("hostname");
} }
public String getBindingIP()
{
return config.getString("binding-ip");
}
public String getPort() public String getPort()
{ {
return config.getString("port"); return config.getString("port");

View file

@ -58,6 +58,10 @@ public class Listeners implements Listener
String ip = event.getAddress().toString().replaceAll("/", ""); String ip = event.getAddress().toString().replaceAll("/", "");
if (!Capatchafy.configs.isAuthorized(ip)) if (!Capatchafy.configs.isAuthorized(ip))
{ {
if (url == null)
{
setURLMessage();
}
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + "" + ChatColor.BOLD + "Yikes, we're under attack! Please solve the capatcha.\n" + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + "" + ChatColor.BOLD + "Yikes, we're under attack! Please solve the capatcha.\n" +
ChatColor.WHITE + "Please go to " + ChatColor.GOLD + url + ChatColor.WHITE + " in your web browser and solve the capatcha.\n" + ChatColor.WHITE + "Please go to " + ChatColor.GOLD + url + ChatColor.WHITE + " in your web browser and solve the capatcha.\n" +
"Once solved successfully, you will be able to join."); "Once solved successfully, you will be able to join.");

View file

@ -27,8 +27,8 @@ import org.glassfish.jersey.server.ResourceConfig;
public class HttpdServer public class HttpdServer
{ {
public static final String BASE_URI = "http://" + Capatchafy.configs.getHostname() + ":" + Capatchafy.configs.getPort() + "/"; public static final String BASE_URI = "http://" + (Capatchafy.configs.getBindingIP().isEmpty() ? Capatchafy.configs.getHostname() : Capatchafy.configs.getBindingIP()) + ":" + Capatchafy.configs.getPort() + "/";
public static HttpServer startServer() public static HttpServer getServer()
{ {
final ResourceConfig rc = new ResourceConfig().packages("me.hockey.capatchafy.httpd"); final ResourceConfig rc = new ResourceConfig().packages("me.hockey.capatchafy.httpd");
final Set<Class<?>> classes = new HashSet<Class<?>>(); final Set<Class<?>> classes = new HashSet<Class<?>>();

View file

@ -11,6 +11,9 @@ always-on: false
#3 - Strict. You must verify each time you join. #3 - Strict. You must verify each time you join.
security-level: 2 security-level: 2
# IP to bind the httpd to, leave blank to use hostname
binding-ip: ''
#Hostname - The ip that you want Capatchafy to listen on goes here. #Hostname - The ip that you want Capatchafy to listen on goes here.
#You don't HAVE to change this, but leaving it will cause problems when a player tries to find the link to the capatcha. #You don't HAVE to change this, but leaving it will cause problems when a player tries to find the link to the capatcha.
hostname: 127.0.0.1 hostname: 127.0.0.1

View file

@ -1,5 +1,5 @@
name: Capatchafy name: Capatchafy
version: 1.1.0 version: 1.1.0-TF
main: me.hockey.capatchafy.Capatchafy main: me.hockey.capatchafy.Capatchafy
commands: commands: