summaryrefslogtreecommitdiff
path: root/ereproxy_config.erl
blob: 80bf2437bdd65c2cd2bc73d46dacd1d22b267703 (plain)
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
-module(ereproxy_config).
-export([ciphers/0, config/0, select_destination/1]).

-include("ereproxy_config.hrl").

config() ->
    #cfg{listen = [{http, 80}, {https, 443}],
	 ssl_opts = [{certfile, "example/cert.pem"},
		     {keyfile, "example/key.pem"},
                     {versions, [tlsv1,  'tlsv1.1', 'tlsv1.2']},
                     {ciphers, ciphers()}]
	}.

%% select_destination
select_destination(HostName) ->
    case lists:keysearch(HostName, 1, destination_list()) of
	{value, {HostName, Destination}} -> Destination;
	_UnknownHostName -> destination_default()
    end.

destination_default() ->
    {"192.168.130.35", 80}.

destination_list() ->
    [
     {"code.sotun.de", {"192.168.130.103", 80}},
     {"wave.sotun.de", {"192.168.130.111", 9898}}
     | [{WWW ++ "kraut" ++ Dash ++ "computing." ++ TLD,
	{"192.168.130.37", 80}}
       || WWW <- ["", "www."],
	  Dash <- ["", "-"],
	  TLD <- ["com", "de", "net", "eu", "org", "at"] ]
    ].

ciphers() -> filter_ciphers(ssl:cipher_suites()).

filter_ciphers([{_, '3des_ede_cbc', _} | Rest]) -> filter_ciphers(Rest);
filter_ciphers([{_, des_cbc,        _} | Rest]) -> filter_ciphers(Rest);
filter_ciphers([{_, rc4_128,        _} | Rest]) -> filter_ciphers(Rest);
filter_ciphers([Cipher | Rest]) -> [Cipher | filter_ciphers(Rest)];
filter_ciphers([]) -> [].
contact: Jan Huwald // Impressum