| 3 | |
| 4 | |
| 5 | class MDConf(HttpdConf): |
| 6 | |
| 7 | def __init__(self, env: MDTestEnv, text=None, std_ports=True, |
| 8 | local_ca=True, std_vhosts=True, proxy=False, |
| 9 | admin=None): |
| 10 | super().__init__(env=env) |
| 11 | |
| 12 | if admin is None: |
| 13 | admin = f"admin@{env.http_tld}" |
| 14 | if len(admin.strip()): |
| 15 | self.add_admin(admin) |
| 16 | self.add([ |
| 17 | "MDRetryDelay 1s", # speed up testing a little |
| 18 | "MDRenewViaARI off", # not on, logs unwanted errors when test |
| 19 | # acme server is not responding |
| 20 | ]) |
| 21 | if local_ca: |
| 22 | self.add([ |
| 23 | f"MDCertificateAuthority {env.acme_url}", |
| 24 | f"MDCertificateAgreement accepted", |
| 25 | f"MDCACertificateFile {env.server_dir}/acme-ca.pem", |
| 26 | "", |
| 27 | ]) |
| 28 | if std_ports: |
| 29 | self.add(f"MDPortMap 80:{env.http_port} 443:{env.https_port}") |
| 30 | if env.ssl_module == "mod_tls": |
| 31 | self.add(f"TLSListen {env.https_port}") |
| 32 | self.add([ |
| 33 | "<Location /server-status>", |
| 34 | " SetHandler server-status", |
| 35 | "</Location>", |
| 36 | "<Location /md-status>", |
| 37 | " SetHandler md-status", |
| 38 | "</Location>", |
| 39 | ]) |
| 40 | if std_vhosts: |
| 41 | self.add_vhost_test1() |
| 42 | if proxy: |
| 43 | self.add([ |
| 44 | f"Listen {self.env.proxy_port}", |
| 45 | f"<VirtualHost *:{self.env.proxy_port}>", |
| 46 | " ProxyRequests On", |
| 47 | " ProxyVia On", |
| 48 | " # be totally open", |
| 49 | " AllowCONNECT 0-56535", |
| 50 | " <Proxy *>", |
| 51 | " # No require or other restrictions, this is just a test server", |
| 52 | " </Proxy>", |
| 53 | "</VirtualHost>", |
| 54 | ]) |
| 55 | if text is not None: |
| 56 | self.add(text) |
| 57 | |
| 58 | def add_drive_mode(self, mode): |
| 59 | self.add("MDRenewMode \"%s\"\n" % mode) |
| 60 | |
| 61 | def add_renew_window(self, window): |
| 62 | self.add("MDRenewWindow %s\n" % window) |
no outgoing calls