share over LAN

This commit is contained in:
clowwindy
2014-11-09 13:31:33 +08:00
parent 492869fd5c
commit e4ff27a1fc
8 changed files with 122 additions and 67 deletions
@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace Shadowsocks.Controller
{
@@ -25,6 +26,7 @@ namespace Shadowsocks.Controller
public event EventHandler ConfigChanged;
public event EventHandler EnableStatusChanged;
public event EventHandler ShareOverLANStatusChanged;
// when user clicked Edit PAC, and PAC file has already created
public event EventHandler<PathEventArgs> PACFileReadyToOpen;
@@ -33,14 +35,14 @@ namespace Shadowsocks.Controller
{
_config = Configuration.Load();
polipoRunner = new PolipoRunner();
polipoRunner.Start(_config.GetCurrentServer());
local = new Local(_config.GetCurrentServer());
polipoRunner.Start(_config);
local = new Local(_config);
try
{
local.Start();
pacServer = new PACServer();
pacServer.PACFileChanged += pacServer_PACFileChanged;
pacServer.Start();
pacServer.Start(_config);
}
catch (Exception e)
{
@@ -58,9 +60,9 @@ namespace Shadowsocks.Controller
local.Stop();
polipoRunner.Stop();
polipoRunner.Start(_config.GetCurrentServer());
polipoRunner.Start(_config);
local = new Local(_config.GetCurrentServer());
local = new Local(_config);
local.Start();
if (ConfigChanged != null)
@@ -92,6 +94,18 @@ namespace Shadowsocks.Controller
}
}
public void ToggleShareOverLAN(bool enabled)
{
_config.shareOverLan = enabled;
SaveConfig(_config);
pacServer.Stop();
pacServer.Start(_config);
if (ShareOverLANStatusChanged != null)
{
ShareOverLANStatusChanged(this, new EventArgs());
}
}
public void Stop()
{
if (stopped)