Skip to contentSkip to conversation

Patch: allow browser as a management GUI

Openvpn-devel P Kern 2 participants 2 messages Jul 11, 2006

lore
Share & tools
lore

P Kern

author
#0 lore raw

Hello.

Just fyi - a patch (id 1520128) has been posted to Sourceforge which allows a browser to connect to the management interface. The patch is based on openvpn-2.1_beta14.

Since most platforms now have a web browser, this patch could lessen the need for a separate OpenVPN management GUI.

Hope this patch proves useful.

Paul Kern, CNS, U Toronto.

-------------------------------------------------------------

http://sourceforge.net/tracker/index.php?func=detail&aid=1520128&group_id=48978&atid=454721

Included in this patch:
- code to extract commands from HTTP format messages.
- code to send HTML-wrapped replies as HTTP messages.
- a simple built-in default "home page".

Example usage:
- configure a patched OpenVPN with ... management localhost 7505 management-query-passwords management-hold
management-http <--[NEW]
- point your web browser at "http://localhost:7505/"

     eg.
        % lynx http://localhost:7505/

Note: real-time messages are not available due to the nature of HTTP.

Compiled+tested on:
FreeBSD 4.10, FreeBSD 5.4, RedHat Linux 2.6.13

Browsers tested:
Lynx, Mozilla, Opera, MSIE.

#1 lore raw
Quoted 6 lines · P Kern

Hello.

Just fyi - a patch (id 1520128) has been posted to Sourceforge which allows a browser to connect to the management interface. The patch is based on openvpn-2.1_beta14.

Quoted 6 lines

Since most platforms now have a web browser, this patch could lessen the need for a separate OpenVPN management GUI.

Hope this patch proves useful.

Paul Kern, CNS, U Toronto.

Hello,

Nice idea!
Just going through your patch...
I have some questions...

Can you please #ifdef all relevant additions, such as:

	HT_send_RAW(man);
	HT_now_reset

I personally don't like multi lines strings... In stead of:
f ("xxxxxx\n\
yyyyy");
Consider:
f ("xxxxxx\n"
"yyyyyy\n");

Also C concat is not so readable you not just writing HTML?

len = openvpn_snprintf(ht_getpw, sizeof(ht_getpw),
"<body onLoad=\"document.%s.%s.focus()\">\r\n\
" MAN_self_form "\" name=\"%s\" method=\"post\">\r\n\
" HTML_HIDE_POST "password\"> [%s] Password: \
" HTML_GETPWD "%s\">\r\n " HTML_SUBMIT "\r\n",

               form, type, form, type, type);

-> Something like:

	I think that when the whole form is written it is much more easy to understand what it does.

	len = openvpn_sprintf (ht_getpw, sizeof (ht_getpw),
		(
			"<html>"
			"<body onload=\"document.prompt.pwd.focus()\">"
				"<form name=\"prompt\" method=\"post\">"
					"<input type=\"hidden\" name=\"%s\">"
					"<p>[%s] Password: <input type=\"password\"></p>"
					"<input type=\"submit\" value=\"Submit\"> <input type=\"button\" value=\"cancel\">"
				"</form>"
			"</body>"
			"</html>"
		),
		type, type
	);

	Cancel should be completed... So that both button will submit with hidden action field to be ok or cancel.

	Next stage is to move all these strings into external files... So they can be modified without the need of
	recompilation... I am thinking about translation and such. There can be an option to read these files...
	These files will be much easier to write since you don't have to escape quotes :)

	Also, it is better to have variables in a $0...$N format so that the order may be modified for different languages.
	Better is to insert variables as ${var}... And if you want to go standard, you can parse <%=var%> :)

Why did you change:

       if (parms[0] && streq (parms[0], "password"))

- msg (D_MANAGEMENT_DEBUG, "MANAGEMENT: CMD 'password [...]'");
+ msg (D_MANAGEMENT_DEBUG, "MANAGEMENT: GET 'password [...]'");
else
- msg (D_MANAGEMENT_DEBUG, "MANAGEMENT: CMD '%s'", line);
+ msg (D_MANAGEMENT_DEBUG, "MANAGEMENT: GET '%s'", line);

Best Regards,
Alon Bar-Lev.