Skip to content
This repository has been archived by the owner on Sep 2, 2019. It is now read-only.

Commit

Permalink
MobileProc 감지 기능 추가.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZCube committed Feb 28, 2017
1 parent 55a504d commit f3cd18e
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 132 deletions.
4 changes: 0 additions & 4 deletions ACTWebSocket.Core/ACTWebSocket.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@
<HintPath>C:\Program Files (x86)\Advanced Combat Tracker\Advanced Combat Tracker.exe</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BouncyCastle.Crypto, Version=1.8.1.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.1\lib\BouncyCastle.Crypto.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DotNetZip, Version=1.10.1.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.10.1\lib\net20\DotNetZip.dll</HintPath>
<Private>True</Private>
Expand Down
188 changes: 149 additions & 39 deletions ACTWebSocket.Core/ACTWebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public class ACTWebSocketMain : UserControl, IActPluginV1, PluginDirectory
private Button buttonOverlay;
private ProgressBar progressBar;
private Button buttonDownload;
private CheckBox SSLUse;
private GroupBox groupBox4;
private Button buttonCopyCode;
private Label label1;
private TextBox hashCode;
private CheckBox chatFilter;

public void SetSkinDir(string path)
Expand Down Expand Up @@ -163,14 +166,18 @@ private void InitializeComponent()
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.FileSkinListView = new System.Windows.Forms.ListView();
this.Title = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.SSLUse = new System.Windows.Forms.CheckBox();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.buttonCopyCode = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.hashCode = new System.Windows.Forms.TextBox();
this.startoption.SuspendLayout();
this.hostdata.SuspendLayout();
this.othersets.SuspendLayout();
this.serverStatus.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// port
Expand Down Expand Up @@ -248,7 +255,6 @@ private void InitializeComponent()
// startoption
//
this.startoption.BackColor = System.Drawing.Color.Transparent;
this.startoption.Controls.Add(this.SSLUse);
this.startoption.Controls.Add(this.skinOnAct);
this.startoption.Controls.Add(this.UPNPUse);
this.startoption.Controls.Add(this.randomURL);
Expand Down Expand Up @@ -472,17 +478,36 @@ private void InitializeComponent()
//
resources.ApplyResources(this.Title, "Title");
//
// SSLUse
// groupBox4
//
resources.ApplyResources(this.SSLUse, "SSLUse");
this.SSLUse.BackColor = System.Drawing.Color.Transparent;
this.SSLUse.Name = "SSLUse";
this.SSLUse.UseVisualStyleBackColor = false;
this.SSLUse.CheckedChanged += new System.EventHandler(this.SSLUse_CheckedChanged);
this.groupBox4.Controls.Add(this.buttonCopyCode);
this.groupBox4.Controls.Add(this.label1);
this.groupBox4.Controls.Add(this.hashCode);
resources.ApplyResources(this.groupBox4, "groupBox4");
this.groupBox4.Name = "groupBox4";
this.groupBox4.TabStop = false;
//
// buttonCopyCode
//
resources.ApplyResources(this.buttonCopyCode, "buttonCopyCode");
this.buttonCopyCode.Name = "buttonCopyCode";
this.buttonCopyCode.UseVisualStyleBackColor = true;
this.buttonCopyCode.Click += new System.EventHandler(this.buttonCopyCode_Click);
//
// label1
//
resources.ApplyResources(this.label1, "label1");
this.label1.Name = "label1";
//
// hashCode
//
resources.ApplyResources(this.hashCode, "hashCode");
this.hashCode.Name = "hashCode";
//
// ACTWebSocketMain
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
Expand All @@ -502,6 +527,8 @@ private void InitializeComponent()
this.groupBox2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);

}
Expand Down Expand Up @@ -620,7 +647,7 @@ public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText)
BeforeLogLineReadUse.Checked = BeforeLogLineRead;
OnLogLineReadUse.Checked = OnLogLineRead;
MiniParseUse.Checked = MiniParse;
SSLUse.Checked = UseSSL;
//SSLUse.Checked = UseSSL;
UPNPUse.Checked = UseUPnP;
randomURL.Checked = RandomURL;
skinOnAct.Checked = SkinOnAct;
Expand Down Expand Up @@ -749,14 +776,14 @@ void LoadSettings()
{
UseUPnP = false;
}
if (obj.TryGetValue("UseSSL", out token))
{
UseSSL = token.ToObject<bool>();
}
else
{
UseSSL = false;
}
//if (obj.TryGetValue("UseSSL", out token))
//{
// UseSSL = token.ToObject<bool>();
//}
//else
//{
// UseSSL = false;
//}
if (obj.TryGetValue("SkinOnAct", out token))
{
SkinOnAct = token.ToObject<bool>();
Expand Down Expand Up @@ -840,7 +867,7 @@ void SaveSettings()
obj.Add("Hostname", Hostname);
obj.Add("RandomURL", RandomURL);
obj.Add("UseUPnP", UseUPnP);
obj.Add("UseSSL", UseSSL);
//obj.Add("UseSSL", UseSSL);
obj.Add("AutoRun", AutoRun);
obj.Add("AutoOverlay", AutoOverlay);
obj.Add("BeforeLogLineRead", BeforeLogLineRead);
Expand Down Expand Up @@ -971,7 +998,7 @@ public bool RandomURL
}
}

