Changeset ed91398 in trunk


Ignore:
Timestamp:
2016-09-02T23:30:21Z (9 years ago)
Author:
Brian Warner <warner@…>
Branches:
master
Children:
00ea41e, 4535741
Parents:
ed22b60
Message:

WUI: disable google timing chart on mapupdate page

The google image chart API has been deprecated since 2012, sending the
URL to google leaks server IDs and the client's IP address (especially
important when the client is otherwise behind Tor), and the X-axis has
no units anyways.

refs ticket:1942 , which is both about removing the URL-based chart, and
eventually replacing it with a browser-rendered d3.js-based one

Location:
src/allmydata/web
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/web/map-update-status.xhtml

    red22b60 red91398  
    2222<ul>
    2323  <li n:render="problems" />
    24   <li>Timings: <span n:render="timing_chart" /></li>
     24  <li>Total: <span n:render="time" n:data="time_total" /></li>
    2525  <ul>
    26     <li>Total: <span n:render="time" n:data="time_total" /></li>
    27     <ul>
    28       <li>Initial Queries: <span n:render="time" n:data="time_initial_queries" /></li>
    29       <li n:render="privkey_from" />
    30       <li>Cumulative Verify: <span n:render="time" n:data="time_cumulative_verify" /></li>
    31     </ul>
    32     <li n:render="server_timings" />
     26    <li>Initial Queries: <span n:render="time" n:data="time_initial_queries" /></li>
     27    <li n:render="privkey_from" />
     28    <li>Cumulative Verify: <span n:render="time" n:data="time_cumulative_verify" /></li>
    3329  </ul>
     30  <li n:render="server_timings" />
    3431</ul>
    3532
  • TabularUnified src/allmydata/web/status.py

    red22b60 red91398  
    950950        return T.li["Per-Server Response Times: ", l]
    951951
    952     def render_timing_chart(self, ctx, data):
    953         imageurl = self._timing_chart()
    954         return ctx.tag[imageurl]
    955 
    956     def _timing_chart(self):
    957         started = self.update_status.get_started()
    958         total = self.update_status.timings.get("total")
    959         per_server = self.update_status.timings.get("per_server")
    960         # We'd like to use an https: URL here, but the site has a domain/cert mismatch.
    961         base = "http://chart.apis.google.com/chart?"
    962         pieces = ["cht=bhs"]
    963         pieces.append("chco=ffffff,4d89f9,c6d9fd") # colors
    964         data0 = []
    965         data1 = []
    966         data2 = []
    967         nb_nodes = 0
    968         graph_botom_margin= 21
    969         graph_top_margin = 5
    970         server_names = []
    971         top_abs = started
    972         # we sort the queries by the time at which we sent the first request
    973         sorttable = [ (times[0][1], server)
    974                       for server, times in per_server.items() ]
    975         sorttable.sort()
    976         servers = [t[1] for t in sorttable]
    977 
    978         for server in servers:
    979             nb_nodes += 1
    980             times = per_server[server]
    981             name = server.get_name()
    982             server_names.append(name)
    983             # for servermap updates, there are either one or two queries per
    984             # peer. The second (if present) is to get the privkey.
    985             op,q_started,q_elapsed = times[0]
    986             data0.append("%.3f" % (q_started-started))
    987             data1.append("%.3f" % q_elapsed)
    988             top_abs = max(top_abs, q_started+q_elapsed)
    989             if len(times) > 1:
    990                 op,p_started,p_elapsed = times[0]
    991                 data2.append("%.3f" % p_elapsed)
    992                 top_abs = max(top_abs, p_started+p_elapsed)
    993             else:
    994                 data2.append("0.0")
    995         finished = self.update_status.get_finished()
    996         if finished:
    997             top_abs = max(top_abs, finished)
    998         top_rel = top_abs - started
    999         chs ="chs=400x%d" % ( (nb_nodes*28) + graph_top_margin + graph_botom_margin )
    1000         chd = "chd=t:" + "|".join([",".join(data0),
    1001                                    ",".join(data1),
    1002                                    ",".join(data2)])
    1003         pieces.append(chd)
    1004         pieces.append(chs)
    1005         chds = "chds=0,%0.3f" % top_rel
    1006         pieces.append(chds)
    1007         pieces.append("chxt=x,y")
    1008         pieces.append("chxr=0,0.0,%0.3f" % top_rel)
    1009         pieces.append("chxl=1:|" + "|".join(reversed(server_names)))
    1010         # use up to 10 grid lines, at decimal multiples.
    1011         # mathutil.next_power_of_k doesn't handle numbers smaller than one,
    1012         # unfortunately.
    1013         #pieces.append("chg="
    1014 
    1015         if total is not None:
    1016             finished_f = 1.0 * total / top_rel
    1017             pieces.append("chm=r,FF0000,0,%0.3f,%0.3f" % (finished_f,
    1018                                                           finished_f+0.01))
    1019         url = base + "&".join(pieces)
    1020         return T.img(src=url,border="1",align="right", float="right")
    1021 
    1022952
    1023953class Status(rend.Page):
Note: See TracChangeset for help on using the changeset viewer.