/[mldonkey]/mldonkey/src/networks/donkey/donkeyOvernet.ml
ViewVC logotype

Diff of /mldonkey/src/networks/donkey/donkeyOvernet.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.36 by spiralvoice, Sun Jul 17 23:18:21 2005 UTC revision 1.37 by spiralvoice, Mon Jul 18 00:52:31 2005 UTC
# Line 962  let udp_client_handler t p = Line 962  let udp_client_handler t p =
962    | OvernetUnknown (opcode, s) ->    | OvernetUnknown (opcode, s) ->
963        if !verbose_hidden_errors then        if !verbose_hidden_errors then
964          begin          begin
965            lprintf () "Unknown message from %s:%d " (Ip.to_string other_ip) other_port;            lprintf_nl () "Unknown message from %s:%d " (Ip.to_string other_ip) other_port;
966            lprintf_nl () "\tCode: %d" opcode; dump s;            lprintf_nl () "\tCode: %d" opcode; dump s;
967          end          end
968    
# Line 1377  let parse_overnet_url url = Line 1377  let parse_overnet_url url =
1377        true        true
1378    | _ -> false    | _ -> false
1379    
1380    let command_prefix_to_net =
1381      if command_prefix = "ov_" || Proto.redirector_section = "DKKO" then "Overnet"
1382      else "Kademlia"
1383    
1384  let register_commands list =  let register_commands list =
1385    register_commands    register_commands
1386      (List2.tail_map (fun (n,f,h) -> (n, "Network/Overnet", f,h)) list)      (List2.tail_map (fun (n,f,h) -> (n, "Network/Overnet", f,h)) list)
# Line 1391  let _ = Line 1395  let _ =
1395          let port = int_of_string port in          let port = int_of_string port in
1396          bootstrap ip port;          bootstrap ip port;
1397          Printf.sprintf "peer %s:%d added" (Ip.to_string ip) port          Printf.sprintf "peer %s:%d added" (Ip.to_string ip) port
1398      ), "<ip> <port> :\t\t\tadd an Overnet/Kademlia peer";      ), ("<ip> <port> :\t\t\tadd an " ^ command_prefix_to_net ^ " peer");
1399    
1400      "link", Arg_multiple (fun args o ->      "link", Arg_multiple (fun args o ->
1401          let buf = o.conn_buf in          let buf = o.conn_buf in
# Line 1401  let _ = Line 1405  let _ =
1405          else "bad syntax"          else "bad syntax"
1406      ), "<fhalink> :\t\t\tdownload fha:// link";      ), "<fhalink> :\t\t\tdownload fha:// link";
1407    
1408        "view_stats_cmds", Arg_none (fun o ->
1409            let buf = o.conn_buf in
1410            html_mods_commands buf "commandsTable" "commands" ([
1411              ("bu bbig", command_prefix_to_net ^ " boots list",
1412               "top.output.location.href='submit\\?q=" ^ command_prefix ^ "boots'",
1413               command_prefix_to_net ^ " boots");
1414              ("bu bbig", command_prefix_to_net ^ " buckets list",
1415               "top.output.location.href='submit\\?q=" ^ command_prefix ^ "buckets'",
1416               command_prefix_to_net ^ " buckets");
1417              ("bu bbig", command_prefix_to_net ^ " stats",
1418               "top.output.location.href='submit\\?q=" ^ command_prefix ^ "stats'",
1419               command_prefix_to_net ^ " stats");
1420              ("bu bbig", command_prefix_to_net ^ " store list",
1421               "top.output.location.href='submit\\?q=" ^ command_prefix ^ "store'",
1422               command_prefix_to_net ^ " store");
1423              ]);
1424            "";
1425        ), (":\t\t\t\t" ^ command_prefix_to_net ^ " Stats commands");
1426    
1427      "stats", Arg_none (fun o ->      "stats", Arg_none (fun o ->
1428          let buf = o.conn_buf and sum = ref 0 in          let buf = o.conn_buf and sum = ref 0 in
1429          if o.conn_output = HTML then          if o.conn_output = HTML then
# Line 1409  let _ = Line 1432  let _ =
1432              html_mods_table_header buf "ovstatsTable" "sources" [];              html_mods_table_header buf "ovstatsTable" "sources" [];
1433              Printf.bprintf buf "\\<tr\\>";              Printf.bprintf buf "\\<tr\\>";
1434              html_mods_td buf [              html_mods_td buf [
1435                ("", "srh", Printf.sprintf "%s statistics"                ("", "srh", Printf.sprintf "%s statistics" command_prefix_to_net);
               (if Proto.redirector_section = "DKKO" then "Overnet" else "Kademlia"));  
1436                ("", "srh", Printf.sprintf "Search hits: %d\n" !search_hits);                ("", "srh", Printf.sprintf "Search hits: %d\n" !search_hits);
1437                ("", "srh", Printf.sprintf "Source hits: %d\n" !source_hits); ];                ("", "srh", Printf.sprintf "Source hits: %d\n" !source_hits); ];
1438              Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\n";              Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\n";
# Line 1418  let _ = Line 1440  let _ =
1440          else          else
1441            begin            begin
1442              Printf.bprintf buf "%s statistics:\n"              Printf.bprintf buf "%s statistics:\n"
1443              (if Proto.redirector_section = "DKKO" then "Overnet" else "Kademlia");              (command_prefix_to_net);
1444              Printf.bprintf buf "  Search hits: %d\n" !search_hits;              Printf.bprintf buf "  Search hits: %d\n" !search_hits;
1445              Printf.bprintf buf "  Source hits: %d\n" !source_hits;              Printf.bprintf buf "  Source hits: %d\n" !source_hits;
1446            end;            end;
# Line 1472  let _ = Line 1494  let _ =
1494            Printf.bprintf buf "\\</div\\>\n";            Printf.bprintf buf "\\</div\\>\n";
1495    
1496          "";          "";
1497      ), ":\t\t\t\tOvernet/Kademlia Stats";      ), ":\t\t\t\t" ^ command_prefix_to_net ^ " Stats";
1498    
1499      "web", Arg_multiple (fun args o ->      "web", Arg_multiple (fun args o ->
1500          let urls =          let urls =
# Line 1504  let _ = Line 1526  let _ =
1526    
1527      "store", Arg_none (fun o ->      "store", Arg_none (fun o ->
1528          let buf = o.conn_buf in          let buf = o.conn_buf in
1529            if o.conn_output = HTML then
1530              begin
1531                let buftmp = Buffer.create 100 in
1532                PublishedKeywords.print buftmp;
1533                let listtmp = String2.split (Buffer.contents buftmp) '\n' in
1534                let keywords = ref [] in
1535                List.iter (fun s ->
1536                    keywords := !keywords @ [("", "dl-1", s);]
1537                ) listtmp;
1538                Buffer.clear buftmp;
1539                PublishedFiles.print buftmp;
1540                let listtmp = String2.split (Buffer.contents buftmp) '\n' in
1541                let files = ref [] in
1542                List.iter (fun s ->
1543                    files := !files @ [("", "dl-1", s);]
1544                  ) listtmp;
1545                Buffer.clear buftmp;
1546                html_mods_table_one_col buf "ovstoreTable" "results" ([
1547                  ("", "srh", Printf.sprintf "%s store" command_prefix_to_net);
1548                  ] @ !keywords @ !files);
1549              end
1550            else
1551              begin
1552            Printf.bprintf buf "%s store:\n"            Printf.bprintf buf "%s store:\n"
1553            (if Proto.redirector_section = "DKKO" then "Overnet" else "Kademlia");            (command_prefix_to_net);
1554            PublishedKeywords.print buf;            PublishedKeywords.print buf;
1555            PublishedFiles.print buf;            PublishedFiles.print buf;
1556            end;
1557          ""          ""
1558      ), ":\t\t\t\tdump the Overnet/Kademlia File Store";      ), ":\t\t\t\tdump the " ^ command_prefix_to_net ^ " File Store";
1559    
1560      "send_udp", Arg_three (fun ip port hex o ->      "send_udp", Arg_three (fun ip port hex o ->
1561          try          try
# Line 1531  let _ = Line 1577  let _ =
1577              lprintf_nl () "Unable to send UDP message"; "Unable to send UDP message"              lprintf_nl () "Unable to send UDP message"; "Unable to send UDP message"
1578      ), ":\t\t\t\tsend UDP message (<ip> <port> <msg in hex>)";      ), ":\t\t\t\tsend UDP message (<ip> <port> <msg in hex>)";
1579    
1580        "buckets", Arg_none (fun o ->       "buckets", Arg_none (fun o ->
1581            let buf = o.conn_buf in           let buf = o.conn_buf in
1582            update_buckets ();           update_buckets ();
1583             if o.conn_output != HTML then
1584            Printf.bprintf buf "Number of used buckets %d with %d peers (prebucket: %d peers)\n"            Printf.bprintf buf "Number of used buckets %d with %d peers (prebucket: %d peers)\n"
1585              !n_used_buckets !connected_peers !pre_connected_peers;              !n_used_buckets !connected_peers !pre_connected_peers;
1586            for i = 0 to !n_used_buckets do           for i = 0 to !n_used_buckets do
1587              if Fifo.length buckets.(i) > 0 ||             if Fifo.length buckets.(i) > 0 ||
1588                Fifo.length prebuckets.(i) > 0 then               Fifo.length prebuckets.(i) > 0 then
1589                Printf.bprintf buf "   bucket[%d] : %d peers (prebucket %d)\n"                Printf.bprintf buf "   bucket[%d] : %d peers (prebucket %d)\n"
1590                  i (Fifo.length buckets.(i)) (Fifo.length prebuckets.(i));                  i (Fifo.length buckets.(i)) (Fifo.length prebuckets.(i));
1591            done;           done;
1592            ""           if o.conn_output = HTML then
1593        ), ":\t\t\t\tprint buckets table status";             begin
1594                 let listtmp = String2.split (Buffer.contents buf) '\n' in
1595        "boots", Arg_none (fun o ->               let buckets = ref [] in
1596            let buf = o.conn_buf in               List.iter (fun s ->
1597            LimitedList.iter (fun (ip, port) ->                   buckets := !buckets @ [("", "dl-1", s);]
1598                Printf.bprintf buf "   %s:%d\n" (Ip.to_string ip) port;               ) listtmp;
1599            ) !!boot_peers;               Buffer.clear buf;
1600            Printf.sprintf "Boot peers: %d\n" (LimitedList.length !!boot_peers);               html_mods_table_one_col buf "ovbucketsTable" "results" ([
1601                   ("", "srh",
1602        ), ":\t\t\t\tprint boot peers";                   Printf.sprintf "Number of used buckets %d with %d peers"
1603                       !n_used_buckets !connected_peers);
1604                   ] @ !buckets);
1605               end;          ""
1606         ), ":\t\t\t\tprint buckets table status";
1607    
1608         "boots", Arg_none (fun o ->
1609             let buf = o.conn_buf in
1610             LimitedList.iter (fun (ip, port) ->
1611                 Printf.bprintf buf "   %s:%d\n" (Ip.to_string ip) port;
1612             ) !!boot_peers;
1613             if o.conn_output = HTML then
1614               begin
1615                 let listtmp = String2.split (Buffer.contents buf) '\n' in
1616                 let boots = ref [] in
1617                 List.iter (fun s ->
1618                     boots := !boots @ [("", "dl-1", s);]
1619                 ) listtmp;
1620                 Buffer.clear buf;
1621                 html_mods_table_one_col buf "ovbucketsTable" "results" ([
1622                   ("", "srh",
1623                     Printf.sprintf "Boot peers: %d\n" (LimitedList.length !!boot_peers));
1624                   ] @ !boots);
1625               end
1626             else
1627               Printf.bprintf buf "Boot peers: %d\n" (LimitedList.length !!boot_peers);
1628             ""
1629         ), ":\t\t\t\tprint boot peers";
1630    ]);    ]);
1631    ()    ()
1632    

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.37

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26