public bool UseSSL { get; set; }
//public bool UseSSL { get; set; }
public bool UseUPnP { get; set; }
public bool AutoRun { get; set; }
public bool AutoOverlay { get; set; }
Expand Down Expand Up @@ -1032,11 +1059,11 @@ public void StartServer()
{
if (UseUPnP)
{
core.StartServer(localhostOnly ? "127.0.0.1" : "0.0.0.0", Port, UPnPPort, Hostname, SkinOnAct, UseSSL);
core.StartServer(localhostOnly ? "127.0.0.1" : "0.0.0.0", Port, UPnPPort, Hostname, SkinOnAct, false);
}
else
{
core.StartServer(localhostOnly ? "127.0.0.1" : "0.0.0.0", Port, Port, Hostname, SkinOnAct, UseSSL);
core.StartServer(localhostOnly ? "127.0.0.1" : "0.0.0.0", Port, Port, Hostname, SkinOnAct, false);
}
}
catch (Exception e)
Expand All @@ -1048,7 +1075,7 @@ public void StartServer()
//OnLogLineReadUse.Enabled = false;
//MiniParseUse.Enabled = false;
//chatFilter.Enabled = false;
SSLUse.Enabled = false;
//SSLUse.Enabled = false;
skinOnAct.Enabled = false;
UPNPUse.Enabled = false;
randomURL.Enabled = false;
Expand All @@ -1059,26 +1086,88 @@ public void StartServer()
buttonOff.Enabled = true;


string serviceType = "_overlay._tcp";
Task serviceTask = new Task(() =>
{
try
{
string serviceType = "_overlay._tcp";
lock (serviceLock)
{
if (serviceBrowser != null)
{
serviceBrowser.StopBrowse();
serviceBrowser = null;
}

{
serviceBrowser = new ServiceBrowser();
serviceBrowser.ServiceAdded += onServiceAdded;
serviceBrowser.ServiceRemoved += onServiceRemoved;
serviceBrowser.ServiceChanged += onServiceChanged;

Console.WriteLine("Browsing for type: {0}", serviceType);
serviceBrowser.StartBrowse(serviceType);
Console.ReadLine();
}
}


String url = ("http") + "://" + Hostname + ":" + Port + "/";
if (ACTWebSocketCore.randomDir != null)
{
url += ACTWebSocketCore.randomDir + "/";
}
string address = string.Format("http://zcube.kr:8585/shorten?longUrl={0}", Uri.EscapeDataString(url));

HttpWebRequest request = HttpWebRequest.CreateHttp(address);
WebResponse response = request.GetResponse();
String res = "";
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
res = reader.ReadToEnd();
}

res = res;
JObject obj = JObject.Parse(res);
JToken token;
int status_code = 0;
String hash = "";
if (obj.TryGetValue("status_code", out token))
{
status_code = token.ToObject<int>();
}

ServiceBrowser serviceBrowser = new ServiceBrowser();
serviceBrowser.ServiceAdded += onServiceAdded;
serviceBrowser.ServiceRemoved += onServiceRemoved;
serviceBrowser.ServiceChanged += onServiceChanged;
JObject data = (JObject)obj["data"];
if (data != null && data.TryGetValue("hash", out token))
{
hash = token.ToObject<String>();
}
hashCode.Text = hash;
}
catch (Exception e)
{

Console.WriteLine("Browsing for type: {0}", serviceType);
serviceBrowser.StartBrowse(serviceType);
Console.ReadLine();
}
});
serviceTask.Start();
}

