diff options
Diffstat (limited to 'server.d')
-rw-r--r-- | server.d | 18 |
1 files changed, 4 insertions, 14 deletions
@@ -1,7 +1,5 @@ -import std.socket, std.stdio, - std.conv, std.file, - std.string; -import serverutils; +import std.socket, std.conv; +import context; void main(string[] args) { if (args.length != 2) return; @@ -9,17 +7,9 @@ void main(string[] args) { sock.bind(new InternetAddress("127.0.0.1", to!ushort(args[1]))); sock.listen(1000); while (true) { - auto level = 0; auto pair = sock.accept(); - char[255] filename; - auto len = pair.receive(filename); - auto file = filename[0 .. len]; - file = strip(file); - if (inRoot(file)) { - pair.send(readText(file)); - } else { - pair.send("ERROR: Client left root!\n"); - } + auto context = new ClientContext(pair); + context.handle(); pair.shutdown(SocketShutdown.BOTH); pair.close(); } |