Skip to content

Commit

Permalink
fix pac for wrong ipv4 subnets
Browse files Browse the repository at this point in the history
  • Loading branch information
HMBSbige committed Sep 17, 2018
1 parent 8b47c5d commit 8718d35
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions shadowsocks-csharp/Controller/ChnDomainsAndIPUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Shadowsocks.Model;
using Shadowsocks.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using Shadowsocks.Model;
using Shadowsocks.Util;

namespace Shadowsocks.Controller
{
public class ChnDomainsAndIPUpdater
{
private const string CNIP_URL = @"https://raw.githubusercontent.com/17mon/china_ip_list/master/china_ip_list.txt";
private const string CNIP_URL = @"https://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest";
private const string CNDOMAINS_URL = @"https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf";
private const string SS_CNIP_TEMPLATE_URL = @"https://raw.githubusercontent.com/HMBSbige/Text_Translation/master/ShadowsocksR/ss_cnip_temp.pac";
private const string SS_WHITE_TEMPLATE_URL = @"https://raw.githubusercontent.com/HMBSbige/Text_Translation/master/ShadowsocksR/ss_white_temp.pac";
Expand Down
11 changes: 4 additions & 7 deletions shadowsocks-csharp/Util/GetCNIP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;

namespace Shadowsocks.Util
{
Expand Down Expand Up @@ -153,13 +152,11 @@ public static string GetcnIp16Range(Dictionary<IPAddress, int> ipv4Subnets)
return null;
}

var reg = new Regex("^(.+)/(.+)$");
var match = reg.Match(str);
if (match.Groups.Count == 3)
var strA = str.Split('|');
//apnic|CN|ipv4|
if (strA.Length > 4 && strA[0] == @"apnic" && strA[1] == @"CN" && strA[2] == @"ipv4")
{
var ipv4 = IPAddress.Parse(match.Groups[1].Value);
var hosts = IPv4Subnet.CIDR2Hosts(Convert.ToInt32(match.Groups[2].Value));
return new KeyValuePair<IPAddress, int>(ipv4, hosts);
return new KeyValuePair<IPAddress, int>(IPAddress.Parse(strA[3]), Convert.ToInt32(strA[4]));
}

return null;
Expand Down

0 comments on commit 8718d35

Please sign in to comment.