public void StopServer()
{
if (serviceBrowser != null)
{
lock (serviceLock)
{
serviceBrowser.StopBrowse();
serviceBrowser = null;
}
}
core.StopServer();
//BeforeLogLineReadUse.Enabled = true;
//OnLogLineReadUse.Enabled = true;
//MiniParseUse.Enabled = true;
//chatFilter.Enabled = true;
SSLUse.Enabled = true;
//SSLUse.Enabled = true;
skinOnAct.Enabled = true;
UPNPUse.Enabled = true;
randomURL.Enabled = true;
Expand Down Expand Up @@ -1229,7 +1318,7 @@ public string getURLPath(string skinPath = "", bool withRandomURL = true)
{
try
{
string fullURL = (UseSSL ? "https" : "http") + url + Uri.EscapeDataString(skinPath);
string fullURL = ("http") + url + Uri.EscapeDataString(skinPath);
fullURL = fullURL.Replace("%5C", "/");
fullURL = fullURL.Replace("%2F", "/");
return fullURL;
Expand Down Expand Up @@ -1262,7 +1351,7 @@ private void UpdateFormSettings()
BeforeLogLineRead = BeforeLogLineReadUse.Checked;
OnLogLineRead = OnLogLineReadUse.Checked;
MiniParse = MiniParseUse.Checked;
UseSSL = SSLUse.Checked;
//UseSSL = SSLUse.Checked;
UseUPnP = UPNPUse.Checked;
RandomURL = randomURL.Checked;
SkinOnAct = skinOnAct.Checked;
Expand Down Expand Up @@ -1313,7 +1402,7 @@ void onServiceAdded(object sender, ServiceAnnouncementEventArgs e)
HttpWebRequest webRequest = WebRequest.CreateHttp(uri);
webRequest.Headers.Add("Port", Port.ToString());
webRequest.Headers.Add("IP", hostnames.Text.ToString());
webRequest.Headers.Add("SCHEME", UseSSL ? "https" : "http");
webRequest.Headers.Add("SCHEME", "http");
webRequest.BeginGetResponse(null, webRequest);
}

Expand Down Expand Up @@ -1472,7 +1561,6 @@ private void AddWebURL(string a)
});
Task UITask = task.ContinueWith((t) =>
{
lock (core.skinObject)
{
bool find = false;
foreach (ListViewItem i in WebSkinListView.Items)
Expand All @@ -1492,6 +1580,7 @@ private void AddWebURL(string a)
WebSkinListView.Items.Add(lvi);
if (core != null)
{
lock (core.skinObject)
{
JObject skinInfo = new JObject();
skinInfo["Title"] = title;
Expand All @@ -1511,6 +1600,9 @@ private void AddWebURL(string a)
}, TaskScheduler.FromCurrentSynchronizationContext());
}
List<Task> tasklist = new List<Task>();
private ServiceBrowser serviceBrowser;
private Object serviceLock = new Object();

private void AddFileURL(string a)
{
a = a.Replace("\\", "/");
Expand All @@ -1521,7 +1613,6 @@ private void AddFileURL(string a)
});
Task UITask = task.ContinueWith((t) =>
{
lock (core.skinObject)
{
bool find = false;
foreach (ListViewItem i in FileSkinListView.Items)
Expand Down Expand Up @@ -1641,7 +1732,7 @@ private void UPNPUse_CheckedChanged(object sender, EventArgs e)

private void UseSSL_CheckedChanged(object sender, EventArgs e)
{
UseSSL = SSLUse.Checked;
//UseSSL = SSLUse.Checked;
}

private void skinOnAct_CheckedChanged(object sender, EventArgs e)
Expand All @@ -1650,6 +1741,24 @@ private void skinOnAct_CheckedChanged(object sender, EventArgs e)
buttonRefresh_Click(sender, e);
}

private void buttonCopyCode_Click(object sender, EventArgs e)
{
String id = hashCode.Text;
Task task = Task.Factory.StartNew(() =>
{
string url = ("http") + getURLPath("");
string address = string.Format("https://dev.zcube.kr/fcmhelper/v1/message?id={0}&message={1}", Uri.EscapeDataString(id), Uri.EscapeDataString(url));

HttpWebRequest request = HttpWebRequest.CreateHttp(address);
WebResponse response = request.GetResponse();
String res = "";
using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
res = reader.ReadToEnd();
}
});
}

void UpdateOverlayProc()
{
bool b = File.Exists(overlayProcExe);
Expand Down Expand Up @@ -1961,7 +2070,8 @@ private void ServerUrlChanged()

private void SSLUse_CheckedChanged(object sender, EventArgs e)
{

//UseSSL = SSLUse.Checked;
}

}
}
Loading

0 comments on commit f3cd18e

Please sign in to comment.