another socket refactor
fuck
This commit is contained in:
parent
8b9cbd0550
commit
3f125e5463
18 changed files with 97 additions and 24 deletions
2
client/ip.php
Normal file
2
client/ip.php
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<?php
|
||||||
|
echo $_SERVER["REMOTE_ADDR"];
|
|
@ -41,9 +41,9 @@ namespace CircleScape {
|
||||||
return Settings[section];
|
return Settings[section];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Section General {
|
public static Instance General {
|
||||||
get {
|
get {
|
||||||
return Settings["General"];
|
return Settings["General"][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Square;
|
using Square;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Kneesocks.WebSocket;
|
using Kneesocks;
|
||||||
|
|
||||||
namespace CircleScape {
|
namespace CircleScape {
|
||||||
class Entrypoint {
|
class Entrypoint {
|
||||||
|
|
|
@ -8,7 +8,7 @@ using Square;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace Kneesocks.WebSocket {
|
namespace Kneesocks {
|
||||||
public class Connection {
|
public class Connection {
|
||||||
private bool Initialized = false;
|
private bool Initialized = false;
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Square;
|
using Square;
|
||||||
|
|
||||||
namespace Kneesocks.WebSocket {
|
namespace Kneesocks {
|
||||||
public class Frame {
|
public class Frame {
|
||||||
public enum kClosingReason {
|
public enum kClosingReason {
|
||||||
Normal = 1000,
|
Normal = 1000,
|
|
@ -5,7 +5,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Square;
|
using Square;
|
||||||
|
|
||||||
namespace Kneesocks.WebSocket {
|
namespace Kneesocks {
|
||||||
public class Handshake {
|
public class Handshake {
|
||||||
private const string HttpVersion = "1.1";
|
private const string HttpVersion = "1.1";
|
||||||
public bool IsRequest = false;
|
public bool IsRequest = false;
|
|
@ -40,14 +40,14 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="WebSocket\Connection.cs" />
|
<Compile Include="Connection.cs" />
|
||||||
<Compile Include="WebSocket\Frame.cs" />
|
<Compile Include="Frame.cs" />
|
||||||
<Compile Include="WebSocket\Handshake.cs" />
|
<Compile Include="Handshake.cs" />
|
||||||
<Compile Include="WebSocket\Pool.cs" />
|
<Compile Include="Pool.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="WebSocket\ReadBuffer.cs" />
|
<Compile Include="ReadBuffer.cs" />
|
||||||
<Compile Include="WebSocket\Server.cs" />
|
<Compile Include="Server.cs" />
|
||||||
<Compile Include="WebSocket\Stack.cs" />
|
<Compile Include="Stack.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Square\Square.csproj">
|
<ProjectReference Include="..\Square\Square.csproj">
|
||||||
|
@ -55,9 +55,7 @@
|
||||||
<Name>Square</Name>
|
<Name>Square</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="UDP\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Kneesocks.WebSocket {
|
namespace Kneesocks {
|
||||||
public class Pool<T> where T : Connection {
|
public class Pool<T> where T : Connection {
|
||||||
// number of threads that should be started when the pool is created
|
// number of threads that should be started when the pool is created
|
||||||
// these threads will run for as long as the pool exists
|
// these threads will run for as long as the pool exists
|
|
@ -5,11 +5,11 @@ using System.Runtime.InteropServices;
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("Kneesocks.WebSocket")]
|
[assembly: AssemblyTitle("Kneesocks")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("Kneesocks.WebSocket")]
|
[assembly: AssemblyProduct("Kneesocks")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Kneesocks.WebSocket {
|
namespace Kneesocks {
|
||||||
internal class ReadBuffer {
|
internal class ReadBuffer {
|
||||||
private const int BufferSize = 1024;
|
private const int BufferSize = 1024;
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace Kneesocks.WebSocket {
|
namespace Kneesocks {
|
||||||
public abstract class Server {
|
public abstract class Server {
|
||||||
protected TcpListener Socket;
|
protected TcpListener Socket;
|
||||||
protected Thread Listener = null;
|
protected Thread Listener = null;
|
|
@ -5,7 +5,7 @@ using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
namespace Kneesocks.WebSocket {
|
namespace Kneesocks {
|
||||||
internal class Stack<T> where T : Connection {
|
internal class Stack<T> where T : Connection {
|
||||||
private Pool<T> PoolRef = null;
|
private Pool<T> PoolRef = null;
|
||||||
private List<T> Clients = new List<T>();
|
private List<T> Clients = new List<T>();
|
15
server/ServerList.cs
Normal file
15
server/ServerList.cs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CircleScape {
|
||||||
|
static class ServerList {
|
||||||
|
public static Dictionary<int, IPEndPoint> Servers { get; private set; }
|
||||||
|
= new Dictionary<int, IPEndPoint>();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kneesocks.WebSocket;
|
using Kneesocks;
|
||||||
using Square;
|
using Square;
|
||||||
|
|
||||||
namespace CircleScape.Socks {
|
namespace CircleScape.Socks {
|
||||||
|
|
11
server/Socks/MasterUdpClient.cs
Normal file
11
server/Socks/MasterUdpClient.cs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CircleScape.Socks {
|
||||||
|
class MasterUdpClient {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
44
server/Socks/MasterUdpServer.cs
Normal file
44
server/Socks/MasterUdpServer.cs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CircleScape.Socks {
|
||||||
|
static class MasterUdpServer {
|
||||||
|
private static UdpClient Sock;
|
||||||
|
private static Thread ListeningThread = null;
|
||||||
|
private static bool IsOpen = false;
|
||||||
|
|
||||||
|
public static void Initialize() {
|
||||||
|
if(!IsOpen && ListeningThread == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
short port = (short)Configuration.General["Master Port"];
|
||||||
|
Sock = new UdpClient(port);
|
||||||
|
|
||||||
|
IsOpen = true;
|
||||||
|
ListeningThread = new Thread(new ThreadStart(Listener));
|
||||||
|
ListeningThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Listener() {
|
||||||
|
while(IsOpen) {
|
||||||
|
while(Sock.Available > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread.Sleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Close() {
|
||||||
|
IsOpen = false;
|
||||||
|
ListeningThread.Join();
|
||||||
|
ListeningThread = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kneesocks.WebSocket;
|
using Kneesocks;
|
||||||
using Square;
|
using Square;
|
||||||
using CircleScape.Encryption;
|
using CircleScape.Encryption;
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ Master Port = 16670
|
||||||
; this value used if the max users isn't specified in a server instance
|
; this value used if the max users isn't specified in a server instance
|
||||||
Max Users = 100
|
Max Users = 100
|
||||||
|
|
||||||
|
; url to a web page that prints out the public ip address of the requester
|
||||||
|
Ip Checker = http://aroltd.com/ip.php
|
||||||
|
|
||||||
[Server]
|
[Server]
|
||||||
Id = 1
|
Id = 1
|
||||||
Port = 6770
|
Port = 6770
|
||||||
|
|
Loading…
Reference in a new issue