Browse Source

make sure protobuf works

in case gfwlist no longer update
tags/4.2.0.0
Student Main 4 years ago
parent
commit
6369e76f8d
9 changed files with 5926 additions and 77 deletions
  1. +40
    -0
      shadowsocks-csharp/Controller/Service/GeositeUpdater.cs
  2. +4983
    -0
      shadowsocks-csharp/Data/dlc.dat
  3. +753
    -0
      shadowsocks-csharp/Model/Geosite/Geosite.cs
  4. +43
    -0
      shadowsocks-csharp/Model/Geosite/geosite.proto
  5. +1
    -1
      shadowsocks-csharp/Program.cs
  6. +77
    -76
      shadowsocks-csharp/Properties/Resources.Designer.cs
  7. +3
    -0
      shadowsocks-csharp/Properties/Resources.resx
  8. +5
    -0
      shadowsocks-csharp/packages.config
  9. +21
    -0
      shadowsocks-csharp/shadowsocks-csharp.csproj

+ 40
- 0
shadowsocks-csharp/Controller/Service/GeositeUpdater.cs View File

@@ -0,0 +1,40 @@
using NLog;
using Shadowsocks.Properties;
using Shadowsocks.Util;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Google.Protobuf;

namespace Shadowsocks.Controller
{
static class GeositeUpdater
{
private static Logger logger = LogManager.GetCurrentClassLogger();

private static readonly string DatabasePath = Utils.GetTempPath("dlc.dat");

public static readonly GeositeList List;

public static readonly Dictionary<string, List<DomainObject>> Geosites = new Dictionary<string, List<DomainObject>>();

static GeositeUpdater()
{
if (!File.Exists(DatabasePath))
{
File.WriteAllBytes(DatabasePath, Resources.dlc_dat);
}

List = GeositeList.Parser.ParseFrom(File.ReadAllBytes(DatabasePath));


foreach (var item in List.Entry)
{
Geosites[item.CountryCode] = item.Domain.ToList();
}
}
}
}

+ 4983
- 0
shadowsocks-csharp/Data/dlc.dat
File diff suppressed because it is too large
View File


+ 753
- 0
shadowsocks-csharp/Model/Geosite/Geosite.cs View File

