Skip to content

Commit

Permalink
修复 doub
Browse files Browse the repository at this point in the history
  • Loading branch information
xxx committed Jan 24, 2018
1 parent 5f2d86b commit c0d02c9
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity;
import com.example.ShadowSocksShare.service.ShadowSocksCrawlerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

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

/**
* doub
Expand All @@ -21,12 +20,86 @@
public class DoubCrawlerServiceImpl extends ShadowSocksCrawlerService {
// 目标网站 URL
private static final String TARGET_URL = "https://doub.io/sszhfx/";
// 协议
private final static Map<String, String> protocolMap = new HashMap() {
{
put("1", "origin");
put("2", "verify_deflate");
put("3", "auth_sha1_v4");
put("4", "auth_aes128_md5");
put("5", "auth_aes128_sha1");
put("6", "auth_chain_a");
put("7", "auth_chain_b");
}
};
// 混淆
private final static Map<String, String> obfsMap = new HashMap() {
{
put("1", "plain");
put("2", "http_simple");
put("3", "http_post");
put("4", "random_head");
put("5", "tls1.2_ticket_auth");
put("6", "tls1.2_ticket_fastauth");
}
};

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

if (!tables.isEmpty()) {
// 取第一个 table
Element table = tables.get(0);
// 所有行(首行为表头)
Elements rows = table.select("tr");
if (rows.size() > 2) {

Set<ShadowSocksDetailsEntity> set = new HashSet(rows.size() - 1);
// 从第二行读取
for (int i = 1; i < rows.size(); i++) {
Elements cols = rows.get(i).select("td");
if (cols.size() >= 5) {
// 服务器地址 / 服务器IP / 端口 / 协议|混淆 / 加密方式 / 提供者 / 二维码
// 计算 协议|混淆
String strs[] = StringUtils.deleteWhitespace(cols.get(3).text()).split("\\|");
// 协议|混淆
if (strs.length >= 2) {
String protocol = protocolMap.get(strs[0].trim());
String obfs = obfsMap.get(strs[1].trim());

// IPV4、协议、混淆 不为空
if (cols.get(1).text().contains(".") && StringUtils.isNotBlank(protocol) && StringUtils.isNotBlank(obfs)) {
ShadowSocksDetailsEntity ss = new ShadowSocksDetailsEntity(cols.get(1).text(), Integer.parseInt(cols.get(2).text()), cols.get(4).text(), "doub.io/sszhfx/*doub.bid/sszhfx/*" + cols.get(2).text(), protocol, obfs);
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("*************** 第 {} 条 ***************{}{}", set.size(), System.lineSeparator(), ss);
}
}
}
}
return set;
}
}
return new HashSet<>();
}

// 解析 连接方式
/*protected Set<ShadowSocksDetailsEntity> parse(Document document) {
Elements ssList = document.select("a.dl1");
Set<ShadowSocksDetailsEntity> set = new HashSet(ssList.size());
Expand Down Expand Up @@ -59,7 +132,7 @@ protected Set<ShadowSocksDetailsEntity> parse(Document document) {
}
}
return set;
}
}*/

/**
* 目标网站 URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.nio.charset.StandardCharsets;

@Slf4j
public class ShadowSocksDetailsEntityTest {

Expand All @@ -20,7 +24,10 @@ public void testgetLink() {

@Test
public void testsetLink() {
String str = "ssr://MjE2LjE4OS4xNTguMTQ3OjM1MDc6YXV0aF9hZXMxMjhfc2hhMTpjaGFjaGEyMDp0bHMxLjJfdGlja2V0X2F1dGg6Wkc5MVlpNXBieTl6YzNwb1puZ3ZLbVJ2ZFdJdVltbGtMM056ZW1obWVDOHFNelV3TncvP3JlbWFya3M9NXB5czZMU201WS0zNXAybDZJZXFPbVJ2ZFdJdWFXOHZjM042YUdaNEwtbVZuT1dEai1XZm4tV1FqVHBrYjNWaUxtSnBaQzl6YzNwb1puZ3Y";
String str = "MjYwNDphODgwOjQwMDpkMDo6MmVmOmMw6VsafSaFgGdGPK0MDE6NTM3MDphdXRoX2FlczEyOF9zaGExOmNoYWNoYTIwOnRsczEuMl90aWNrZXRfYXV0aDpaRzkxWWk1cGJ5OXpjM3BvWm5ndkttUnZkV0l1WW1sa0wzTnplbWhtZUM4cU5UTTNNQS8_cmVtYXJrcz01cHlzNkxTbTVZLTM1cDJsNkllcU9tUnZkV0l1YVc4dmMzTjZhR1o0TC1tVm5PV0RqLVdmbi1XUWpUcGtiM1ZpTG1KcFpDOXpjM3BvWm5ndg";
String ssrInfoStr = new String(Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8);
log.debug(ssrInfoStr);
log.debug("{}", new String(Base64.decodeBase64(str)));
// log.debug("{}", new ShadowSocksDetailsEntity(str));
// log.debug("{}", new ShadowSocksDetailsEntity(str).getLink());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
package com.example.ShadowSocksShare.service;

import com.example.ShadowSocksShare.BaseTest;
import com.example.ShadowSocksShare.domain.ShadowSocksDetailsEntity;
import com.example.ShadowSocksShare.domain.ShadowSocksEntity;
import com.example.ShadowSocksShare.domain.ShadowSocksRepository;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.web.servlet.MockMvc;

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

@Slf4j
public class ShadowSocksCrawlerServiceTest extends BaseTest {
@Autowired
private MockMvc mvc;

@Autowired
private ShadowSocksCrawlerService iShadowCrawlerServiceImpl;
@Qualifier("iShadowCrawlerServiceImpl")
private ShadowSocksCrawlerService iShadowCrawlerServiceImpl; // ishadow
@Autowired
private ShadowSocksRepository shadowSocksRepository;


public void aa() {
ShadowSocksEntity socksEntity = new ShadowSocksEntity("targetURL", "title", true, new Date());
socksEntity.setShadowSocksSet(new HashSet<>());

ShadowSocksDetailsEntity entity = new ShadowSocksDetailsEntity("216.189.158.147", 5307, "mm", "chacha20", "auth_aes128_sha1", "tls1.2_ticket_auth");
entity.setValid(true);
entity.setRemarks("本账号来自:doub.io/sszhfx/镜像域名:doub.bid/sszhfx/");
entity.setGroup("");
@Qualifier("doubCrawlerServiceImpl")
private ShadowSocksCrawlerService doubCrawlerServiceImpl; // https://doub.io
@Autowired
@Qualifier("freeSS_EasyToUseCrawlerServiceImpl")
private ShadowSocksCrawlerService freeSS_EasyToUseCrawlerServiceImpl; // https://freess.cx/#portfolio-preview
@Autowired
@Qualifier("ss8ServiceImpl")
private ShadowSocksCrawlerService ss8ServiceImpl; // https://en.ss8.fun/
@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

socksEntity.getShadowSocksSet().add(entity);

shadowSocksRepository.save(socksEntity);
@Test
public void testDoubCrawlerService() {
ShadowSocksEntity entity = doubCrawlerServiceImpl.getShadowSocks();
log.debug("========>{}", entity);
}
}

0 comments on commit c0d02c9

Please sign in to comment.