2016-11-04 21:08:47 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2016-11-07 17:50:56 +01:00
|
|
|
|
using System.Xml;
|
2016-11-04 21:08:47 +01:00
|
|
|
|
|
|
|
|
|
namespace EduNetworkBuilder
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public partial class FirewallEditor : Form
|
|
|
|
|
{
|
2016-11-07 17:50:56 +01:00
|
|
|
|
NetworkDevice FirewallDevice = null;
|
|
|
|
|
public FirewallEditor(NetworkDevice WhatToEdit)
|
2016-11-04 21:08:47 +01:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-11-07 17:50:56 +01:00
|
|
|
|
FirewallDevice = WhatToEdit;
|
2016-11-04 21:08:47 +01:00
|
|
|
|
UpdateForm();
|
2016-11-07 17:50:56 +01:00
|
|
|
|
Icon = Properties.Resources.NBIco;
|
2016-11-04 21:08:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UpdateForm()
|
|
|
|
|
{
|
|
|
|
|
if (lbRules.SelectedIndex > 0)
|
|
|
|
|
btnDel.Visible = true;
|
|
|
|
|
else
|
|
|
|
|
btnDel.Visible = false;
|
2016-11-07 17:50:56 +01:00
|
|
|
|
int selected = lbRules.SelectedIndex;
|
|
|
|
|
lbRules.Items.Clear();
|
|
|
|
|
foreach (FirewallRule FW in FirewallDevice.FirewallRules)
|
|
|
|
|
{
|
|
|
|
|
string OneLine = FW.Action.ToString() + " " + FW.Source + " -> " + FW.Destination;
|
|
|
|
|
lbRules.Items.Add(OneLine);
|
|
|
|
|
}
|
|
|
|
|
if (selected >= 0 && selected < lbRules.Items.Count)
|
|
|
|
|
lbRules.SelectedIndex = selected;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (lbRules.Items.Count > 0)
|
|
|
|
|
lbRules.SelectedIndex = 0;
|
|
|
|
|
}
|
2016-11-04 21:08:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnNew_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-11-07 17:50:56 +01:00
|
|
|
|
FirewallRule FW = new FirewallRule("","",FirewallRuleType.Drop);
|
|
|
|
|
NetTestEditor NTE = new NetTestEditor(FW,FirewallDevice);
|
|
|
|
|
NTE.ShowDialog();
|
|
|
|
|
if(FW.Source!="" && FW.Destination != "")
|
|
|
|
|
{
|
|
|
|
|
FirewallDevice.FirewallRules.Add(FW);
|
|
|
|
|
}
|
|
|
|
|
UpdateForm();
|
2016-11-04 21:08:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnDel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnDone_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-11-07 17:50:56 +01:00
|
|
|
|
Close();
|
2016-11-04 21:08:47 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|