mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-24 08:24:50 +00:00
trunk contents moved to root
This commit is contained in:
64
libsrc/jpproxy/src/com/jpexs/proxy/Main.java
Normal file
64
libsrc/jpproxy/src/com/jpexs/proxy/Main.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package com.jpexs.proxy;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main
|
||||
{
|
||||
|
||||
public static final String REPLACEMENTSFILE = "." + File.separator + "config" + File.separator + "replacements.ini";
|
||||
public static boolean DEBUG_MODE = false;
|
||||
|
||||
public static void main(String[] argv)
|
||||
{
|
||||
List<Replacement> replacements = new ArrayList<Replacement>();
|
||||
if ((new File(REPLACEMENTSFILE)).exists()) {
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new FileReader(REPLACEMENTSFILE));
|
||||
String s = "";
|
||||
while ((s = br.readLine()) != null) {
|
||||
String fileName = br.readLine();
|
||||
if (fileName == null) break;
|
||||
fileName = fileName.replaceAll("[\\\\/]", File.separator);
|
||||
Replacement r = new Replacement(s, fileName);
|
||||
if (DEBUG_MODE) {
|
||||
System.out.println("Added Replacement: " + r.urlPattern + " => " + r.targetFile);
|
||||
}
|
||||
replacements.add(r);
|
||||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
if (DEBUG_MODE) {
|
||||
System.out.println("WARNING:REPLACEMENTS FILE NOT FOUND.");
|
||||
}
|
||||
}
|
||||
Server.startServer(ProxyConfig.port, replacements, new ArrayList<String>(), new CatchedListener() {
|
||||
|
||||
/**
|
||||
* Method called when specified contentType is received
|
||||
*
|
||||
* @param contentType Content type
|
||||
* @param url URL of the method
|
||||
* @param data Data stream
|
||||
*/
|
||||
public void catched(String contentType, String url, InputStream data) {
|
||||
}
|
||||
}, new ReplacedListener() {
|
||||
|
||||
public void replaced(Replacement replacement, String url, String contentType) {
|
||||
if (DEBUG_MODE) {
|
||||
System.out.println("REPLACED:" + url + " (Content-type:" + contentType + ") WITH FILE " + replacement.targetFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user