Commit 6dc16ef7a3963549bafdcafa7098ed3d7bce5f4e

Authored by David RENÉ
1 parent 39ca95a4

remove denial of service which is not serializable and not working since anubis …

…1.17 (Anubis 1.17 take more care about serializable type and warn about it if a non serializable type will is in serialization process)
generic/session.anubis
... ... @@ -7,6 +7,7 @@
7 7 */
8 8  
9 9 transmit xlib/generic/types/session.anubis
  10 +read system/data_io.anubis
10 11  
11 12 public define Var(List(Session_Field))
12 13 empty_fields_list =
... ... @@ -32,7 +33,7 @@ public define Var(List(Session_Field))
32 33 bool(v) then bool(v),
33 34 int(v) then int(v),
34 35 db_id(v) then db_id(v),
35   - message(v) then message(v),
  36 + message(v) then message(if unflatten_message(make_data_io(v)) is {failure then message(0), success(msg) then msg}),
36 37 byte_array(v) then byte_array(v),
37 38 float(v) then float(v),
38 39 word128(v) then word128(v),
... ... @@ -61,7 +62,7 @@ public define List(Session_Field_No_Var)
61 62 bool(v) then bool(v),
62 63 int(v) then int(v),
63 64 db_id(v) then db_id(v),
64   - message(v) then message(v),
  65 + message(v) then message(if flatten_message(v) is {failure then constant_byte_array(0,0), success(ba) then ba}),
65 66 byte_array(v) then byte_array(v),
66 67 float(v) then float(v),
67 68 word128(v) then word128(v),
... ...
generic/types/session.anubis
... ... @@ -35,7 +35,7 @@ public type Session_Field_Datum_No_Var:
35 35 bool(Bool), //fully implented
36 36 int(Int), //fully implemented
37 37 db_id(DB_id),
38   - message(Message), //fully implemented
  38 + message(ByteArray), //fully implemented
39 39 byte_array(ByteArray),
40 40 float(Float),
41 41 word128(Word128),
... ...
web/CXM_making_a_web_site.anubis
... ... @@ -3006,13 +3006,12 @@ public define Start_Web_Sites_Result
3006 3006 with http_server_r =
3007 3007 start_http_server(ip_address,http_port,
3008 3008 map(get_description,web_sites),
3009   - load_denial_of_service_info,
  3009 + //load_denial_of_service_info,
3010 3010 shutdown_required),
3011 3011 with https_server_r =
3012 3012 start_https_server(ip_address,https_port,
3013 3013 ssl_certificate_common_name,
3014 3014 map(get_description,web_sites),
3015   - load_denial_of_service_info,
3016 3015 shutdown_required),
3017 3016 if http_server_r is ok(http_server)
3018 3017 then
... ...
web/CXM_multihost_http_server.anubis
... ... @@ -351,8 +351,8 @@ public define StartServerResult
351 351 (
352 352 Word32 ip_address,
353 353 Word32 http_port,
354   - List(Web_Site_Description) web_sites,
355   - DenialOfService dos
  354 + List(Web_Site_Description) web_sites
  355 + //DenialOfService dos
356 356 ).
357 357  
358 358 public define StartServerResult
... ... @@ -361,8 +361,8 @@ public define StartServerResult
361 361 Word32 ip_address,
362 362 Word32 https_port,
363 363 String certificate_common_name,
364   - List(Web_Site_Description) web_sites,
365   - DenialOfService dos
  364 + List(Web_Site_Description) web_sites
  365 + //DenialOfService dos
366 366 ).
367 367  
368 368 The first argument 'ip_address' is the IP address on which the servers listen. If you
... ... @@ -2509,8 +2509,8 @@ define One
2509 2509 Word32 ip_addr, // of the client
2510 2510 HTTP_Request_Line request_line,
2511 2511 List(HTTP_header) headers,
2512   - ByteArray body,
2513   - One -> String generate_tt // trust ticket generation
  2512 + ByteArray body
  2513 + //One -> String generate_tt // trust ticket generation
2514 2514 ) =
2515 2515 with all_web_args = query_string(request_line) +
2516 2516 read_www_url_encoded_web_args(to_string(body),0),
... ... @@ -3014,7 +3014,6 @@ define One
3014 3014 HTTP_Request_Line request_line,
3015 3015 List(HTTP_header) headers,
3016 3016 String body_temp_file,
3017   - One -> String generate_tt,
3018 3017 SState s
3019 3018 ) =
3020 3019 if get_boundary(headers) is
... ... @@ -3285,7 +3284,7 @@ define Maybe((String,Web_Site_Description))
3285 3284  
3286 3285  
3287 3286  
3288   -define One -> String make_generate_trust_ticket(DenialOfService dos).
  3287 + define One -> String make_generate_trust_ticket(DenialOfService dos).
