Skip to content

Commit

Permalink
fix: Require a GeoIP private key to download the database and disable…
Browse files Browse the repository at this point in the history
… downloading by default

closes #119
  • Loading branch information
4drian3d committed Nov 14, 2023
1 parent b0b6c41 commit c42eab8
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 66 deletions.
126 changes: 63 additions & 63 deletions core/build.gradle.kts
Expand Up @@ -64,66 +64,66 @@ sourceSets {
}

// Publish to Maven Central
/*publishing {
publications {
create<MavenPublication>("maven") {
repositories {
maven {
credentials(PasswordCredentials::class)
val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
if (project.version.toString().endsWith("SNAPSHOT")) {
name = "SonatypeSnapshots"
setUrl(snapshots)
} else {
name = "OSSRH"
setUrl(central)
}
}
}
from(components["java"])
pom {
url.set("https://github.com/4drian3d/EpicGuard")
licenses {
license {
name.set("GNU General Public License version 3 or later")
url.set("https://opensource.org/licenses/GPL-3.0")
}
}
scm {
connection.set("scm:git:https://github.com/4drian3d/EpicGuard.git")
developerConnection.set("scm:git:ssh://git@github.com/4drian3d/EpicGuard.git")
url.set("https://github.com/4drian3d/EpicGuard")
}
developers {
developer {
id.set("4drian3d")
name.set("Adrian Gonzales")
email.set("adriangonzalesval@gmail.com")
}
developer {
id.set("awumii")
email.set("awumii@protonmail.com")
}
}
issueManagement {
name.set("GitHub")
url.set("https://github.com/4drian3d/EpicGuard/issues")
}
ciManagement {
name.set("GitHub Actions")
url.set("https://github.com/4drian3d/EpicGuard/actions")
}
name.set(project.name)
description.set(project.description)
url.set("https://github.com/4drian3d/EpicGuard")
}
artifactId = "epicguard-api"
}
}
}
signing {
useGpgCmd()
sign(configurations.archives.get())
sign(publishing.publications["maven"])
}*/
//publishing {
// publications {
// create<MavenPublication>("maven") {
// repositories {
// maven {
// credentials(PasswordCredentials::class)
// val central = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
// val snapshots = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
// if (project.version.toString().endsWith("SNAPSHOT")) {
// name = "SonatypeSnapshots"
// setUrl(snapshots)
// } else {
// name = "OSSRH"
// setUrl(central)
// }
// }
// }
// from(components["java"])
// pom {
// url.set("https://github.com/4drian3d/EpicGuard")
// licenses {
// license {
// name.set("GNU General Public License version 3 or later")
// url.set("https://opensource.org/licenses/GPL-3.0")
// }
// }
// scm {
// connection.set("scm:git:https://github.com/4drian3d/EpicGuard.git")
// developerConnection.set("scm:git:ssh://git@github.com/4drian3d/EpicGuard.git")
// url.set("https://github.com/4drian3d/EpicGuard")
// }
// developers {
// developer {
// id.set("4drian3d")
// name.set("Adrian Gonzales")
// email.set("adriangonzalesval@gmail.com")
// }
// developer {
// id.set("awumii")
// email.set("awumii@protonmail.com")
// }
// }
// issueManagement {
// name.set("GitHub")
// url.set("https://github.com/4drian3d/EpicGuard/issues")
// }
// ciManagement {
// name.set("GitHub Actions")
// url.set("https://github.com/4drian3d/EpicGuard/actions")
// }
// name.set(project.name)
// description.set(project.description)
// url.set("https://github.com/4drian3d/EpicGuard")
// }
// artifactId = "epicguard-api"
// }
// }
//}
//signing {
// useGpgCmd()
// sign(configurations.archives.get())
// sign(publishing.publications["maven"])
//}
Expand Up @@ -424,7 +424,10 @@ How often (in seconds) the plugin should check if amount of connections
private boolean updateChecker = true;

@Comment("Set to false to not try to download the latest geolocation database.")
private boolean geoDatabaseDownload = true;
private boolean geoDatabaseDownload = false;

@Comment("MaxMind key for downloading the GeoIP database")
private String geoDatabaseKey = "";

@Comment("""
Time in minutes before auto-saving data.
Expand Down Expand Up @@ -458,6 +461,10 @@ public boolean geoDatabaseDownload() {
return this.geoDatabaseDownload;
}

public String getGeoDatabaseKey() {
return this.geoDatabaseKey;
}

public long autoSaveInterval() {
return this.autoSaveInterval;
}
Expand Down
Expand Up @@ -63,14 +63,15 @@ public GeoManager(EpicGuard epicGuard) {

try {
if (epicGuard.config().misc().geoDatabaseDownload()) {
final String geoIpKey = epicGuard.config().misc().getGeoDatabaseKey();
this.downloadDatabase(
countryDatabase,
countryArchive,
"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=LARAgQo3Fw7W9ZMS&suffix=tar.gz");
"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key="+geoIpKey+"&suffix=tar.gz");
this.downloadDatabase(
cityDatabase,
cityArchive,
"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=LARAgQo3Fw7W9ZMS&suffix=tar.gz");
"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key="+geoIpKey+"&suffix=tar.gz");

} else {
epicGuard.logger().info("GeoIP database download is disabled, skipping...");
Expand Down

0 comments on commit c42eab8

Please sign in to comment.