Author Topic: Fileserver Replacement in Python and C++  (Read 11069 times)

0 Members and 1 Guest are viewing this topic.

Offline Thomas

  • Major
  • *
  • Posts: 76
    • mnus.de
Fileserver Replacement in Python and C++
« on: May 17, 2011, 08:35:26 am »
I reimplemented Soldat's internal fileserver in Python.
It is more stable than Soldat's one and should be able to take a massive amount of requests.

What it does:
  • Serves only files that Soldat's fileserver would serve aswell
  • Caches all files in memory (for now) as soon as they're first requested
  • Handles lots of connections parallely through its non-blocking design
  • Can listen on multiple ports and interfaces

What it doesn't do:
  • Doesn't work with IPv6 (not yet at least)

How to use it:
All setup happens in server.py which loads the FileServe module. Basically you just create an instance of FileServe, addPort()s on it and then run().
You have to disable Soldat’s fileserver. Just set Allow_Download=0 in the [Network] section of soldat.ini.

Some documentation:
Code: [Select]
FileServe.addPort(port, ip=None): binds to port and optionally to ip instead of the default IP
FileServe.setDefaultIp(ip): sets the default IP to bind to
FileServe.run(): runs the server in an infinite loop
FileServe.setDataDir(dir): specify a directory where data files can be found (default: current working dir)

Download from my server or from the attachment.

C++ version:
I also did an implementation in C++11 with Boost. The repo can be found at https://git.mnus.de/minus/soldat_fileserver, the latest code is attached.
« Last Edit: March 05, 2016, 11:43:58 am by Thomas »

Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Fileserver Replacement in Python
« Reply #1 on: May 17, 2011, 09:57:00 am »
Good job, minus! :)
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline Thomas

  • Major
  • *
  • Posts: 76
    • mnus.de
Re: Fileserver Replacement in Python
« Reply #2 on: October 20, 2011, 06:15:30 am »
I wonder how how stable and fast it really is. Anyone mind making a load test? And maybe compare it to soldatserver :D

Offline Thomas

  • Major
  • *
  • Posts: 76
    • mnus.de
Re: Fileserver Replacement in Python
« Reply #3 on: November 25, 2015, 02:29:22 pm »
Excuse me for bumping my 4 year old topic with 2 year old update: I did an implementation of the protocol in C++ as well: https://git.mnus.de/minus/soldat_fileserver

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: Fileserver Replacement in Python
« Reply #4 on: November 26, 2015, 11:34:05 pm »
Excuse me for bumping my 4 year old topic with 2 year old update: I did an implementation of the protocol in C++ as well: https://git.mnus.de/minus/soldat_fileserver

Where are the tests?
There are other worlds than these

Offline Thomas

  • Major
  • *
  • Posts: 76
    • mnus.de
Re: Fileserver Replacement in Python
« Reply #5 on: November 27, 2015, 04:41:13 am »
What are tests?

Offline jrgp

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 5037
Re: Fileserver Replacement in Python
« Reply #6 on: November 27, 2015, 11:41:12 am »
What are tests?

Unit and integration tests... to make sure the individual components of your app work as expected. They're all the rage for modern software development.
There are other worlds than these

Offline soldat-game

  • Camper
  • ***
  • Posts: 407
Re: Fileserver Replacement in Python
« Reply #7 on: December 02, 2015, 07:51:33 am »
I understand that the server reaches a performance similar to the revolution in soldat 1.7

Offline Thomas

  • Major
  • *
  • Posts: 76
    • mnus.de
Re: Fileserver Replacement in Python
« Reply #8 on: March 05, 2016, 07:05:00 am »
Well, it does handle multiple clients concurrently with a pretty much static set of resources, I don't know how Soldat behaves there internally. I mainly wrote this because Soldat's file downloads were (are?) being broken/not working well. (Also for fun.) It's not extensively tested (neither of the both implementations), but the C++ one has a little tool to send requests to the file server (which I also used to measure performance, see the project's README).

In other news, I just refactored the code a bit. Primarily with regard to boost usage; replacing some stuff with C++11 features. (boost::bind → std::bind/lambdas, boost::shared_ptr → std::shared_ptr). I updated the first post and attached the latest code there.