3289 3288  
3290 3289 define One
3291 3290 http_https_handler
... ... @@ -3293,7 +3292,6 @@ define One
3293 3292 List(Web_Site_Description) sites,
3294 3293 HTTP_Buffered_Connection connection,
3295 3294 Bool is_https,
3296   - DenialOfService dos,
3297 3295 SState s,
3298 3296 (One) -> Bool shutdown_required
3299 3297 ) =
... ... @@ -3305,7 +3303,7 @@ define One
3305 3303 println("shutdown required on http_https_handler");
3306 3304 unique
3307 3305 else
3308   - if dos is denial_of_service(mc_v,rld_v,hd_v,ad_v,ld_v,ra_v) then
  3306 + //if dos is denial_of_service(mc_v,rld_v,hd_v,ad_v,ld_v,ra_v) then
3309 3307 if remote_IP_address_and_port(connection.conn) is (ip_addr,port) then
3310 3308 if read_request_line(connection) is
3311 3309 {
... ... @@ -3330,7 +3328,7 @@ define One
3330 3328  
3331 3329 //Get the type of encoding which decide if we read the content in ByteArray for www_url or in
3332 3330 //temporary file for multipart.
3333   - with generate_tt = make_generate_trust_ticket(dos),
  3331 + //with generate_tt = make_generate_trust_ticket(dos),
3334 3332 if get_encoding_type(headers) is
3335 3333 {
3336 3334 //WWW_URL
... ... @@ -3340,9 +3338,9 @@ define One
3340 3338 error(msg) then log_journal_msg(desc,format(msg)),
3341 3339 ok(body) then
3342 3340 //HERE produce the answer of the server
3343   - www_url_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, body, generate_tt);
  3341 + www_url_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, body);
3344 3342 //it's HTTP 1.1 keep-alive is default
3345   - http_https_handler(sites, connection, is_https, dos, s, shutdown_required)
  3343 + http_https_handler(sites, connection, is_https, s, shutdown_required)
3346 3344 }
3347 3345  
3348 3346 //MULTIPART_FORM_DATA
... ... @@ -3380,10 +3378,10 @@ define One
3380 3378 with duration = (UTime) unow - t0,
3381 3379 println("Read body "+read_size+" duration: " + __utime_to_string(duration));
3382 3380  
3383   - multipart_form_data_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, desc.site_directory + tmp_body_file, generate_tt, s);
  3381 + multipart_form_data_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, desc.site_directory + tmp_body_file, s);
3384 3382  
3385 3383 //it's HTTP 1.1 keep-alive is default
3386   - http_https_handler(sites, connection, is_https, dos, s, shutdown_required)
  3384 + http_https_handler(sites, connection, is_https, s, shutdown_required)
3387 3385  
3388 3386 else
3389 3387 println("Can't copy data from stream to temporary file "),
... ... @@ -3394,10 +3392,10 @@ define One
3394 3392 with duration = (UTime) unow - t0,
3395 3393 println("Read body "+read_size+" duration: " + __utime_to_string(duration));
3396 3394  
3397   - multipart_form_data_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, desc.site_directory + tmp_body_file, generate_tt, s);
  3395 + multipart_form_data_answer(host_name, desc, connection.conn, ip_addr, rqline2, headers, desc.site_directory + tmp_body_file, s);
3398 3396  
3399 3397 //it's HTTP 1.1 keep-alive is default
3400   - http_https_handler(sites, connection, is_https, dos, s, shutdown_required)
  3398 + http_https_handler(sites, connection, is_https, s, shutdown_required)
3401 3399  
3402 3400 else
3403 3401 println("Can't copy data from stream to temporary file ")
... ... @@ -3427,48 +3425,46 @@ define One
3427 3425 Below are the two tools for constructing the handlers required by 'start_server' and
3428 3426 'start_ssl_server' (see 'predefined.anubis').
3429 3427  
3430   -define Bool is_dubious_IP(Word32 ip, DenialOfService dos).
  3428 + define Bool is_dubious_IP(Word32 ip, DenialOfService dos).
3431 3429  
3432 3430 define Server -> ((RWStream) -> One)
3433 3431 make_http_handler
3434 3432 (
3435 3433 List(Web_Site_Description) sites,
3436   - DenialOfService dos,
3437 3434 (One) -> Bool shutdown_required
3438 3435 ) =
3439 3436 (Server server) |-> (RWStream conn) |->
3440 3437 if remote_IP_address_and_port(conn) is (addr,_) then
3441   - if is_dubious_IP(addr,dos)
3442   - then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n")
3443   - else
  3438 +// if is_dubious_IP(addr,dos)
  3439 +// then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n")
  3440 +// else
3444 3441 with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
3445   - http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required).
  3442 + http_https_handler(sites, connection, false, sstate(var(0),var(0)), shutdown_required).
  3443 +
