aboutsummaryrefslogtreecommitdiffstats
path: root/doc-src/index.py
blob: 753f90a5cd66e763f2cc78c266eeb724e97f8bf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os
import sys
import datetime
import countershape
from countershape import Page, Directory, markup, model
import countershape.template

MITMPROXY_SRC = os.path.abspath(
    os.path.expanduser(os.environ.get("MITMPROXY_SRC", ".."))
)
sys.path.insert(0, MITMPROXY_SRC)
from libmproxy import filt, version

ns.VERSION = version.VERSION

if ns.options.website:
    ns.idxpath = "doc/index.html"
    this.layout = countershape.Layout("_websitelayout.html")
else:
    ns.idxpath = "index.html"
    this.layout = countershape.Layout("_layout.html")

ns.title = countershape.template.Template(None, "<h1>@!this.title!@</h1>")
this.titlePrefix = "%s - " % version.NAMEVERSION
this.markup = markup.Markdown(extras=["footnotes"])

ns.docMaintainer = "Aldo Cortesi"
ns.docMaintainerEmail = "aldo@corte.si"
ns.copyright = u"\u00a9 mitmproxy project, %s" % datetime.date.today().year


def mpath(p):
    p = os.path.join(MITMPROXY_SRC, p)
    return os.path.expanduser(p)


def example(s):
    d = file(mpath(s)).read().rstrip()
    extemp = """<div class="example">%s<div class="example_legend">(%s)</div></div>"""
    return extemp%(countershape.template.Syntax("py")(d), s)


ns.example = example


ns.filt_help = filt.help


def nav(page, current, state):
    if current.match(page, False):
        pre = '<li class="active">'
    else:
        pre = "<li>"
    p = state.application.getPage(page)
    return pre + '<a href="%s">%s</a></li>'%(model.UrlTo(page), p.title)
ns.nav = nav
ns.navbar = countershape.template.File(None, "_nav.html")


pages = [
    Page("index.html", "Introduction"),
    Page("install.html", "Installation"),
    Page("howmitmproxy.html", "How mitmproxy works"),
    Page("modes.html", "Modes of Operation"),

    Page("mitmproxy.html", "mitmproxy"),
    Page("mitmdump.html", "mitmdump"),
    Page("config.html", "configuration"),

    Page("ssl.html", "Overview"),
    Directory("certinstall"),
    Directory("scripting"),
    Directory("tutorials"),
    Page("transparent.html", "Overview"),
    Directory("transparent"),
]
="p">) ConnectionHandle = ConnectedDevices[0]; else return null; // Fix report handle under Windows if (ConnectionHandle is Hid.Win32.Win32DeviceSet) { ((Hid.Win32.Win32DeviceSet)ConnectionHandle).AddDevice(0x00, ((Hid.Win32.Win32DeviceSet)ConnectionHandle).UnallocatedDevices[0]); } return ConnectionHandle; } public frmDataloggerSettings() { InitializeComponent(); } private void btnSetValues_Click(object sender, EventArgs e) { IDevice ConnectionHandle = GetDeviceConnection(); if (ConnectionHandle == null) { MessageBox.Show("Error: Cannot connect to Datalogger device."); return; } Device_Report_t DeviceReport = new Device_Report_t(); DeviceReport.Day = (byte)dtpDate.Value.Day; DeviceReport.Month = (byte)dtpDate.Value.Month; DeviceReport.Year = (byte)((dtpDate.Value.Year < 2000) ? 0 : (dtpDate.Value.Year - 2000)); DeviceReport.Hour = (byte)dtpTime.Value.Hour; DeviceReport.Minute = (byte)dtpTime.Value.Minute; DeviceReport.Second = (byte)dtpTime.Value.Second; DeviceReport.LogInterval500MS = (byte)(nudLogInterval.Value * 2); try { ConnectionHandle.Write(0x00, DeviceReport.ToReport()); MessageBox.Show("Device parameters updated successfully."); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } } private void btnGetValues_Click(object sender, EventArgs e) { IDevice ConnectionHandle = GetDeviceConnection(); if (ConnectionHandle == null) { MessageBox.Show("Error: Cannot connect to Datalogger device."); return; } Device_Report_t DeviceReport = new Device_Report_t(); try { Byte[] Report = new Byte[7]; ConnectionHandle.Read(0x00, Report); DeviceReport.FromReport(Report); String msgText = "Device parameters retrieved successfully."; try { dtpDate.Value = new DateTime( (2000 + DeviceReport.Year), DeviceReport.Month, DeviceReport.Day); dtpTime.Value = new DateTime( DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DeviceReport.Hour, DeviceReport.Minute, DeviceReport.Second); } catch (Exception ex) { msgText = "Problem reading device:\n" + ex.Message + "\nY:" + DeviceReport.Year.ToString() + " M:" + DeviceReport.Month.ToString() + " D:" + DeviceReport.Day.ToString() + "\n\nUsing current date and time."; dtpDate.Value = DateTime.Now; dtpTime.Value = DateTime.Now; } try { nudLogInterval.Value = (DeviceReport.LogInterval500MS / 2); } catch (Exception ex) { nudLogInterval.Value = nudLogInterval.Minimum; } MessageBox.Show(msgText); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } } private void frmDataloggerSettings_Load(object sender, EventArgs e) { } } }