File: proxy.md

package info (click to toggle)
python-pyfunceble 4.2.29.dev-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,108 kB
  • sloc: python: 27,413; sh: 142; makefile: 27
file content (174 lines) | stat: -rw-r--r-- 4,244 bytes parent folder | download
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# `proxy`

PyFunceble can let you proxy requests to another server or service.
This parameter let you defines rules and global proxies to use.

## Overview

```yaml title=".PyFunceble.overwrite.yaml"
proxy:
  # Provides everything related to the proxy usage and configuration.
  #
  # The idea:
  #   We have two main keys, "global" and "rules".
  #   The system will always follow the global keys unless you define an explit
  #   TLD.
  #
  # Example:
  #
  #   Let's say we want all HTTP requests to go through example.org but we want
  #   all HTTP request for domains ending with `.com`, `.org` and `.dev` to go
  #   through example.com. And, we want all domains ending with `.onion` to go
  #   through example.dev.
  #
  #   This is how it will look like.
  #
  #       global:
  #         http: http://example.org:8080
  #         https: http://example.org:8080
  #
  #       rules:
  #         - http: http://example.com:8080
  #           https: http://example.org:8080
  #           tld:
  #             - com
  #             - org
  #             - dev
  #         - http: socks5h://example.dev:8080
  #           https: socks5h://example.dev:8080
  #           tld:
  #             - onion
  #

  global:
    # Global HTTP proxy to use when no rule is given or matched.
    #
    # CLI Argument: --http-proxy
    http: null

    # Global HTTPS proxy to use when no rule is given or matched.
    #
    # CLI Argument: --https-proxy
    https: null

  # The rules to apply.
  # See example.
  rules: []
```

## Example

PyFunceble - like many other python programs - follow any `HTTP_PROXY` or
`HTTPS_PROXY` environment variable. However, end-users that want to define
a proxy per Top Level Domain are advised to use the configuration parameters as
it offers of way to define proxy rules.

Through the `proxy.global.http` and `proxy.global.https` parameters, one can set
the proxy to reach when no rules is given or matched.

However, if you want something more granular, you may use the `proxy.rules`
parameter.

Let's say we want:

- any domains ending with `.com`, `.org`, and `.dev` to be tested through the
  `http://spec-proxy.example.com` proxy for any HTTP traffic and
  `http://spec-proxy.example.com:8443` for any HTTPS traffic.

- any domains ending with `.ionion` to be tested through the
  `http://onion-proxy.example.com` proxy.

- any other domains to be tested through `http://proxy.example.com` for any HTTP
  traffic and `http://proxy.example.com:8443` for any HTTP traffic.

How would you do that ? It's simple, simply define the following rules:

```yaml title=".PyFunceble.overwrite.yaml"
proxy:
  rules:
    # Any domains ending with `.com`, `.org` and `.dev`
    - http: http://spec-proxy.example.com
      https: http://spec-proxy.example.com:8443
      tld:
        - com
        - org
        - dev

    # Any domains ending with `.onion`
    - http: http://onion-proxy.example.com
      https: http://onion-proxy.example.com
      tld:
        - onion

  global:
    # Any other domains
    http: http://proxy.example.com
    https: http://proxy.example.com:8443
```

## `global`

Set the global HTTP and HTTPS proxies.

### Overview

```yaml title=".PyFunceble.overwrite.yaml"
proxy:
  global:
    # Global HTTP proxy to use when no rule is given or matched.
    #
    # CLI Argument: --http-proxy
    http: null

    # Global HTTPS proxy to use when no rule is given or matched.
    #
    # CLI Argument: --https-proxy
    https: null
```

### `http`

Set the proxy to reach for any HTTP traffic when no rule is given or matched.

**Type:** string

**Default Value:** `null`

**Available Values:** User-Defined Values

**CLI Argument:** `--http-proxy`

### `https`

Set the proxy to reach for any HTTPS traffic when no rule is given or matched.

**Type:** string

**Default Value:** `null`

**Available Values:** User-Defined Values

**CLI Argument:** `--https-proxy`

## `rules`

Set the proxy rules PyFunceble has to match. (See also: [Example](#example)).

**Type:** list[dict]

**Default Value:** `[]`

**Available Values:** User-Defined Values

**CLI Argument:** `--https-proxy`

**Boilerplate:**

```yaml
- http: {HTTP_PROXY}
  https: {HTTP_PROXY}
  tld:
    - {TLD}
    - {TLD2}
    - {TLD3}
```