Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xxx committed Jan 22, 2018
1 parent 837f281 commit 5f2d86b
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ https://doub.io/sszhfx/ | 是 | 从 0 点 10 分开始,每 6 小时
https://freess.cx/ | 是 | 从 0 点 10 分开始,每 12 小时
https://en.ss8.fun/ | 是 | 从 0 点 10 分开始,每 4 小时
https://freessr.win/ | 是 | 从 0 点 10 分开始,每 6 小时
http://www.ssr.blue/ | 是 | 从 0 点 10 分开始,每 3 小时


#### 系统部署
Expand All @@ -60,4 +61,5 @@ ShadowSocksShare-OpenShift [Heroku 部署方法](https://github.com/the0demiurge
#### TO DO

1. 计划支持下列站点:
1. https://free-ss.site/
1. https://plus.google.com/communities/104092405342699579599
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<packaging>jar</packaging>

<name>ShadowSocks-Share</name>
<description>Demo project for Spring Boot</description>
<description>ShadowSocks-Share</description>

<parent>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.example.ShadowSocksShare.service.impl;

import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity;
import com.example.ShadowSocksShare.service.ShadowSocksCrawlerService;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

import java.text.MessageFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
* https://free-ss.site/
*/
@Slf4j
// @Service
public class Free_ssServiceImpl extends ShadowSocksCrawlerService {
// 目标网站 URL
private static final String TARGET_URL = "https://free-ss.site/ss.json?_={0}";

/**
* 网页内容解析 ss 信息
*/
@Override
protected Set<ShadowSocksDetailsEntity> parse(Document document) {
log.debug("===================>{}", document.html());
return null;
}

/**
* 目标网站 URL
*/
@Override
protected String getTargetURL() {
return MessageFormat.format(TARGET_URL, System.currentTimeMillis());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.example.ShadowSocksShare.service.impl;

import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity;
import com.example.ShadowSocksShare.service.ShadowSocksCrawlerService;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
* https://free-ss.site/
*/
@Slf4j
@Service
public class SsrBlueCrawlerServiceImpl extends ShadowSocksCrawlerService {
// 目标网站 URL
private static final String TARGET_URL = "http://www.ssr.blue/";

/**
* 网页内容解析 ss 信息
*/
@Override
protected Set<ShadowSocksDetailsEntity> parse(Document document) {
Elements ssList = document.select("a.btn-info");

Set<ShadowSocksDetailsEntity> set = new HashSet(ssList.size());
for (int i = 0; i < ssList.size(); i++) {
try {
String ssrLink = ssList.get(i).attributes().get("href");
ShadowSocksDetailsEntity ss = parseLink(ssrLink);
ss.setValid(false);
ss.setValidTime(new Date());
ss.setTitle(document.title());
ss.setRemarks(TARGET_URL);
ss.setGroup("ShadowSocks-Share");

// 测试网络
if (isReachable(ss))
ss.setValid(true);

// 无论是否可用都入库
set.add(ss);

log.debug("*************** 第 {} 条 ***************{}{}", i + 1, System.lineSeparator(), ss);
// log.debug("{}", ss.getLink());

} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
return set;
}

/**
* 目标网站 URL
*/
@Override
protected String getTargetURL() {
return TARGET_URL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public class ShadowSocksTasks {
@Autowired
@Qualifier("freeSSRCrawlerServiceImpl")
private ShadowSocksCrawlerService freeSSRCrawlerServiceImpl; // https://global.ishadowx.net/
/*@Autowired
@Qualifier("free_ssServiceImpl")*/
private ShadowSocksCrawlerService free_ssServiceImpl; // https://free-ss.site/
@Autowired
@Qualifier("ssrBlueCrawlerServiceImpl")
private ShadowSocksCrawlerService ssrBlueCrawlerServiceImpl; // http://www.ssr.blue

@Scheduled(cron = "0 10 0/3 * * ?")
public void iShadowCrawler() {
Expand All @@ -61,6 +67,16 @@ public void freeSSRCrawler() {
shadowSocksSerivce.crawlerAndSave(freeSSRCrawlerServiceImpl);
}

/*@Scheduled(cron = "0 10 0/6 * * ?")
public void free_ssCrawler() {
shadowSocksSerivce.crawlerAndSave(free_ssServiceImpl);
}*/

@Scheduled(cron = "0 10 0/3 * * ?")
public void ssrBlueCrawler() {
shadowSocksSerivce.crawlerAndSave(ssrBlueCrawlerServiceImpl);
}

/**
* SS 有效性检查,每 1 小时
*/
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/com/example/ShadowSocksShare/service/CodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,37 @@

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Test;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.MessageFormat;


@Slf4j
public class CodeTest {

@Test
public void testGetDocument() throws IOException {
String url = MessageFormat.format("https://free-ss.site/ss.json?_={0}", String.valueOf(System.currentTimeMillis()));

Document document = Jsoup.connect(url)
.userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36")
.referrer("https://free-ss.site/")
.ignoreContentType(true)
.ignoreHttpErrors(true)
.followRedirects(true)
.method(Connection.Method.GET)
.timeout(60 * 1000)
// .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 1080)))
.get();

log.debug("==========>{}", document.html());
}

@Test
public void test() {
// 104.236.187.174:1118:auth_sha1_v4:chacha20:tls1.2_ticket_auth:ZGFzamtqZGFr/?obfsparam=&remarks=MTExOCDml6fph5HlsbEgMTDkurogMTAwRyBTU1I&group=Q2hhcmxlcyBYdQ
Expand Down

0 comments on commit 5f2d86b

Please sign in to comment.