summaryrefslogtreecommitdiffstats
path: root/iw/firewall_gui.py
blob: 0015f188230e1719aeb02bf591b145d006ee1704 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from gtk import *
from iw_gui import *
from isys import *
from translate import _
import checklist

class FirewallWindow (InstallWindow):		

    def __init__ (self, ics):
	InstallWindow.__init__ (self, ics)

        ics.setTitle (_("Firewall Configuration"))
        ics.setNextEnabled (1)
        ics.readHTML ("securitylevel")
        self.todo = ics.getToDo ()
#        self.calcNMHandler = None

#        for dev in self.todo.network.available ().values ():
#	    if not dev.get('onboot'):
#		dev.set (("onboot", "yes"))

    def activate_firewall (self, widget):
        if self.radio3.get_active ():            
            active = not (self.radio3.get_active())

            self.radio4.set_sensitive (active)
            self.radio5.set_sensitive (active)        
            self.trusted.set_sensitive(active)
            self.incoming.set_sensitive(active)
            self.ports.set_sensitive(active)
            self.label1.set_sensitive(active)
            self.label2.set_sensitive(active)
            self.label3.set_sensitive(active)
        else:
            self.radio4.set_sensitive (TRUE)
            self.radio5.set_sensitive (TRUE) 

            if self.radio5.get_active ():
                self.trusted.set_sensitive(self.radio5.get_active())
                self.incoming.set_sensitive(self.radio5.get_active())
                self.ports.set_sensitive(self.radio5.get_active())
                self.label1.set_sensitive(self.radio5.get_active())
                self.label2.set_sensitive(self.radio5.get_active())
                self.label3.set_sensitive(self.radio5.get_active())

            else:
                self.trusted.set_sensitive(self.radio5.get_active())
                self.incoming.set_sensitive(self.radio5.get_active())
                self.ports.set_sensitive(self.radio5.get_active())
                self.label1.set_sensitive(self.radio5.get_active())
                self.label2.set_sensitive(self.radio5.get_active())
                self.label3.set_sensitive(self.radio5.get_active())

            
    def getScreen (self):
        box = GtkVBox (FALSE, 5)
        box.set_border_width (5)

        label = GtkLabel (_("Please choose your security level:  "))
        label.set_alignment (0.0, 0.5)

        label.set_line_wrap (TRUE)
        
        box.pack_start(label, FALSE)

        hbox = GtkHBox (FALSE)

        self.radio1 = GtkRadioButton (None, (_("High")))
        self.radio2 = GtkRadioButton (self.radio1, (_("Medium")))
        self.radio3 = GtkRadioButton (self.radio1, (_("No firewall")))

        self.radio3.connect ("clicked", self.activate_firewall)

        hbox.pack_start (self.radio1)
        hbox.pack_start (self.radio2)
        hbox.pack_start (self.radio3)

        a = GtkAlignment ()
        a.add (hbox)
        a.set (1.0, 0.5, 0.7, 1.0)

        box.pack_start (a, FALSE)

        hsep = GtkHSeparator ()
        box.pack_start (hsep, FALSE)

        self.radio4 = GtkRadioButton (None, (_("Use default firewall rules")))
        self.radio5 = GtkRadioButton (self.radio4, (_("Customize")))
        self.radio4.set_active (TRUE)

        self.radio4.connect ("clicked", self.activate_firewall)
        self.radio5.connect ("clicked", self.activate_firewall)
        
        box.pack_start (self.radio4, FALSE)
        box.pack_start (self.radio5, FALSE)

        table = GtkTable (2, 3)
        box.pack_start (table)

        hbox = GtkHBox(FALSE, 10)
        self.label1 = GtkLabel (_("Trusted devices:"))
        self.label1.set_alignment (0.2, 0.0)
        self.trusted = checklist.CheckList(1)
        table.attach (self.label1, 0, 1, 0, 1, FILL, FILL, 5, 5)
        table.attach (self.trusted, 1, 2, 0, 1, EXPAND|FILL, FILL, 5, 5)

        self.trusted.append_row (("cipcb0", ""), FALSE)
        self.trusted.append_row (("wvlan0", ""), FALSE)

        hbox = GtkHBox(FALSE, 10)        
        self.label2 = GtkLabel (_("Allow incoming:"))
        self.label2.set_alignment (0.2, 0.0)
        self.incoming = checklist.CheckList(1)
        table.attach (self.label2, 0, 1, 1, 2, FILL, FILL, 5, 5)
        table.attach (self.incoming, 1, 2, 1, 2, EXPAND|FILL, FILL, 5, 5)

        list = ["DHCP", "SSH", "Telnet", "WWW (HTTP)", "Mail (SMTP)", "FTP"]

        for item in list:
            self.incoming.append_row ((item, ""), FALSE)

        self.label3 = GtkLabel (_("Other ports:"))
        self.ports = GtkEntry ()

        table.attach (self.label3, 0, 1, 2, 3, FILL, FILL, 5, 5)
        table.attach (self.ports, 1, 2, 2, 3, EXPAND|FILL, FILL, 5, 5)


        self.trusted.set_sensitive(FALSE)
        self.incoming.set_sensitive(FALSE)
        self.ports.set_sensitive(FALSE)
        self.label1.set_sensitive(FALSE)
        self.label2.set_sensitive(FALSE)
        self.label3.set_sensitive(FALSE)


        return box