@@ -0,0 +1,753 @@
// <auto-generated>
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: geosite.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
/// <summary>Holder for reflection information generated from geosite.proto</summary>
public static partial class GeositeReflection {

#region Descriptor
/// <summary>File descriptor for geosite.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
private static pbr::FileDescriptor descriptor;

static GeositeReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Cg1nZW9zaXRlLnByb3RvIvMBCgxEb21haW5PYmplY3QSIAoEdHlwZRgBIAEo",
"DjISLkRvbWFpbk9iamVjdC5UeXBlEg0KBXZhbHVlGAIgASgJEioKCWF0dHJp",
"YnV0ZRgDIAMoCzIXLkRvbWFpbk9iamVjdC5BdHRyaWJ1dGUaUgoJQXR0cmli",
"dXRlEgsKA2tleRgBIAEoCRIUCgpib29sX3ZhbHVlGAIgASgISAASEwoJaW50",
"X3ZhbHVlGAMgASgDSABCDQoLdHlwZWRfdmFsdWUiMgoEVHlwZRIJCgVQbGFp",
"bhAAEgkKBVJlZ2V4EAESCgoGRG9tYWluEAISCAoERnVsbBADIj4KB0dlb3Np",
"dGUSFAoMY291bnRyeV9jb2RlGAEgASgJEh0KBmRvbWFpbhgCIAMoCzINLkRv",
"bWFpbk9iamVjdCImCgtHZW9zaXRlTGlzdBIXCgVlbnRyeRgBIAMoCzIILkdl",
"b3NpdGViBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::DomainObject), global::DomainObject.Parser, new[]{ "Type", "Value", "Attribute" }, null, new[]{ typeof(global::DomainObject.Types.Type) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::DomainObject.Types.Attribute), global::DomainObject.Types.Attribute.Parser, new[]{ "Key", "BoolValue", "IntValue" }, new[]{ "TypedValue" }, null, null, null)}),
new pbr::GeneratedClrTypeInfo(typeof(global::Geosite), global::Geosite.Parser, new[]{ "CountryCode", "Domain" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::GeositeList), global::GeositeList.Parser, new[]{ "Entry" }, null, null, null, null)
}));
}
#endregion

}
#region Messages
/// <summary>
/// DomainObject for routing decision.
/// </summary>
public sealed partial class DomainObject : pb::IMessage<DomainObject> {
private static readonly pb::MessageParser<DomainObject> _parser = new pb::MessageParser<DomainObject>(() => new DomainObject());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<DomainObject> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::GeositeReflection.Descriptor.MessageTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public DomainObject() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public DomainObject(DomainObject other) : this() {
type_ = other.type_;
value_ = other.value_;
attribute_ = other.attribute_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public DomainObject Clone() {
return new DomainObject(this);
}

/// <summary>Field number for the "type" field.</summary>
public const int TypeFieldNumber = 1;
private global::DomainObject.Types.Type type_ = global::DomainObject.Types.Type.Plain;
/// <summary>
/// DomainObject matching type.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::DomainObject.Types.Type Type {
get { return type_; }
set {
type_ = value;
}
}

/// <summary>Field number for the "value" field.</summary>
public const int ValueFieldNumber = 2;
private string value_ = "";
/// <summary>
/// DomainObject value.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Value {
get { return value_; }
set {
value_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "attribute" field.</summary>
public const int AttributeFieldNumber = 3;
private static readonly pb::FieldCodec<global::DomainObject.Types.Attribute> _repeated_attribute_codec
= pb::FieldCodec.ForMessage(26, global::DomainObject.Types.Attribute.Parser);
private readonly pbc::RepeatedField<global::DomainObject.Types.Attribute> attribute_ = new pbc::RepeatedField<global::DomainObject.Types.Attribute>();
/// <summary>
/// Attributes of this domain. May be used for filtering.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::DomainObject.Types.Attribute> Attribute {
get { return attribute_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as DomainObject);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(DomainObject other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Type != other.Type) return false;
if (Value != other.Value) return false;
if(!attribute_.Equals(other.attribute_)) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Type != global::DomainObject.Types.Type.Plain) hash ^= Type.GetHashCode();
if (Value.Length != 0) hash ^= Value.GetHashCode();
hash ^= attribute_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (Type != global::DomainObject.Types.Type.Plain) {
output.WriteRawTag(8);
output.WriteEnum((int) Type);
}
if (Value.Length != 0) {
output.WriteRawTag(18);
output.WriteString(Value);
}
attribute_.WriteTo(output, _repeated_attribute_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Type != global::DomainObject.Types.Type.Plain) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
}
if (Value.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Value);
}
size += attribute_.CalculateSize(_repeated_attribute_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(DomainObject other) {
if (other == null) {
return;
}
if (other.Type != global::DomainObject.Types.Type.Plain) {
Type = other.Type;
}
if (other.Value.Length != 0) {
Value = other.Value;
}
attribute_.Add(other.attribute_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 8: {
Type = (global::DomainObject.Types.Type) input.ReadEnum();
break;
}
case 18: {
Value = input.ReadString();
break;
}
case 26: {
attribute_.AddEntriesFrom(input, _repeated_attribute_codec);
break;
}
}
}
}

#region Nested types
/// <summary>Container for nested types declared in the DomainObject message type.</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static partial class Types {
/// <summary>
/// Type of domain value.
/// </summary>
public enum Type {
/// <summary>
/// The value is used as is.
/// </summary>
[pbr::OriginalName("Plain")] Plain = 0,
/// <summary>
/// The value is used as a regular expression.
/// </summary>
[pbr::OriginalName("Regex")] Regex = 1,
/// <summary>
/// The value is a root domain.
/// </summary>
[pbr::OriginalName("Domain")] Domain = 2,
/// <summary>
/// The value is a domain.
/// </summary>
[pbr::OriginalName("Full")] Full = 3,
}