3446 3444 public define One
3447 3445 http_direct_handler
3448 3446 (
3449 3447 List(Web_Site_Description) sites,
3450 3448 RWStream conn,
3451   - DenialOfService dos,
3452 3449 (One) -> Bool shutdown_required
3453 3450 ) =
3454 3451 if remote_IP_address_and_port(conn) is (addr,_) then
3455   - if is_dubious_IP(addr,dos)
3456   - then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n")
3457   - else
  3452 +// if is_dubious_IP(addr,dos)
  3453 +// then print("Rejecting dubious IP address "+ip_addr_to_string(addr)+"\n")
  3454 +// else
3458 3455 with connection = http_buffered_connection(tcp(conn), var(constant_byte_array(0, 0)), var(0), var([])),
3459   - http_https_handler(sites, connection, false, dos, sstate(var(0),var(0)), shutdown_required).
  3456 + http_https_handler(sites, connection, false, sstate(var(0),var(0)), shutdown_required).
3460 3457  
3461 3458  
3462 3459 define Server -> (SSL_Connection -> One)
3463 3460 make_https_handler
3464 3461 (
3465 3462 List(Web_Site_Description) sites,
3466   - DenialOfService dos,
3467 3463 (One) -> Bool shutdown_required
3468 3464 ) =
3469 3465 (Server server) |-> (SSL_Connection conn) |->
3470 3466 with connection = http_buffered_connection(ssl(conn), var(constant_byte_array(0, 0)), var(0), var([])),
3471   - http_https_handler(sites, connection, true, dos, sstate(var(0),var(0)), shutdown_required).
  3467 + http_https_handler(sites, connection, true, sstate(var(0),var(0)), shutdown_required).
3472 3468  
3473 3469  
3474 3470  
... ... @@ -3599,7 +3595,7 @@ define One
3599 3595 record_dubious_IP(addr,list_of_dubious(dos)).
3600 3596  
3601 3597  
3602   -public define DenialOfService
  3598 + public define DenialOfService
3603 3599 load_denial_of_service_info
3604 3600 =
3605 3601 if (RetrieveResult(DenialOfService))retrieve(my_anubis_directory+"/web_sites/dos_info") is
... ... @@ -3732,8 +3728,8 @@ define StartServerResult
3732 3728 Word32 ip_address,
3733 3729 Word32 port,
3734 3730 Server -> ((RWStream) -> One) handler,
3735   - Int retries,
3736   - DenialOfService dos
  3731 + Int retries
  3732 + //DenialOfService dos
3737 3733 ) =
3738 3734 if start_server(ip_address,
3739 3735 port,
... ... @@ -3743,7 +3739,7 @@ define StartServerResult
3743 3739 ok(server)
3744 3740 else print("Port "+port+": retry number "+retries+"\r");
3745 3741 sleep(1000);
3746   - start_http_server(ip_address,port,handler,retries+1,dos).
  3742 + start_http_server(ip_address,port,handler,retries+1).
3747 3743  
3748 3744 public define StartServerResult
3749 3745 start_http_server
... ... @@ -3751,14 +3747,12 @@ public define StartServerResult
3751 3747 Word32 ip_address,
3752 3748 Word32 port,
3753 3749 List(Web_Site_Description) sites,
3754   - DenialOfService dos,
3755 3750 (One) -> Bool shutdown_required
3756 3751 ) =
3757 3752 create_directories(sites);
3758 3753 start_http_server(ip_address,port,
3759   - make_http_handler(sites, dos, shutdown_required),
3760   - 0,
3761   - dos).
  3754 + make_http_handler(sites, shutdown_required),
  3755 + 0).
3762 3756  
3763 3757  
3764 3758 For the HTTPS server, we have a problem which is due to the fact that 'anbexec' is not
... ... @@ -3775,8 +3769,7 @@ define StartServerResult
3775 3769 Word32 port,
3776 3770 String certificate_common_name,
3777 3771 Server -> (SSL_Connection -> One) handler,
3778   - Int retries,
3779   - DenialOfService dos
  3772 + Int retries
3780 3773 ) =
3781 3774 if start_ssl_server(ip_address,
3782 3775 port,
... ... @@ -3789,8 +3782,7 @@ define StartServerResult
3789 3782 sleep(1000);
3790 3783 start_https_server(ip_address,port,
3791 3784 certificate_common_name,
3792   - handler,retries+1,
3793   - dos).
  3785 + handler,retries+1).
3794 3786  
3795 3787  
3796 3788 public define StartServerResult
... ... @@ -3800,13 +3792,12 @@ public define StartServerResult
3800 3792 Word32 port,
3801 3793 String certificate_common_name, // of SSL server certificate
3802 3794 List(Web_Site_Description) sites,
3803   - DenialOfService dos,
3804 3795 (One) -> Bool shutdown_required
3805 3796 ) =
3806 3797 create_directories(sites);
3807 3798 start_https_server(ip_address,port,certificate_common_name,
3808   - make_https_handler(sites, dos, shutdown_required),
3809   - 0,dos).
  3799 + make_https_handler(sites, shutdown_required),
  3800 + 0).
3810 3801  
3811 3802  
3812 3803  
... ...