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
use Arc;
/// Enough of an incoming request for a selector to work with, whatever
/// framework it came from. An adapter supplies one of these per request.
///
/// Both closures are `Send + Sync` because an adapter holds this across the
/// await inside [`Core::evaluate`](crate::middleware::Core::evaluate), and a
/// tower `Service` future has to be `Send`. Without the bound the whole
/// middleware fails to compile at the adapter, which is a confusing place to
/// learn it.
/// How the client address is decided.
///
/// There is no portable default: a framework's own accessor may return the
/// socket peer, or may already have walked a proxy chain, depending on the
/// framework and on how the application configured it. You know your framework
/// and your edge, so this is yours to choose - and anything of this shape works,
/// so an edge we have never heard of is a closure rather than a feature request:
///
/// ```
/// use std::sync::Arc;
/// use internetdata::middleware::IpSelector;
///
/// let mine: IpSelector = Arc::new(|view| (view.header)("x-real-ip"));
/// ```
pub type IpSelector = ;
/// The framework's own client-address accessor. The default.
/// An address from `X-Forwarded-For`.
///
/// The LEFT-MOST entry (`depth` 0) is whatever the caller sent, because proxies
/// append to this header, so a visitor who sets it themselves appears first and
/// this returns their forgery. It is only trustworthy when an edge you control
/// overwrites the header. When you know how many proxies sit in front, count
/// from the right: depth 1 is the address your nearest proxy saw.
/// An address from a single-value header your edge writes -
/// `header("CF-Connecting-IP")` behind Cloudflare. Falls back to the
/// framework's accessor when the header is absent.