mirror of
https://git.funtimes909.xyz/ServerSeekerV2/ServerSeekerV2.git
synced 2026-10-11 09:58:10 +08:00
Code cleanup
This commit is contained in:
4 files changed
+18
-17
No files matched your search
+3
-4
@@ -11,7 +11,6 @@ use config::load_config;
|
||||
use indicatif::ProgressStyle;
|
||||
use sqlx::postgres::{PgConnectOptions, PgPoolOptions};
|
||||
use sqlx::ConnectOptions;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use tracing::log::LevelFilter;
|
||||
use tracing::{error, info};
|
||||
@@ -27,9 +26,9 @@ enum Mode {
|
||||
#[clap(about = "Scans the internet for minecraft servers and indexes them")]
|
||||
#[clap(rename_all = "kebab-case")]
|
||||
struct Args {
|
||||
#[clap(help = "Specifies the mode to run (Default: discovery)")]
|
||||
#[clap(help = "Specifies the mode to run")]
|
||||
#[clap(default_value = "rescanner")]
|
||||
#[clap(long, short = 'd')]
|
||||
#[clap(long, short = 'm')]
|
||||
mode: Mode,
|
||||
|
||||
#[clap(help = "Specifies the location of the config file")]
|
||||
@@ -62,7 +61,7 @@ async fn main() {
|
||||
.log_slow_statements(LevelFilter::Off, Duration::from_secs(5));
|
||||
|
||||
let pool = match PgPoolOptions::new()
|
||||
.min_connections(5)
|
||||
// .min_connections(5)
|
||||
.connect_with(options)
|
||||
.await
|
||||
{
|
||||
|
||||
+9
-9
@@ -1,5 +1,5 @@
|
||||
use crate::config::PlayerTracking;
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Debug, sqlx::Type)]
|
||||
@@ -22,7 +22,7 @@ pub enum ServerType {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct Server {
|
||||
pub version: Version,
|
||||
pub favicon: Option<String>,
|
||||
@@ -39,14 +39,14 @@ pub struct Server {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone, Debug)]
|
||||
pub struct Version {
|
||||
pub name: String,
|
||||
pub protocol: i32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone, Debug)]
|
||||
#[serde(untagged)]
|
||||
pub enum Description {
|
||||
Plain(String),
|
||||
@@ -54,7 +54,7 @@ pub enum Description {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone, Debug)]
|
||||
pub struct DescriptionComplex {
|
||||
pub text: Option<String>,
|
||||
pub color: Option<String>,
|
||||
@@ -72,7 +72,7 @@ pub struct DescriptionComplex {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone, Debug)]
|
||||
pub struct Players {
|
||||
pub max: i32,
|
||||
pub online: i32,
|
||||
@@ -80,20 +80,20 @@ pub struct Players {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone, Debug)]
|
||||
pub struct Player {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone, Debug)]
|
||||
pub struct ForgeData {
|
||||
pub mods: Vec<Mod>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone, Debug)]
|
||||
pub struct Mod {
|
||||
#[serde(rename = "modId")]
|
||||
pub id: String,
|
||||
|
||||
+4
-2
@@ -60,13 +60,15 @@ pub async fn handle_scan_results(
|
||||
let bar = ProgressBar::new(completed_servers.len() as u64).with_style(style);
|
||||
|
||||
for server in completed_servers.into_iter().progress_with(bar) {
|
||||
database::update(
|
||||
if let Err(e) = database::update(
|
||||
server.server,
|
||||
&(server.ip, server.port),
|
||||
&mut *transaction.lock().await,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
{
|
||||
warn!("Failed to update database: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
Arc::try_unwrap(transaction)
|
||||
|
||||
Reference in new issue
Block a user