Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 312cd2d

Browse files
committed
增加本地固定节点配置
1 parent 424f324 commit 312cd2d

File tree

6 files changed

+198
-138
lines changed

6 files changed

+198
-138
lines changed

HtmlUnit-Demo/.idea/workspace.xml

Lines changed: 126 additions & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

HtmlUnit-Demo/src/main/java/cn/mrdear/Setting.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package cn.mrdear;
22

3+
import java.util.List;
4+
5+
import cn.mrdear.model.ConfigsBean;
6+
37
/**
48
* @author Niu Li
59
* @date 2016/10/11
@@ -12,6 +16,11 @@ public class Setting
1216
*/
1317

1418
private String sspath;
19+
/**
20+
* 本地节点配置
21+
*/
22+
private List<ConfigsBean> local;
23+
1524

1625
public String getSspath() {
1726
return sspath;
@@ -20,4 +29,13 @@ public String getSspath() {
2029
public void setSspath(String sspath) {
2130
this.sspath = sspath;
2231
}
32+
33+
public List<ConfigsBean> getLocal() {
34+
return local;
35+
}
36+
37+
public void setLocal(List<ConfigsBean> local) {
38+
this.local = local;
39+
}
40+
2341
}

HtmlUnit-Demo/src/main/java/cn/mrdear/core/Main.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/**
2121
* 使用步骤
2222
* 1.配置setting.json里面的ss配置文件地址,如果有的话,会读取,然后值修改里面的节点配置,没有的话则创建新文件,按照默认配置来
23+
* 另外可以可以在Setting里面配置自己拥有的固定节点.
2324
* 2.启动main代码测试
2425
* 3.打包为jar运行
2526
* 4.配合doc里面的bat脚本,可以很大的简化你的运行.
@@ -45,14 +46,21 @@ public static void main(String[] args) throws IOException {
4546
//1通道
4647
MianVpn mianVpn = new MianVpn();
4748
List<ConfigsBean> mianVpns = mianVpn.fetch(webClient);
49+
System.out.println("通道一");
4850
mianVpns.forEach(System.out::println);
4951
//2通道
5052
TutorialVpn tutorialVpn = new TutorialVpn();
5153
List<ConfigsBean> tutorials = tutorialVpn.fetch(webClient);
54+
System.out.println("通道二");
5255
tutorials.forEach(System.out::println);
53-
56+
//本地的配置
57+
mianVpns.addAll(setting.getLocal());
58+
System.out.println("本地配置");
59+
setting.getLocal().forEach(System.out::println);
5460
//集合
5561
mianVpns.addAll(tutorials);
62+
63+
5664
SSModel model = JSON.parseObject(inputStream, null, SSModel.class);
5765
if (model == null) {
5866
model = new SSModel();

HtmlUnit-Demo/src/main/java/cn/mrdear/core/MianVpn.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public List<ConfigsBean> fetch(WebClient webClient) throws IOException {
2626
//拿到全部a标签
2727
DomNodeList<DomElement> domNodeList = page.getElementsByTagName("a");
2828

29-
List<ConfigsBean> results = domNodeList.stream()
30-
//找到内容为Surge的a标签
31-
.filter(domElement -> {
29+
return domNodeList.stream()
30+
//找到内容为Surge的a标签
31+
.filter(domElement -> {
3232
if (domElement.getTextContent().equals("Surge")) {
3333
System.out.println(domElement.getTextContent());
3434
return true;
3535
}
3636
return false;
3737
})
38-
//模拟点击,并取出结果
39-
.map(domElement -> {
38+
//模拟点击,并取出结果
39+
.map(domElement -> {
4040
HtmlPage tempPage = null;
4141
try {
4242
webClient.waitForBackgroundJavaScript(500);
@@ -54,11 +54,10 @@ public List<ConfigsBean> fetch(WebClient webClient) throws IOException {
5454
}
5555
return null;
5656
})
57-
//过滤掉为null的结果
58-
.filter(configsBean -> configsBean != null)
59-
//转换为list
60-
.collect(Collectors.toList());
61-
return results;
57+
//过滤掉为null的结果
58+
.filter(configsBean -> configsBean != null)
59+
//转换为list
60+
.collect(Collectors.toList());
6261
}
6362

6463
/**

HtmlUnit-Demo/src/main/java/cn/mrdear/model/ConfigsBean.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
* @date 2016/10/8
66
*/
77
public class ConfigsBean {
8+
9+
/**
10+
* remarks : 加利福尼亚,洛杉矶,美国
11+
* server : 23.105.203.111
12+
* server_port : 11111
13+
* password : 1111111
14+
* method : aes-256-cfb
15+
* obfs : plain
16+
* obfsparam :
17+
* remarks_base64 :
18+
* tcp_over_udp : false
19+
* udp_over_tcp : false
20+
* protocol : origin
21+
* obfs_udp : false
22+
* enable : true
23+
* id : 6B-7C-2E-E6-75-BD-0B-75-B6-12-30-06-39-61-69-37
24+
*/
825
private String remarks;
926
private String server;
1027
private int server_port;
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
{
2-
"sspath":"E:\\jar\\gui-config.json"
2+
"sspath":"E:\\jar\\gui-config.json",
3+
"local":[
4+
{
5+
"remarks" : "加利福尼亚,洛杉矶,美国",
6+
"server" : "23.105.203.111",
7+
"server_port" : 111,
8+
"password" : "1111",
9+
"method" : "aes-256-cfb",
10+
"obfs" : "plain",
11+
"obfsparam" : "",
12+
"remarks_base64" : "",
13+
"tcp_over_udp" : false,
14+
"udp_over_tcp" : false,
15+
"protocol" : "origin",
16+
"obfs_udp" : false,
17+
"enable" : true,
18+
"id" : "6B-7C-2E-E6-75-BD-0B-75-B6-12-30-06-39-61-69-37"
19+
}
20+
]
321
}

0 commit comments

Comments
 (0)