-
Notifications
You must be signed in to change notification settings - Fork 0
/
IManInTheMiddle.cs
64 lines (59 loc) · 2.82 KB
/
IManInTheMiddle.cs
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
//
// Copyright (C) 2021 William Stackenäs <w.stackenas@gmail.com>
//
// This file is part of Tiriryarai.
//
// Tiriryarai 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 3 of the License, or
// (at your option) any later version.
//
// Tiriryarai 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.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
using Tiriryarai.Http;
namespace Tiriryarai.Server
{
/// <summary>
/// An interface for a man-in-the-middle handler that will receive incomming HTTP requests and outgoing HTTP responses
/// to tamper with them automatically. Classes implementing this interface MUST have a constructor that does not
/// have any arguments.
/// </summary>
interface IManInTheMiddle
{
/// <summary>
/// Returns a <c>bool</c> indicating whether the given host is blocked.
/// </summary>
/// <returns><code>true</code> if the host should be blocked; otherwise, <code>false</code>.</returns>
/// <param name="hostname">The name of the host.</param>
bool Block(string hostname);
/// <summary>
/// Handles a request and returns either a modified request if it is to be proxied, or a response otherwise.
/// </summary>
/// <returns>An instance of <see cref="T:Tiriryarai.Http.HttpRequest"/> if the request was modified or ignored.
/// If the request was handled and intercepted, an instance of <see cref="T:Tiriryarai.Http.HttpResponse"/>.</returns>
/// <param name="req">The request to handle.</param>
HttpMessage HandleRequest(HttpRequest req);
/// <summary>
/// Handles a response returned by the given request and returns the response to be sent back.
/// </summary>
/// <returns>The modified or ignored HTTP response.</returns>
/// <param name="resp">The response to handle.</param>
/// <param name="req">The request that resulted in this response.</param>
HttpResponse HandleResponse(HttpResponse resp, HttpRequest req);
/// <summary>
/// Handles a request destined to the man-in-the-middle handler and returns a custom response. All requests
/// sent to this method were received securely using HTTPS, and were authenticated using HTTP basic
/// authentication if it was required in the <see cref="T:Tiriryarai.Util.HttpsMitmProxyParams"/>
/// <example>This response could for example be a configuration GUI.</example>
/// </summary>
/// <returns>The custom response.</returns>
/// <param name="req">The request to handle.</param>
HttpResponse HomePage(HttpRequest req);
}
}