forked from proxyee-down-org/proxyee-down
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.修复百度云下载提示未选中文件的BUG 2.新增自动更新脚本功能 3.新增启动是否检查证书配置 4.新增GUI模式下记忆上次窗口的大小及位置
- Loading branch information
Showing
22 changed files
with
310 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package lee.study.down.model; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class PluginBean { | ||
|
||
private float version; | ||
private String desc; | ||
private String content; | ||
} |
63 changes: 63 additions & 0 deletions
63
sniff/src/main/java/lee/study/down/plug/PluginContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package lee.study.down.plug; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.net.JarURLConnection; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
import java.util.Enumeration; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.jar.JarEntry; | ||
import java.util.jar.JarFile; | ||
import lee.study.down.model.PluginBean; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class PluginContent { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(PluginContent.class); | ||
private static final Map<String, PluginBean> content = new ConcurrentHashMap<>(); | ||
|
||
public static void init() { | ||
try { | ||
URL url = Thread.currentThread().getContextClassLoader() | ||
.getResource("hookjs"); | ||
URLConnection connection = url.openConnection(); | ||
if (connection instanceof JarURLConnection) { | ||
JarURLConnection jarURLConnection = (JarURLConnection) connection; | ||
JarFile jarFile = jarURLConnection.getJarFile(); | ||
Enumeration<JarEntry> entries = jarFile.entries(); | ||
while(entries.hasMoreElements()){ | ||
JarEntry entry = entries.nextElement(); | ||
if (entry.getName().matches("^.*hookjs/[^/]+$")) { | ||
String key = entry.getName().substring(entry.getName().indexOf("hookjs/")+7); | ||
update(key, PluginUtil.getPluginBean(jarFile.getInputStream(entry))); | ||
} | ||
} | ||
jarFile.close(); | ||
} else { | ||
File file = new File(url.getPath()); | ||
for (File hook : file.listFiles()) { | ||
update(hook.getName(), PluginUtil.getPluginBean(new FileInputStream(hook))); | ||
} | ||
} | ||
} catch (Exception e) { | ||
LOGGER.error("plugin content init error",e); | ||
} | ||
} | ||
|
||
public static void update(String key, PluginBean value) { | ||
content.put(key, value); | ||
} | ||
|
||
public static PluginBean get(String key) { | ||
return content.get(key); | ||
} | ||
|
||
public static void main(String[] args) throws IOException, URISyntaxException { | ||
init(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package lee.study.down.plug; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import lee.study.down.model.PluginBean; | ||
|
||
public class PluginUtil { | ||
|
||
public static PluginBean getPluginBean(InputStream inputStream, float currentVersion) | ||
throws IOException { | ||
PluginBean pluginBean = new PluginBean(); | ||
try ( | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")) | ||
) { | ||
StringBuilder sb = new StringBuilder(); | ||
String line; | ||
int num = 1; | ||
while ((line = reader.readLine()) != null) { | ||
if (num == 1) { | ||
//版本号 | ||
float newVersion = Float.parseFloat(line.substring(2)); | ||
if (newVersion > currentVersion) { | ||
pluginBean.setVersion(newVersion); | ||
} else { | ||
return null; | ||
} | ||
num++; | ||
} | ||
sb.append(line + "\r\n"); | ||
} | ||
pluginBean.setContent(sb.toString()); | ||
} | ||
return pluginBean; | ||
} | ||
|
||
public static PluginBean getPluginBean(InputStream inputStream) | ||
throws IOException { | ||
return getPluginBean(inputStream, -1F); | ||
} | ||
} |
Oops, something went wrong.