Skip to content

Commit

Permalink
Update version check, and fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
layou233 committed Feb 27, 2021
1 parent 510d9ba commit d5ec95a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/main/java/lau/ZBChecker/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class Main {
public static boolean isCloudMode = false;
public static transient Log log = LogFactory.getLog("Main");
public static long totalTriedTimes = 0;
public static List<String> proxyList = new ArrayList<String>();
public static List<String> comboList = new ArrayList<String>();
public static List<String> proxyList = new ArrayList<>();
public static List<String> comboList = new ArrayList<>();
public static Counter counter = new Counter();
public static String fileFolderName = "./results/" + (new Date()).toString().replace(':', '-');
public static int totalThreads = 0;
Expand All @@ -41,6 +41,7 @@ public static void main(String[] args) {
" / /__ | |_| | | |___ | | | | | |___ | |___ | | \\ \\ | |___ | | \\ \\ \n" +
"/_____| |_____/ \\_____| |_| |_| |_____| \\_____| |_| \\_\\ |_____| |_| \\_\\|@ \n" +
"@|yellow By Github@layou233|@\n"));
UpdateCheck.updateCheck();
config.loadConfig();
String text = LoadFileResource.loadFile("combos.txt");
if (!Objects.equals(text, "")) isCloudMode = true;
Expand All @@ -60,8 +61,8 @@ public static void main(String[] args) {
log.fatal(config.proxyFile.getName() + " is not found. Please recheck your proxy file name!");
System.exit(0);
}
System.out.println(ansi().render("@|green Successfully loaded " + Main.proxyList.size() + " proxies.|@"));
}
System.out.println(ansi().render("@|green Successfully loaded " + Main.proxyList.size() + " proxies.|@"));

// Load combos
try {
Expand All @@ -71,7 +72,7 @@ public static void main(String[] args) {
log.fatal(config.comboFile.getName() + " is not found. Please recheck your combo file name!");
System.exit(0);
}
System.out.println(ansi().render("@|green Successfully loaded " + comboList.size() + " combos.|@\n"));
log.warn(ansi().render("@|green Successfully loaded " + comboList.size() + " combos.|@\n"));

// Judge if there is no proxy/combo
if (comboList.size() == 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/lau/ZBChecker/UpdateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public static void updateCheck() {
System.out.println("Version " + version);
String remoteVersion;
try {
CloseableHttpResponse httpClient = HttpClients.createDefault().execute(new HttpGet("https://raw.githubusercontent.com/layou233/NovelDL/master/src/main/resources/version.txt"));
CloseableHttpResponse httpClient = HttpClients.createDefault().execute(new HttpGet("https://raw.githubusercontent.com/layou233/ZBChecker/master/src/main/resources/version.txt"));
remoteVersion = EntityUtils.toString(httpClient.getEntity(), "UTF-8");
httpClient.close();
} catch (IOException e) {
System.out.println("FAILED TO CHECK FOR UPDATES.\n" +
"You can check it yourself at https://github.com/layou233/NovelDL/releases\n");
"You can check it yourself at https://github.com/layou233/ZBChecker/releases\n");
return;
}
if (version.equals(remoteVersion))
System.out.println("Nice! You are using the latest version!\n");
else System.out.println("THE ZBChecker YOU ARE CURRENTLY USING HAS BEEN OUTDATED!\n" +
"Check out newer versions at https://github.com/layou233/NovelDL/releases\n");
"Check out newer versions at https://github.com/layou233/ZBChecker/releases\n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
import java.io.IOException;
import java.util.Arrays;

import static org.fusesource.jansi.Ansi.ansi;

public class RefreshApiProxyThread extends Thread {
protected transient static Log log = LogFactory.getLog("RefreshApiProxyThread");
public static void loadProxyFromApi() {
Log log = LogFactory.getLog("RefreshApiProxyThread");
try {
Main.proxyList = Arrays.asList(Get.get(Main.config.proxyApi, null, null).trim().replace("\r\n", "\n").replace("\r", "\n").split("\n"));
} catch (IOException e) {
e.printStackTrace();
log.error("Fail to load proxies from API. Please restart.");
log.error(ansi().render("@|red Fail to load proxies from API. Please restart.|@"));
System.exit(0);
}
log.info("Successfully loaded " + Main.proxyList.size() + " proxies.\n");
log.warn(ansi().render("@|green Successfully loaded " + Main.proxyList.size() + " proxies |@@|cyan from API.|@"));
}

@Override
Expand Down

0 comments on commit d5ec95a

Please sign in to comment.