WIP
This commit is contained in:
parent
93bb1615df
commit
4ef21cdd32
|
@ -1,53 +1,53 @@
|
|||
module server.listeners;
|
||||
|
||||
import server.types;
|
||||
import std.socket : Socket;
|
||||
import std.socket : Socket, Address, AddressFamily, SocketType;
|
||||
|
||||
public class UNIXListener : BesterListener
|
||||
{
|
||||
this(BesterServer besterServer, string path)
|
||||
this(BesterServer besterServer, Address address)
|
||||
{
|
||||
super(besterServer);
|
||||
setServerSocket(setupUNIXSocket(path));
|
||||
setServerSocket(setupUNIXSocket(address));
|
||||
}
|
||||
|
||||
private Socket setupUNIXSocket(string path)
|
||||
private Socket setupUNIXSocket(Address address)
|
||||
{
|
||||
Socket unixSocket;
|
||||
|
||||
Socket unixSocket = new Socket(AddressFamily.UNIX, SocketType.STREAM);
|
||||
unixSocket.bind(address);
|
||||
return unixSocket;
|
||||
}
|
||||
}
|
||||
|
||||
public class TCP4 : BesterListener
|
||||
public class TCP4Listener : BesterListener
|
||||
{
|
||||
this(BesterServer besterServer, string path)
|
||||
this(BesterServer besterServer, Address address)
|
||||
{
|
||||
super(besterServer);
|
||||
setServerSocket(setupUNIXSocket(path));
|
||||
setServerSocket(setupTCP4Socket(address));
|
||||
}
|
||||
|
||||
private Socket setupUNIXSocket(string path)
|
||||
|
||||
private Socket setupTCP4Socket(Address address)
|
||||
{
|
||||
Socket unixSocket;
|
||||
|
||||
return unixSocket;
|
||||
Socket tcp4Socket = new Socket(AddressFamily.INET, SocketType.STREAM);
|
||||
tcp4Socket.bind(address);
|
||||
return tcp4Socket;
|
||||
}
|
||||
}
|
||||
|
||||
public class TCP6 : BesterListener
|
||||
public class TCP6Listener : BesterListener
|
||||
{
|
||||
this(BesterServer besterServer, string path)
|
||||
this(BesterServer besterServer, Address address)
|
||||
{
|
||||
super(besterServer);
|
||||
setServerSocket(setupUNIXSocket(path));
|
||||
setServerSocket(setupTCP6Socket(address));
|
||||
}
|
||||
|
||||
private Socket setupUNIXSocket(string path)
|
||||
|
||||
private Socket setupTCP6Socket(Address address)
|
||||
{
|
||||
Socket unixSocket;
|
||||
|
||||
return unixSocket;
|
||||
Socket tcp6Socket = new Socket(AddressFamily.INET6, SocketType.STREAM);
|
||||
tcp6Socket.bind(address);
|
||||
return tcp6Socket;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import std.socket : SocketOSException;
|
|||
import utils.debugging : debugPrint;
|
||||
import std.stdio : File, writeln;
|
||||
import std.json : parseJSON, JSONValue;
|
||||
import server.listeners;
|
||||
|
||||
JSONValue getConfig(string configurationFilePath)
|
||||
{
|
||||
|
@ -43,6 +44,9 @@ BesterListener[] getListeners(JSONValue networkBlock)
|
|||
debugPrint("<<< IPv4 TCP Block >>>\n" ~ inet4TCPBlock.toPrettyString());
|
||||
string inet4Address = inet4TCPBlock["address"].str();
|
||||
ushort inet4Port = to!(ushort)(inet4TCPBlock["port"].str());
|
||||
TCP4Listener tcp4Listener = new TCP4Listener();
|
||||
|
||||
|
||||
|
||||
/* Look for IPv6 TCP block */
|
||||
JSONValue inet6TCPBlock = networkBlock["tcp6"];
|
||||
|
|
Loading…
Reference in New Issue