Limit server is server which is intended to reply to requests from Nginx LimitProxy module and add traffic send by traffic filter. There is one main thread which:
  • after starting reads local configuration read_local_config(), and daemonize if necessary
  • initialize worker threads - each worker has his own pipe and loop
    When new connection from nginx is made, main loop is activated and do_accept() is called. Then the connection is stored in worker thread queue (using round-robin algorithm to chose thread) and one byte is write to worker thread pipe. Byte in pipe call the pipe_cb() function, which registers write and read callback.
  • calls the do_register() function which inform the main server about our server
  • waits for updates from main server
  • if requested sends the diff information to main server
When new data is send to server, read_cb() is called. This function reads the entire packet and if no errors occurs call protocol_core().
Depending on packet type protocol_core() could perform following operations:
  • if asked for authorization (limit_server_protocol_check) finds host and id in local DB and decides whether to deny or allow the acces. If user wasn't found requests for information from main server (limit_server_request_uid).
  • if asked for update (limit_server_protocol_update) adds received data to user stored transfer
  • if asked for diff (limit_server_protocol_send_diff), prepares packet and enqueue it to ouput queue. All changed user transfer information is send to main server
  • if new host destination is received (limit_server_update_add_dest) new host with transfer limit information is created
  • if new limit information for user is received updates the hashtable (limit_server_update_set_dest_specyfic_config)
  • if new global transfer is received for user updates it in hashtable (limit_server_update_dest_diff)
  • if new global transfer is received for host updates it in hashtable (limit_server_update_dest_host_diff)
  • if information for unactive ID is received adds it to hashtable (limit_server_answer_uid)
Copyright 2009 DreamLab Sp. z o.o.
Authors: Grzegorz Jablonski, Michal Szklarzewicz

Generated on Thu Oct 22 16:31:07 2009 for Limit server by  doxygen 1.5.6