Problem Statement
In some environments, users of the
snom 4S would like to be able to automatically
perform actions such as registering new users
and deactivating accounts. In principle, these
actions are not critical to performance.
The snom 4S software components have
a built-in web server that supports the features
required. It therefore makes sense to have a
“remote control” that uses the web interface
of the Proxy or the Media Server in the same
fashion as real users do. The snom 4S does
not recognize that a shell script controls its
behavior.
Initiating Web Access from the
Command Line Interface
The problem of controlling a remote web
server from a shell is well known. There are
programs available for performing this task -
“curl” is available for Linux and for Windows
and can be integrated into shell scripts and
PHP programs. For more information, see
http://curl.haxx.se. Other web programs work
in a similar way.
The proxy and the media server do not
differentiate between POST and GET with
parameters in the URL.
Parameter values are “url-encoded”. That
means that some special characters have a
particular meaning. For instance, the “&” is
a separator symbol between the parameters,
the “+” means a space character and “=” is
used to indicate an assignment of a value to
a variable. If you want to encode one of these
special characters (and other characters that
are not in the normal character set), you can
use the % followed by the two-digit hex code
of the character to encode the character that
you need. If in doubt, you should use the %xx
notation.
Proxy Version 2.3x and Higher
In the 3.x versions of the proxy, we use
a scripting language to control the behavior of
the proxy. When the proxy receives a request
to post information to a predened webpage
(post.htm), it rst determines the domain
and the password for this domain. If there is
a match, it sets all variables in the http post
accordingly and calls the subroutine “on_post”.
This function can then perform the necessary
actions (a predened behavior is available,
see below). Sending information to the proxy
does not require a session context.
For example, if you use “curl http://
myproxy:8080/post.htm?domain=abc.com&p
ass=secret&var1=abc&var2=hello+here%21”
, the proxy will execute the function “on_post”
in the domain context of “abc.com” (if it exists
and the password is “secret”). The variable
“$var1” will be set to “abc” and the variable
“$var2” will be set to “hello here!”.
The Default on_post() Function
The proxy comes with several predened
default functions. If you load another on_
post() function in the domain, these functions
are overwritten.
The default script uses the variable
“action” to indicate what the proxy should do.
• create_user:
This function uses the variables
“account” (which indicates the account to
use), “username” (which indicates the user
name for challenging) and “password” (the
password for challenging) to create or update
a user account.
• delete_user:
This function deletes a user account
(indicated in the variable “account”).
• disable_user:
This function disables a user account
(indicated in the variable “account”).
• enable_user: