topical media & game development
server-policy.cfg / cfg
#!/usr/bin/perl -wT
#
# Simple Flash Socket Policy Server
# www.lightsphere.com/dev/articles/flash_socket_policy.html
#
# Copyright (C) 2008 Jacqueline Kira Hamilton
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use Socket;
use IO::Handle;
my logfile = 'log';
if (logfile") or warn "Can't open !\n";
LOG->autoflush(1);
}
my proto = getprotobyname('tcp');
# start the server:
&log("Starting server on port proto) or die "socket: !";
bind(Server,sockaddr_in(!";
listen(Server,SOMAXCONN) or die "listen: paddr;
&log("Server started. Waiting for connections.");
paddr = accept(Client,Server); close Client) {
Client->autoflush(1);
my(iaddr) = sockaddr_in(ip_address = inet_ntoa(name = gethostbyaddr(ip_address;
&log( scalar localtime() . ": Connection from line = <Client>;
&log("Input: line =~ /.*policy\-file.*/i) {
print Client &xml_policy;
}
}
sub xml_policy {
my str;
}
sub log {
my(should_be_logging) {
print LOG
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.