diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index 15c04f6..378c5c5 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -2695,12 +2695,14 @@ public define Start_Web_Sites_Result with http_server_r = start_http_server(ip_address,http_port, map(get_description,web_sites), - load_denial_of_service_info), + load_denial_of_service_info, + shutdown_required), with https_server_r = start_https_server(ip_address,https_port, ssl_certificate_common_name, map(get_description,web_sites), - load_denial_of_service_info), + load_denial_of_service_info, + shutdown_required), if http_server_r is ok(http_server) then ( diff --git a/web/CXM_multihost_http_server.anubis b/web/CXM_multihost_http_server.anubis index e244107..d4512fc 100644 --- a/web/CXM_multihost_http_server.anubis +++ b/web/CXM_multihost_http_server.anubis @@ -3168,12 +3168,17 @@ define One BufferedConnection connection, Bool is_https, DenialOfService dos, - SState s + SState s, + (One) -> Bool shutdown_required ) = //t0 <- (UTime)unow; with start_time = (Int)now, s.sttm <- start_time; //println("Request time: " + format_http_date(start_time)); + if shutdown_required(unique) then + println("shutdown required on http_https_handler"); + unique + else if dos is denial_of_service(mc_v,rld_v,hd_v,ad_v,ld_v,ra_v) then if remote_IP_address_and_port(connection.conn) is (ip_addr,port) then if read_request_line(connection) is @@ -3210,7 +3215,7 @@ define One ok(body) then www_url_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, body, generate_tt); //it's HTTP 1.1 keep-alive is default - http_https_handler(sites, connection, is_https, dos, s) + http_https_handler(sites, connection, is_https, dos, s, shutdown_required) } //MULTIPART_FORM_DATA multipart_form_data then @@ -3250,7 +3255,7 @@ define One multipart_form_data_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, desc.site_directory + tmp_body_file, generate_tt, s); //it's HTTP 1.1 keep-alive is default - http_https_handler(sites, connection, is_https, dos, s) + http_https_handler(sites, connection, is_https, dos, s, shutdown_required) else println("Can't copy data from stream to temporary file "), @@ -3264,7 +3269,7 @@ define One multipart_form_data_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, desc.site_directory + tmp_body_file, generate_tt, s); //it's HTTP 1.1 keep-alive is default - http_https_handler(sites, connection, is_https, dos, s) + http_https_handler(sites, connection, is_https, dos, s, shutdown_required) else println("Can't copy data from stream to temporary file ") @@ -3300,7 +3305,8 @@ define Server -> ((RWStream) -> One) make_http_handler ( List(Web_Site_Description) sites, - DenialOfService dos + DenialOfService dos, + (One) -> Bool shutdown_required ) = (Server server) |-> (RWStream conn) |-> if remote_IP_address_and_port(conn) is (addr,_) then @@ -3308,31 +3314,33 @@ define Server -> ((RWStream) -> One) then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") else with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), - http_https_handler(sites, connection, false, dos, sstate(var(0),var(0))). + http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). public define One http_direct_handler ( List(Web_Site_Description) sites, RWStream conn, - DenialOfService dos + DenialOfService dos, + (One) -> Bool shutdown_required ) = if remote_IP_address_and_port(conn) is (addr,_) then if is_dubious_IP(addr,dos) then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n") else with connection = buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])), - http_https_handler(sites, connection, false, dos, sstate(var(0),var(0))). + http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required). define Server -> (SSL_Connection -> One) make_https_handler ( List(Web_Site_Description) sites, - DenialOfService dos + DenialOfService dos, + (One) -> Bool shutdown_required ) = (Server server) |-> (SSL_Connection conn) |-> with connection = buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])), - http_https_handler(sites, connection, true, dos, sstate(var(0),var(0))). + http_https_handler(sites, connection, true, dos, sstate(var(0),var(0)), shutdown_required). @@ -3614,11 +3622,12 @@ public define StartServerResult Word32 ip_address, Word32 port, List(Web_Site_Description) sites, - DenialOfService dos + DenialOfService dos, + (One) -> Bool shutdown_required ) = create_directories(sites); start_http_server(ip_address,port, - make_http_handler(sites, dos), + make_http_handler(sites, dos, shutdown_required), 0, dos). @@ -3662,11 +3671,12 @@ public define StartServerResult Word32 port, String certificate_common_name, // of SSL server certificate List(Web_Site_Description) sites, - DenialOfService dos + DenialOfService dos, + (One) -> Bool shutdown_required ) = create_directories(sites); start_https_server(ip_address,port,certificate_common_name, - make_https_handler(sites, dos), + make_https_handler(sites, dos, shutdown_required), 0,dos). -- libgit2 0.21.4