public sealed partial class Attribute : pb::IMessage<Attribute> {
private static readonly pb::MessageParser<Attribute> _parser = new pb::MessageParser<Attribute>(() => new Attribute());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Attribute> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::DomainObject.Descriptor.NestedTypes[0]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Attribute() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Attribute(Attribute other) : this() {
key_ = other.key_;
switch (other.TypedValueCase) {
case TypedValueOneofCase.BoolValue:
BoolValue = other.BoolValue;
break;
case TypedValueOneofCase.IntValue:
IntValue = other.IntValue;
break;
}

_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Attribute Clone() {
return new Attribute(this);
}

/// <summary>Field number for the "key" field.</summary>
public const int KeyFieldNumber = 1;
private string key_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Key {
get { return key_; }
set {
key_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "bool_value" field.</summary>
public const int BoolValueFieldNumber = 2;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool BoolValue {
get { return typedValueCase_ == TypedValueOneofCase.BoolValue ? (bool) typedValue_ : false; }
set {
typedValue_ = value;
typedValueCase_ = TypedValueOneofCase.BoolValue;
}
}

/// <summary>Field number for the "int_value" field.</summary>
public const int IntValueFieldNumber = 3;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public long IntValue {
get { return typedValueCase_ == TypedValueOneofCase.IntValue ? (long) typedValue_ : 0L; }
set {
typedValue_ = value;
typedValueCase_ = TypedValueOneofCase.IntValue;
}
}

private object typedValue_;
/// <summary>Enum of possible cases for the "typed_value" oneof.</summary>
public enum TypedValueOneofCase {
None = 0,
BoolValue = 2,
IntValue = 3,
}
private TypedValueOneofCase typedValueCase_ = TypedValueOneofCase.None;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public TypedValueOneofCase TypedValueCase {
get { return typedValueCase_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void ClearTypedValue() {
typedValueCase_ = TypedValueOneofCase.None;
typedValue_ = null;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as Attribute);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(Attribute other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (Key != other.Key) return false;
if (BoolValue != other.BoolValue) return false;
if (IntValue != other.IntValue) return false;
if (TypedValueCase != other.TypedValueCase) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (Key.Length != 0) hash ^= Key.GetHashCode();
if (typedValueCase_ == TypedValueOneofCase.BoolValue) hash ^= BoolValue.GetHashCode();
if (typedValueCase_ == TypedValueOneofCase.IntValue) hash ^= IntValue.GetHashCode();
hash ^= (int) typedValueCase_;
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (Key.Length != 0) {
output.WriteRawTag(10);
output.WriteString(Key);
}
if (typedValueCase_ == TypedValueOneofCase.BoolValue) {
output.WriteRawTag(16);
output.WriteBool(BoolValue);
}
if (typedValueCase_ == TypedValueOneofCase.IntValue) {
output.WriteRawTag(24);
output.WriteInt64(IntValue);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (Key.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Key);
}
if (typedValueCase_ == TypedValueOneofCase.BoolValue) {
size += 1 + 1;
}
if (typedValueCase_ == TypedValueOneofCase.IntValue) {
size += 1 + pb::CodedOutputStream.ComputeInt64Size(IntValue);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(Attribute other) {
if (other == null) {
return;
}
if (other.Key.Length != 0) {
Key = other.Key;
}
switch (other.TypedValueCase) {
case TypedValueOneofCase.BoolValue:
BoolValue = other.BoolValue;
break;
case TypedValueOneofCase.IntValue:
IntValue = other.IntValue;
break;
}

_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
Key = input.ReadString();
break;
}
case 16: {
BoolValue = input.ReadBool();
break;
}
case 24: {
IntValue = input.ReadInt64();
break;
}
}
}
}

}

}
#endregion

}

public sealed partial class Geosite : pb::IMessage<Geosite> {
private static readonly pb::MessageParser<Geosite> _parser = new pb::MessageParser<Geosite>(() => new Geosite());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<Geosite> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::GeositeReflection.Descriptor.MessageTypes[1]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Geosite() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Geosite(Geosite other) : this() {
countryCode_ = other.countryCode_;
domain_ = other.domain_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public Geosite Clone() {
return new Geosite(this);
}

/// <summary>Field number for the "country_code" field.</summary>
public const int CountryCodeFieldNumber = 1;
private string countryCode_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string CountryCode {
get { return countryCode_; }
set {
countryCode_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

/// <summary>Field number for the "domain" field.</summary>
public const int DomainFieldNumber = 2;
private static readonly pb::FieldCodec<global::DomainObject> _repeated_domain_codec
= pb::FieldCodec.ForMessage(18, global::DomainObject.Parser);
private readonly pbc::RepeatedField<global::DomainObject> domain_ = new pbc::RepeatedField<global::DomainObject>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::DomainObject> Domain {
get { return domain_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as Geosite);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(Geosite other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if (CountryCode != other.CountryCode) return false;
if(!domain_.Equals(other.domain_)) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
if (CountryCode.Length != 0) hash ^= CountryCode.GetHashCode();
hash ^= domain_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
if (CountryCode.Length != 0) {
output.WriteRawTag(10);
output.WriteString(CountryCode);
}
domain_.WriteTo(output, _repeated_domain_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
if (CountryCode.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(CountryCode);
}
size += domain_.CalculateSize(_repeated_domain_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(Geosite other) {
if (other == null) {
return;
}
if (other.CountryCode.Length != 0) {
CountryCode = other.CountryCode;
}
domain_.Add(other.domain_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
CountryCode = input.ReadString();
break;
}
case 18: {
domain_.AddEntriesFrom(input, _repeated_domain_codec);
break;
}
}
}
}

}

public sealed partial class GeositeList : pb::IMessage<GeositeList> {
private static readonly pb::MessageParser<GeositeList> _parser = new pb::MessageParser<GeositeList>(() => new GeositeList());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<GeositeList> Parser { get { return _parser; } }

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor {
get { return global::GeositeReflection.Descriptor.MessageTypes[2]; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public GeositeList() {
OnConstruction();
}

partial void OnConstruction();

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public GeositeList(GeositeList other) : this() {
entry_ = other.entry_.Clone();
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public GeositeList Clone() {
return new GeositeList(this);
}

/// <summary>Field number for the "entry" field.</summary>
public const int EntryFieldNumber = 1;
private static readonly pb::FieldCodec<global::Geosite> _repeated_entry_codec
= pb::FieldCodec.ForMessage(10, global::Geosite.Parser);
private readonly pbc::RepeatedField<global::Geosite> entry_ = new pbc::RepeatedField<global::Geosite>();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public pbc::RepeatedField<global::Geosite> Entry {
get { return entry_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as GeositeList);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(GeositeList other) {
if (ReferenceEquals(other, null)) {
return false;
}
if (ReferenceEquals(other, this)) {
return true;
}
if(!entry_.Equals(other.entry_)) return false;
return Equals(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() {
int hash = 1;
hash ^= entry_.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
return hash;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) {
entry_.WriteTo(output, _repeated_entry_codec);
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() {
int size = 0;
size += entry_.CalculateSize(_repeated_entry_codec);
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
return size;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(GeositeList other) {
if (other == null) {
return;
}
entry_.Add(other.entry_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) {
uint tag;
while ((tag = input.ReadTag()) != 0) {
switch(tag) {
default:
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
break;
case 10: {
entry_.AddEntriesFrom(input, _repeated_entry_codec);
break;
}
}
}
}

}

#endregion


#endregion Designer generated code

+ 43
- 0
shadowsocks-csharp/Model/Geosite/geosite.proto View File

@@ -0,0 +1,43 @@
syntax = "proto3";

// DomainObject for routing decision.
message DomainObject {
// Type of domain value.
enum Type {
// The value is used as is.
Plain = 0;
// The value is used as a regular expression.
Regex = 1;
// The value is a root domain.
Domain = 2;
// The value is a domain.
Full = 3;
}

// DomainObject matching type.
Type type = 1;

// DomainObject value.
string value = 2;

message Attribute {
string key = 1;

oneof typed_value {
bool bool_value = 2;
int64 int_value = 3;
}
}

// Attributes of this domain. May be used for filtering.
repeated Attribute attribute = 3;
}

message Geosite {
string country_code = 1;
repeated DomainObject domain = 2;
}

message GeositeList{
repeated Geosite entry = 1;
}

+ 1
- 1
shadowsocks-csharp/Program.cs View File

@@ -155,7 +155,7 @@ namespace Shadowsocks
{
MainController.AskAddServerBySSURL(addedUrl);
}
Console.WriteLine(GeositeUpdater.List);
Application.Run();
}


+ 77
- 76
shadowsocks-csharp/Properties/Resources.Designer.cs View File

@@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
@@ -13,12 +13,12 @@ namespace Shadowsocks.Properties {
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@@ -33,7 +33,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
@@ -47,8 +47,8 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@@ -61,7 +61,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized string similar to /* eslint-disable */
/// 查找类似 /* eslint-disable */
///// Was generated by gfwlist2pac in precise mode
///// https://github.com/clowwindy/gfwlist2pac
///
@@ -76,7 +76,7 @@ namespace Shadowsocks.Properties {
///* This file is part of Adblock Plus &lt;http://adblockplus.org/&gt;,
///* Copyright (C) 2006-2014 Eyeo GmbH
///*
///* Adblock Plus is free software: you can redistribute it and/or [rest of string was truncated]&quot;;.
///* Adblock Plus is free software: you can redistribute it and/or [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string abp_js {
get {
@@ -85,29 +85,28 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized string similar to var __USERRULES__ = [];
///var __RULES__ = [
/// &quot;|http://85.17.73.31/&quot;,
/// &quot;||agnesb.fr&quot;,
/// &quot;||akiba-web.com&quot;,
/// &quot;||altrec.com&quot;,
/// &quot;||angela-merkel.de&quot;,
/// &quot;||angola.org&quot;,
/// &quot;||apartmentratings.com&quot;,
/// &quot;||apartments.com&quot;,
/// &quot;||arena.taipei&quot;,
/// &quot;||asianspiss.com&quot;,
/// &quot;||assimp.org&quot;,
/// &quot;||athenaeizou.com&quot;,
/// &quot;||azubu.tv&quot;,
/// &quot;||bankmobilevibe.com&quot;,
/// &quot;||banorte.com&quot;,
/// &quot;||bash-hackers.org&quot;,
/// &quot;||beeg.com&quot;,
/// &quot;||global.bing.com&quot;,
/// &quot;||bloombergview.com&quot;,
/// &quot;||booktopia.com.au&quot;,
/// [rest of string was truncated]&quot;;.
/// 查找类似 var __USERRULES__ = [];
///var __RULES__ = [
/// &quot;|http://85.17.73.31/&quot;,
/// &quot;||agnesb.fr&quot;,
/// &quot;||akiba-web.com&quot;,
/// &quot;||altrec.com&quot;,
/// &quot;||angela-merkel.de&quot;,
/// &quot;||angola.org&quot;,
/// &quot;||apartmentratings.com&quot;,
/// &quot;||apartments.com&quot;,
/// &quot;||arena.taipei&quot;,
/// &quot;||asianspiss.com&quot;,
/// &quot;||assimp.org&quot;,
/// &quot;||athenaeizou.com&quot;,
/// &quot;||azubu.tv&quot;,
/// &quot;||bankmobilevibe.com&quot;,
/// &quot;||banorte.com&quot;,
/// &quot;||bash-hackers.org&quot;,
/// &quot;||beeg.com&quot;,
/// &quot;||global.bing.com&quot;,
/// &quot;||bloombergview.com&quot;,
/// &quot; [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string default_abp_rule {
get {
@@ -116,24 +115,29 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized string similar to en,zh-CN,zh-TW,ja
///#Restart program to apply translation,,,
///#This is comment line,,,
///#Always keep language name at head of file,,,
///#Language name is output in log,,,
///&quot;#You can find it by search &quot;&quot;Current language is:&quot;&quot;&quot;,,,
///#Please use UTF-8 with BOM encoding so we can edit it in Excel,,,
///,,,
///Shadowsocks,Shadowsocks,Shadowsocks,Shadowsocks
///,,,
///#Menu,,,
///,,,
///System Proxy,系统代理,系統代理,システムプロキシ
///Disable,禁用,禁用,無効
///PAC,PAC 模式,PAC 模式,PAC
///Global,全局模式,全局模式,全般
///Servers,服务器,伺服器,サーバー
///Edit Servers...,编辑服务器...,編輯伺服器...,サーバーの編集.. [rest of string was truncated]&quot;;.
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] dlc_dat {
get {
object obj = ResourceManager.GetObject("dlc_dat", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// 查找类似 en,ru-RU,zh-CN,zh-TW,ja,ko,fr
///#Restart program to apply translation,,,,,,
///#This is comment line,,,,,,
///#Always keep language name at head of file,,,,,,
///#Language name is output in log,,,,,,
///&quot;#You can find it by search &quot;&quot;Current language is:&quot;&quot;&quot;,,,,,,
///#Please use UTF-8 with BOM encoding so we can edit it in Excel,,,,,,
///,,,,,,
///Shadowsocks,Shadowsocks,Shadowsocks,Shadowsocks,Shadowsocks,Shadowsocks,Shadowsocks
///,,,,,,
///#Menu,,,,,,
///,,,,,,
///System Proxy,Системный прокси-сервер,系统代理,系統代理,システムプロキシ,시스템 프록시,P [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string i18n_csv {
get {
@@ -142,7 +146,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] libsscrypto_dll {
get {
@@ -152,16 +156,13 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
/// 查找类似 &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
///&lt;!-- Warning: Configuration may reset after shadowsocks upgrade. --&gt;
///&lt;!-- If you messed it up, delete this file and Shadowsocks will create a new one. --&gt;
///&lt;nlog xmlns=&quot;http://www.nlog-project.org/schemas/NLog.xsd&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
/// &lt;targets&gt;
/// &lt;target name=&quot;file&quot; xsi:type=&quot;File&quot; fileName=&quot;shadowsocks.log&quot;/&gt;
///
/// &lt;/targets&gt;
/// &lt;rules&gt;
/// &lt;logger name=&quot;Name.Space.Class1&quot; minlevel=&quot;Debug&quot; writeTo=&quot;f1&quot; /&gt;
/// &lt;/rules&gt;
///&lt;/nlog&gt;.
/// &lt;!-- This line is managed by Shadowsocks. Do not modify it unless you know what you are doing.--&gt;
/// &lt;target name=&quot;file&quot; xsi:type=&quot;File&quot; fileName=&quot;ss_win_temp\shadowsocks.log&quot; writ [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string NLog_config {
get {
@@ -170,7 +171,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized string similar to listen-address __PRIVOXY_BIND_IP__:__PRIVOXY_BIND_PORT__
/// 查找类似 listen-address __PRIVOXY_BIND_IP__:__PRIVOXY_BIND_PORT__
///toggle 0
///logfile ss_privoxy.log
///show-on-task-bar 0
@@ -178,7 +179,7 @@ namespace Shadowsocks.Properties {
///forward-socks5 / __SOCKS_HOST__:__SOCKS_PORT__ .
///max-client-connections 2048
///hide-console
///.
/// 的本地化字符串。
/// </summary>
internal static string privoxy_conf {
get {
@@ -187,7 +188,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] privoxy_exe {
get {
@@ -197,7 +198,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ss32Fill {
get {
@@ -207,7 +208,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ss32In {
get {
@@ -217,7 +218,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ss32Out {
get {
@@ -227,7 +228,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ss32Outline {
get {
@@ -237,7 +238,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap ssw128 {
get {
@@ -247,7 +248,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] sysproxy_exe {
get {
@@ -257,7 +258,7 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// 查找 System.Byte[] 类型的本地化资源。
/// </summary>
internal static byte[] sysproxy64_exe {
get {
@@ -267,9 +268,9 @@ namespace Shadowsocks.Properties {
}
/// <summary>
/// Looks up a localized string similar to ! Put user rules line by line in this file.
/// 查找类似 ! Put user rules line by line in this file.
///! See https://adblockplus.org/en/filter-cheatsheet
///.
/// 的本地化字符串。
/// </summary>
internal static string user_rule {
get {


+ 3
- 0
shadowsocks-csharp/Properties/Resources.resx View File

@@ -124,6 +124,9 @@
<data name="default_abp_rule" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Data\default-abp-rule.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="dlc_dat" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\data\dlc.dat;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="i18n_csv" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Data\i18n.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>


+ 5
- 0
shadowsocks-csharp/packages.config View File

@@ -4,8 +4,13 @@
<package id="Costura.Fody" version="3.3.3" targetFramework="net472" />
<package id="Fody" version="4.2.1" targetFramework="net472" developmentDependency="true" />
<package id="GlobalHotKey" version="1.1.0" targetFramework="net472" />
<package id="Google.Protobuf" version="3.11.4" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
<package id="NLog" version="4.6.8" targetFramework="net472" />
<package id="StringEx.CS" version="0.3.1" targetFramework="net472" developmentDependency="true" />
<package id="System.Buffers" version="4.4.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.2" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net472" />
<package id="ZXing.Net" version="0.16.5" targetFramework="net472" />
</packages>

+ 21
- 0
shadowsocks-csharp/shadowsocks-csharp.csproj View File

@@ -77,6 +77,9 @@
<Reference Include="GlobalHotKey, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\GlobalHotKey.1.1.0\lib\GlobalHotKey.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.11.4.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.11.4\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
@@ -87,13 +90,26 @@
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Drawing" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.2\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
@@ -112,6 +128,7 @@
<ItemGroup>
<Compile Include="Controller\HotkeyReg.cs" />
<Compile Include="Controller\LoggerExtension.cs" />
<Compile Include="Controller\Service\GeositeUpdater.cs" />
<Compile Include="Controller\Service\PACDaemon.cs" />
<Compile Include="Controller\Service\NamedPipeServer.cs" />
<Compile Include="Controller\System\ProtocolHandler.cs" />
@@ -133,6 +150,7 @@
<Compile Include="Encryption\Stream\StreamMbedTLSEncryptor.cs" />
<Compile Include="Encryption\Stream\StreamOpenSSLEncryptor.cs" />
<Compile Include="Encryption\Stream\StreamSodiumEncryptor.cs" />
<Compile Include="Model\Geosite\Geosite.cs" />
<Compile Include="Model\HotKeyConfig.cs" />
<Compile Include="Model\NLogConfig.cs" />
<Compile Include="Model\ProxyConfig.cs" />
@@ -267,10 +285,12 @@
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Data\dlc.dat" />
<None Include="Data\i18n.csv" />
<None Include="Data\libsscrypto.dll.gz" />
<None Include="Data\NLog.config" />
<None Include="Data\privoxy.exe.gz" />
<None Include="Model\Geosite\geosite.proto" />
</ItemGroup>
<ItemGroup>
<None Include="Data\sysproxy.exe.gz" />
@@ -322,6 +342,7 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.4.2.1\build\Fody.targets" Condition="Exists('..\packages\Fody.4.2.1\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">


Loading…
Cancel
Save