-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGeoblockModule.cs
More file actions
60 lines (54 loc) · 2.55 KB
/
GeoblockModule.cs
File metadata and controls
60 lines (54 loc) · 2.55 KB
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
#nullable disable
/* GeoblockModule.cs
*
* Copyright (C) 2009 Triple IT. All Rights Reserved.
* Author: Frank Lippes, Modified for IIS 10 (.Net 4.6) by RvdH
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
using System;
using Microsoft.Web.Management.Client;
using Microsoft.Web.Management.Server;
namespace IISGeoIP2blockModule
{
/// <summary>
/// Represents the GeoblockModule in IIS
/// </summary>
internal class GeoblockModule : Module
{
/// <summary>
/// Called by IIS to register the modulepage
/// </summary>
/// <param name="serviceProvider">The service provider</param>
/// <param name="moduleInfo">The module info</param>
protected override void Initialize(IServiceProvider serviceProvider, ModuleInfo moduleInfo)
{
base.Initialize(serviceProvider, moduleInfo);
//load the icon
System.IO.Stream icoStream = this.GetType().Assembly.GetManifestResourceStream("IISGeoIP2blockModule.resources.geoblock.png");
System.Drawing.Bitmap ico = new System.Drawing.Bitmap(icoStream);
icoStream.Close();
string description = $"[{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}] Blocks access by country referenced by client IP address.";
IControlPanel controlPanel = (IControlPanel)GetService(typeof(IControlPanel));
ModulePageInfo modulePageInfo = new ModulePageInfo(this, typeof(GeoblockModuleDialogPage), "Geoblock Module", "Blocks access by country referenced by client IP address.", ico, ico, description);
controlPanel.RegisterPage(ControlPanelCategoryInfo.Security, modulePageInfo);
}
/// <summary>
/// Whether or not the modulepage is enabled in the iis 7 management console
/// </summary>
/// <param name="pageInfo">The module page info</param>
/// <returns>True if the module page is enabled. False otherwise</returns>
protected override bool IsPageEnabled(ModulePageInfo pageInfo)
{
return base.IsPageEnabled(pageInfo);
}
}
}