Skip to content

Commit

Permalink
fix ip resolving; use simple-json instead; reduce icon size
Browse files Browse the repository at this point in the history
  • Loading branch information
clowwindy committed Jan 16, 2013
1 parent fe0bdbf commit 5ecad22
Show file tree
Hide file tree
Showing 10 changed files with 500 additions and 1,132 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "shadowsocks-csharp/simple-json"]
path = shadowsocks-csharp/simple-json
url = git@github.com:facebook-csharp-sdk/simple-json.git
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Other ports and clients can be found [here](https://github.com/clowwindy/shadows
usage
-----------

First, clone the code:

git clone --recurse-submodules git://github.com/shadowsocks/shadowsocks-iOS.git

Use Visual Studio 2012 Express or higher to build.

Need .Net 3.5.
Need .Net 2.0.
21 changes: 13 additions & 8 deletions shadowsocks-csharp/Config.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization.Json;
using System.Text;
using System.IO;
using System.Diagnostics;
using SimpleJson;

namespace shadowsocks_csharp
{
Expand All @@ -15,7 +15,6 @@ public class Config
public int local_port;
public string password;

[NonSerialized]
public bool isDefault;

private static void assert(bool condition)
Expand All @@ -28,12 +27,11 @@ private static void assert(bool condition)

public static Config Load()
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Config));
try
{
using (FileStream fs = File.OpenRead(@"config.json"))
using (StreamReader sr = new StreamReader(File.OpenRead(@"config.json")))
{
Config config = ser.ReadObject(fs) as Config;
Config config = SimpleJson.SimpleJson.DeserializeObject<Config>(sr.ReadToEnd());
assert(!string.IsNullOrEmpty(config.server));
assert(!string.IsNullOrEmpty(config.password));
assert(config.local_port > 0);
Expand All @@ -58,12 +56,19 @@ public static Config Load()

public static void Save(Config config)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Config));
try
{
using (FileStream fs = File.Open(@"config.json", FileMode.Create))
using (StreamWriter sw = new StreamWriter(File.Open(@"config.json", FileMode.Create)))
{
ser.WriteObject(fs, config);
string jsonString = SimpleJson.SimpleJson.SerializeObject(new
{
server = config.server,
server_port = config.server_port,
local_port = config.local_port,
password = config.password
});
sw.Write(jsonString);
sw.Flush();
}
}
catch (IOException e)
Expand Down
15 changes: 8 additions & 7 deletions shadowsocks-csharp/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion shadowsocks-csharp/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
Expand Down
Loading

0 comments on commit 5ecad22

Please sign in to comment.