Skip to content

Commit

Permalink
""
Browse files Browse the repository at this point in the history
git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@59 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information
Claes Wikstrom committed May 29, 2002
1 parent 1347a37 commit 661bd8c
Show file tree
Hide file tree
Showing 9 changed files with 474 additions and 126 deletions.
2 changes: 1 addition & 1 deletion ebin/yaws.app
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{application,yaws,
[{description,"yaws WWW server"},
{vsn,"0.34"},
{modules,[yaws, yaws_app, yaws_config, yaws_server, yaws_sup, yaws_api, yaws_log, yaws_ls, yaws_debug, yaws_compile, yaws_ctl]},
{modules,[yaws, yaws_app, yaws_config, yaws_server, yaws_sup, yaws_api, yaws_log, yaws_ls, yaws_debug, yaws_compile, yaws_ctl, yaws_ssl]},
{registered, []},
{mod,{yaws_app,[]}},
{env, []},
Expand Down
7 changes: 4 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ MODULES=yaws \
yaws_ls \
yaws_debug \
yaws_compile \
yaws_ctl
yaws_ctl \
yaws_ssl

EBIN_FILES=$(MODULES:%=../ebin/%.$(EMULATOR)) ../ebin/yaws.app

ERLC_FLAGS+=-W $(DEBUG_FLAGS) -pa ../../yaws
ERLC_FLAGS+=-W +debug_info $(DEBUG_FLAGS) -pa ../../yaws

#
# Targets
Expand All @@ -44,7 +45,7 @@ install: all
install -d $(INSTALLPREFIX)/lib/yaws/ebin
install -d /var/log/yaws
install -d /var/yaws/www
install -d /val/yaws/ebin
install -d /var/yaws/ebin
(cd ..; tar cz ebin --) | (cd $(INSTALLPREFIX)/lib/yaws; tar xz -- )
(cd ..; tar cz include --) | (cd $(INSTALLPREFIX)/lib/yaws; tar xz -- )
(cd ..; tar cz www --) | (cd /var/yaws; tar xz -- )
Expand Down
2 changes: 2 additions & 0 deletions src/yaws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,5 @@ mktags() ->
init:stop().


pids() ->
gen_server:call(yaws_server, pids).
15 changes: 13 additions & 2 deletions src/yaws.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,28 @@
%% one list of #sconf's per listen ip


-record(ssl,
{
keyfile,
certfile,
verify = 0,
depth = 1,
password,
cacertfile,
ciphers,
cachetimeout}).


%% server conf
-record(sconf,
{port = 8000,
ssl = off,
ssl_port = 443,
docroot,
access_log = true,
listen = {127,0,0,1},
servername = "localhost",
default_server_on_this_ip = true,
ets,
ssl,
authdirs = []
}).

Expand Down
100 changes: 97 additions & 3 deletions src/yaws_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ load({file, File}, Trace, Debug) ->
{ok, GC2, Cs} ->
validate_cs(GC2, Cs);
Err ->
?Debug("Load err: ~p", [Err]),
Err
end;
_ ->
Expand Down Expand Up @@ -317,10 +316,96 @@ fload(FD, server, GC, C, Cs, Lno, Chars) ->
false ->
{error, ?F("Expect true|false at line ~w", [Lno])}
end;


%% A bunch of ssl options

["ssl", '=', Bool] ->
case is_bool(Bool) of
{true, Val} ->
ssl:start(),
C2 = C#sconf{ssl = #ssl{}},
fload(FD, server, GC, C2, Cs, Lno, Next);
false ->
{error, ?F("Expect true|false at line ~w", [Lno])}
end;
["ssl_keyfile", '=', Val] ->
case is_file(Val) of
true when record(C#sconf.ssl, ssl) ->
C2 = C#sconf{ssl = (C#sconf.ssl)#ssl{keyfile = Val}},
fload(FD, server, GC, C2, Cs, Lno, Next);
true ->
{error, ?F("Need to set option ssl to true before line ~w",
[Lno])};
_ ->
{error, ?F("Expect existing file at line ~w", [Lno])}
end;
["ssl_certfile", '=', Val] ->
case is_file(Val) of
true when record(C#sconf.ssl, ssl) ->
C2 = C#sconf{ssl = (C#sconf.ssl)#ssl{certfile = Val}},
fload(FD, server, GC, C2, Cs, Lno, Next);
true ->
{error, ?F("Need to set option ssl to true before line ~w",
[Lno])};
_ ->
{error, ?F("Expect existing file at line ~w", [Lno])}
end;
["ssl_cacertfile", '=', Val] ->
case is_file(Val) of
true when record(C#sconf.ssl, ssl) ->
C2 = C#sconf{ssl = (C#sconf.ssl)#ssl{cacertfile = Val}},
fload(FD, server, GC, C2, Cs, Lno, Next);
true ->
{error, ?F("Need to set option ssl to true before line ~w",
[Lno])};
_ ->
{error, ?F("Expect existing file at line ~w", [Lno])}
end;
["ssl_verify", '=', Val] ->
case lists:member(Val, [1,2,3]) of
true when record(C#sconf.ssl, ssl) ->
C2 = C#sconf{ssl = (C#sconf.ssl)#ssl{verify = Val}},
fload(FD, server, GC, C2, Cs, Lno, Next);
true ->
{error, ?F("Need to set option ssl to true before line ~w",
[Lno])};
_ ->
{error, ?F("Expect integer at line ~w", [Lno])}
end;
["ssl_depth", '=', Val] ->
case lists:member(Val, [1,2,3,4,5,6,7]) of
true when record(C#sconf.ssl, ssl) ->
C2 = C#sconf{ssl = (C#sconf.ssl)#ssl{depth = Val}},
fload(FD, server, GC, C2, Cs, Lno, Next);
true ->
{error, ?F("Need to set option ssl to true before line ~w",
[Lno])};
_ ->
{error, ?F("Expect reasonable integer at line ~w", [Lno])}
end;
["ssl_password", '=', Val] ->
if
record(C#sconf.ssl, ssl) ->
C2 = C#sconf{ssl = (C#sconf.ssl)#ssl{password = Val}};
true ->
{error, ?F("Need to set option ssl to true before line ~w",
[Lno])}
end;
["ssl_ciphers", '=', Val] ->
if
record(C#sconf.ssl, ssl) ->
C2 = C#sconf{ssl = (C#sconf.ssl)#ssl{ciphers = Val}};
true ->
{error, ?F("Need to set option ssl to true before line ~w",
[Lno])}
end;


['<', "/server", '>'] ->
fload(FD, globals, GC, undefined, [C|Cs], Lno+1, Next);
[H|_] ->
{error, ?F("Unexpected input ~p at line ~w", [H, Lno])}
[H|T] ->
{error, ?F("Unexpected input ~p at line ~w", [[H|T], Lno])}
end.


Expand All @@ -343,6 +428,15 @@ is_dir(Val) ->
end.


is_file(Val) ->
case file:read_file_info(Val) of
{ok, FI} when FI#file_info.type == regular ->
true;
_ ->
false
end.


%% tokenizer
toks(Chars) ->
toks(Chars, free, [], []). % two accumulators
Expand Down
Loading

0 comments on commit 661bd8c

Please sign in to comment.