* VRFS-1000 - mapped all the castles, got the xml working, and added more tests

This commit is contained in:
Seth Call 2014-01-17 04:51:19 +00:00
parent cfa2ba383a
commit 5d6e34f374
35 changed files with 931 additions and 865 deletions

View File

@ -13,7 +13,7 @@ CREATE TABLE icecast_limits (
queue_size INTEGER NOT NULL DEFAULT 102400,
-- does not appear to be used
client_timeout INTEGER DEFAULT 10,
client_timeout INTEGER DEFAULT 30,
-- The maximum time (in seconds) to wait for a request to come in once
-- the client has made a connection to the server.
@ -35,23 +35,23 @@ CREATE TABLE icecast_limits (
);
create table icecast_admin_authentications (
CREATE TABLE icecast_admin_authentications (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- The unencrypted password used by sources to connect to icecast2.
-- The default username for all source connections is 'source' but
-- this option allows to specify a default password. This and the username
-- The DEFAULT username for all source connections is 'source' but
-- this option allows to specify a DEFAULT password. This and the username
-- can be changed in the individual mount sections.
source_password VARCHAR(64) NOT NULL DEFAULT 'icejam321',
source_password VARCHAR(64) NOT NULL,
-- Used in the master server as part of the authentication when a slave requests
-- the list of streams to relay. The default username is 'relay'
relay_user VARCHAR(64) NOT NULL DEFAULT 'relay',
relay_password VARCHAR(64) NOT NULL DEFAULT 'jkrelayhack',
-- the list of streams to relay. The DEFAULT username is 'relay'
relay_user VARCHAR(64) NOT NULL,
relay_password VARCHAR(64) NOT NULL,
--The username/password used for all administration functions.
admin_user VARCHAR(64) NOT NULL DEFAULT 'jkadmin',
admin_password VARCHAR(64) NOT NULL DEFAULT 'jKadmin123',
admin_user VARCHAR(64) NOT NULL,
admin_password VARCHAR(64) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
@ -60,294 +60,282 @@ create table icecast_admin_authentications (
--contains all the settings for listing a stream on any of the Icecast2 YP Directory servers.
-- Multiple occurances of this section can be specified in order to be listed on multiple directory servers.
create table icecast_directories (
CREATE TABLE icecast_directories (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
yp_url_timeout INTEGER not null default 15,
yp_url VARCHAR(1024) not null UNIQUE default 'http://dir.xiph.org/cgi-bin/yp-cgi',
yp_url_timeout INTEGER NOT NULL DEFAULT 15,
yp_url VARCHAR(1024) NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_servermiscs (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- This is the DNS name or IP address that will be used for the stream directory lookups or possibily
-- the playlist generation if a Host header is not provided. While localhost is shown as an example,
-- in fact you will want something that your listeners can use.
hostname VARCHAR(256) not null default 'concertsvr.jamkazam.com',
--This sets the location string for this icecast instance. It will be shown e.g in the web interface.
location VARCHAR(128) not null default 'earth',
--This should contain contact details for getting in touch with the server administrator.
admin VARCHAR(128) not null default 'icemaster@localhost',
-- This flag turns on the icecast2 fileserver from which static files can be served.
-- All files are served relative to the path specified in the <paths><webroot> configuration
-- setting. By default the setting is enabled so that requests for the images
-- on the status page are retrievable.
fileserve INTEGER not null default 1,
-- This optional setting allows for the administrator of the server to override the
-- default server identification. The default is icecast followed by a version number
-- and most will not care to change it however this setting will change that.
server_id VARCHAR(128) not null default 'icecast 2.3',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_listen_sockets (
CREATE TABLE icecast_listen_sockets (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- The TCP port that will be used to accept client connections.
port INTEGER not null default 8001,
port INTEGER NOT NULL DEFAULT 8001,
-- An optional IP address that can be used to bind to a specific network card.
-- If not supplied, then it will bind to all interfaces.
bind_address VARCHAR(128),
bind_address VARCHAR(1024),
shoutcast_mount VARCHAR(128) default NULL,
shoutcast_compat INTEGER not null default 0,
shoutcast_mount VARCHAR(1024),
shoutcast_compat INTEGER,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_mastersvr_relays (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- ip address of the master icecast server and port number
master_server VARCHAR(128) not null,
master_server_port INTEGER not null,
--The interval (in seconds) that the Relay Server will poll the Master Server for any new mountpoints to relay.
master_update_interval INTEGER not null default 120,
-- This is the relay username on the master server. It is used to query the server for a list of
-- mountpoints to relay. If not specified then 'relay' is used
master_username VARCHAR(64) not null default 'relay',
master_password VARCHAR(64) not null,
--Global on-demand setting for relays. Because you do not have individual relay options when
-- using a master server relay, you still may want those relays to only pull the stream when
-- there is at least one listener on the slave. The typical case here is to avoid surplus
-- bandwidth costs when no one is listening.
relays_on_demand INTEGER default 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
--make sure this combo is unique
--CONSTRAINT serverID UNIQUE KEY (master_server,master_server_port)
);
create table icecast_relays (
CREATE TABLE icecast_relays (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- ip address of server we are relaying from and port number
server VARCHAR(128) not null,
port INTEGER not null default 8001,
server VARCHAR(1024) NOT NULL,
port INTEGER NOT NULL DEFAULT 8001,
-- mount at server. eg /example.ogg
mount VARCHAR(128) not null,
mount VARCHAR(1024) NOT NULL,
-- eg /different.ogg
local_mount VARCHAR(128) not null default '/relaymout.ogg',
local_mount VARCHAR(1024),
-- eg joe. could be null
username VARCHAR(64) not null default 'jkicerelayusr' ,
username VARCHAR(64),
-- user password
password VARCHAR(64) not null default 'jkicerelaypwd' ,
relay_shoutcast_metadata INTEGER default 0,
password VARCHAR(64),
relay_shoutcast_metadata BOOLEAN DEFAULT FALSE,
--- relay only if we have someone wanting to listen
on_demand INTEGER default 0,
on_demand BOOLEAN DEFAULT TRUE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create TABLE icecast_user_authentications(
CREATE TABLE icecast_user_authentications(
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
--"htpasswd or url"
-- real name is type
stype VARCHAR(16) DEFAULT 'url' ,
authentication_type VARCHAR(16) DEFAULT 'url',
-- these are for httpasswd
filename VARCHAR(256) default NULL,
allow_duplicate_users INTEGER DEFAULT 1,
filename VARCHAR(1024),
allow_duplicate_users BOOLEAN,
-- these options are for url
-- eg value="http://myauthserver.com/stream_start.php"
mount_add VARCHAR(256) DEFAULT 'http://icecastauth.jamkazam.com/stream_start.php',
mount_add VARCHAR(1024),
--value="http://myauthserver.com/stream_end.php"
mount_remove VARCHAR(256) default 'http://icecastauth.jamkazam.com/stream_end.php',
mount_remove VARCHAR(1024),
--value="http://myauthserver.com/listener_joined.php"
listener_add VARCHAR(256) default 'http://icecastauth.jamkazam.com/listener_joined.php',
listener_add VARCHAR(1024),
--value="http://myauthserver.com/listener_left.php"
listener_remove VARCHAR(256) default 'http://icecastauth.jamkazam.com/listener_left.php',
listener_remove VARCHAR(1024),
-- value="user"
username VARCHAR(64) default 'jkuser',
username VARCHAR(64),
-- value="pass"
password VARCHAR(64) DEFAULT 'jkhackpass',
password VARCHAR(64),
-- value="icecast-auth-user: 1"
auth_header VARCHAR(64) default 'icecast-auth-user: 1',
auth_header VARCHAR(64) DEFAULT 'icecast-auth-user: 1',
-- value="icecast-auth-timelimit:"
timelimit_header VARCHAR(64) default 'icecast-auth-timelimit:',
timelimit_header VARCHAR(64) DEFAULT 'icecast-auth-timelimit:',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_mounts (
CREATE UNLOGGED TABLE icecast_mounts (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- eg/example-complex.ogg
mount_name VARCHAR(128) UNIQUE NOT NULL,
username VARCHAR(64) NOT NULL DEFAULT 'jamsource',
password VARCHAR(64) NOT NULL DEFAULT 'jamhackmesourcepwd',
max_listeners INTEGER NOT NULL DEFAULT 4,
max_listener_duration INTEGER NOT NULL DEFAULT 3600,
mount_name VARCHAR(1024) UNIQUE NOT NULL,
username VARCHAR(64),
password VARCHAR(64),
max_listeners INTEGER DEFAULT 4,
max_listener_duration INTEGER DEFAULT 3600,
-- dump of the stream coming through on this mountpoint.
-- eg /tmp/dump-example1.ogg
dump_file VARCHAR(256) DEFAULT NULL,
dump_file VARCHAR(1024),
-- intro music to play
-- This optional value specifies a mountpoint that clients are automatically moved to
-- if the source shuts down or is not streaming at the time a listener connects.
intro VARCHAR(256) NOT NULL DEFAULT '/intro.ogg',
fallback_mount VARCHAR(256) NOT NULL DEFAULT '/sourcedown.ogg',
intro VARCHAR(1024),
fallback_mount VARCHAR(1024),
-- When enabled, this allows a connecting source client or relay on this mountpoint
-- to move listening clients back from the fallback mount.
fallback_override INTEGER DEFAULT 1,
fallback_override BOOLEAN DEFAULT TRUE,
-- When set to 1, this will cause new listeners, when the max listener count for the mountpoint
-- has been reached, to move to the fallback mount if there is one specified.
fallback_when_full INTEGER DEFAULT 1,
fallback_when_full BOOLEAN DEFAULT TRUE,
--For non-Ogg streams like MP3, the metadata that is inserted into the stream often
-- has no defined character set.
charset VARCHAR(256) NOT NULL DEFAULT 'ISO8859-1',
-- possilble values are -1, 0, 1
charset VARCHAR(1024) DEFAULT 'ISO8859-1',
-- possible values are -1, 0, 1
-- real name is public but this is reserved word in ruby
publicc INTEGER DEFAULT 1,
is_public INTEGER DEFAULT 0,
stream_name VARCHAR(256) NOT NULL DEFAULT 'My Jamkazam Audio Stream',
stream_description VARCHAR(256) NOT NULL DEFAULT 'My JK audio description',
stream_name VARCHAR(1024),
stream_description VARCHAR(10000),
-- direct to user page
stream_url VARCHAR(256) NOT NULL DEFAULT 'http://wwww.jamakazam.com#user_id',
stream_url VARCHAR(1024),
-- get this from the session info
genre VARCHAR(64) NOT NULL DEFAULT 'Unknown',
bitrate integer NOT NULL default 92,
genre VARCHAR(256),
bitrate INTEGER,
-- real name is type but this is reserved name in ruby
mtype VARCHAR(64) NOT NULL DEFAULT 'application/ogg' ,
subtype VARCHAR(64) NOT NULL DEFAULT 'vorbis',
mime_type VARCHAR(64) NOT NULL DEFAULT 'application/ogg' ,
subtype VARCHAR(64) NOT NULL DEFAULT 'vorbis',
-- This optional setting allows for providing a burst size which overrides the
-- DEFAULT burst size as defined in limits. The value is in bytes.
burst_size INTEGER,
mp3_metadata_interval INTEGER,
-- Enable this to prevent this mount from being shown on the xsl pages.
-- This is mainly for cases where a local relay is configured and you do
-- not want the source of the local relay to be shown
hidden INTEGER DEFAULT 1,
-- This optional setting allows for providing a burst size which overrides the
-- default burst size as defined in limits. The value is in bytes.
burst_size INTEGER DEFAULT 65536,
mp3_metadata_interval INTEGER DEFAULT 4096,
hidden BOOLEAN DEFAULT TRUE,
--called when the source connects or disconnects. The scripts are called with the name of the mount
on_connect VARCHAR(256) DEFAULT '/home/icecast/bin/source-start',
on_disconnect VARCHAR(256) DEFAULT '/home/icecast/bin/source-end',
on_connect VARCHAR(1024),
on_disconnect VARCHAR(1024),
user_authentication_id varchar(64) DEFAULT NULL references icecast_user_authentications(id),
-- references icecast_user_authentications(id)
authentication_id varchar(64) DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_paths (
CREATE TABLE icecast_paths (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
basedir VARCHAR(256) NOT NULL DEFAULT './',
logdir VARCHAR(256) NOT NULL DEFAULT './logs',
pidfile VARCHAR(256) NOT NULL DEFAULT './icecast.pid',
webroot VARCHAR(256) NOT NULL DEFAULT './web',
adminroot VARCHAR(256) NOT NULL DEFAULT './admin',
allow_ip VARCHAR(256) NOT NULL DEFAULT '/path/to/ip_allowlist',
deny_ip VARCHAR(256) NOT NULL DEFAULT '/path_to_ip_denylist',
--real name is alias but alias is reserved in ruby
aliass VARCHAR(256) DEFAULT 'source="/foo" dest="/bar"',
base_dir VARCHAR(1024) NOT NULL DEFAULT './',
log_dir VARCHAR(1024) NOT NULL DEFAULT './logs',
pid_file VARCHAR(1024) NOT NULL DEFAULT './icecast.pid',
web_root VARCHAR(1024) NOT NULL DEFAULT './web',
admin_root VARCHAR(1024) NOT NULL DEFAULT './admin',
allow_ip VARCHAR(1024),
deny_ip VARCHAR(1024),
alias_source VARCHAR(1024),
alias_dest VARCHAR(1024),
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_loggings (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
accesslog VARCHAR(256) NOT NULL DEFAULT 'access.log',
errorlog VARCHAR(256) NOT NULL DEFAULT 'error.log',
playlistlog VARCHAR(256) NOT NULL DEFAULT 'playlist.log',
-- 4 Debug, 3 Info, 2 Warn, 1 Error
loglevel INTEGER NOT NULL DEFAULT 4 ,
CREATE TABLE icecast_loggings (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
access_log VARCHAR(1024) NOT NULL DEFAULT 'access.log',
error_log VARCHAR(1024) NOT NULL DEFAULT 'error.log',
playlist_log VARCHAR(1024),
-- 4 Debug, 3 Info, 2 Warn, 1 Error
log_level INTEGER NOT NULL DEFAULT 3 ,
log_archive BOOLEAN,
-- 10 meg log file by default
log_size INTEGER DEFAULT 10000,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_securities (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
chroot INTEGER NOT NULL DEFAULT 0,
changeowner_user VARCHAR(64) DEFAULT 'nobody',
changeowner_group VARCHAR(64) DEFAULT 'nogroup',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
CREATE TABLE icecast_securities (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
chroot BOOLEAN NOT NULL DEFAULT FALSE,
change_owner_user VARCHAR(64),
change_owner_group VARCHAR(64),
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create TABLE icecast_servers(
CREATE TABLE icecast_master_server_relays(
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
-- ip address of the master icecast server and port number
master_server VARCHAR(1024) NOT NULL,
master_server_port INTEGER NOT NULL DEFAULT 8001,
--The interval (in seconds) that the Relay Server will poll the Master Server for any new mountpoints to relay.
master_update_interval INTEGER NOT NULL DEFAULT 120,
-- This is the relay username on the master server. It is used to query the server for a list of
-- mountpoints to relay. If not specified then 'relay' is used
master_username VARCHAR(64) NOT NULL,
master_password VARCHAR(64) NOT NULL,
--Global on-demand setting for relays. Because you do not have individual relay options when
-- using a master server relay, you still may want those relays to only pull the stream when
-- there is at least one listener on the slave. The typical case here is to avoid surplus
-- bandwidth costs when no one is listening.
relays_on_demand BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE icecast_servers (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
--use this to mark the server configuration as needing to be regenerated
config_changed INTEGER DEFAULT 0,
config_changed BOOLEAN DEFAULT FALSE,
limit_id VARCHAR(64) REFERENCES icecast_limits(id),
admin_auth_id VARCHAR(64) REFERENCES icecast_admin_authentications(id),
directory_id VARCHAR(64) REFERENCES icecast_directories(id),
master_relay_id VARCHAR(64) REFERENCES icecast_master_server_relays(id),
path_id VARCHAR(64) REFERENCES icecast_paths(id),
logging_id VARCHAR(64) REFERENCES icecast_loggings(id),
security_id VARCHAR(64) REFERENCES icecast_securities(id),
limit_id VARCHAR(64) REFERENCES icecast_limits(id),
adminauth_id VARCHAR(64) REFERENCES icecast_admin_authentications(id),
directory_id VARCHAR(64) REFERENCES icecast_directories(id),
misc_id VARCHAR(64) REFERENCES icecast_servermiscs(id),
master_relay_id VARCHAR(64) REFERENCES icecast_mastersvr_relays(id),
/* relay_ids VARCHAR(64) REFERENCES icecast_serverrelays(id),
mount_ids VARCHAR(64) REFERENCES icecast_servermounts(id),
socket_ids VARCHAR(64) REFERENCES icecast_serversockets(id) ,
*/
-- This is the DNS name or IP address that will be used for the stream directory lookups or possibily
-- the playlist generation if a Host header is not provided. While localhost is shown as an example,
-- in fact you will want something that your listeners can use.
hostname VARCHAR(1024) NOT NULL,
--This sets the location string for this icecast instance. It will be shown e.g in the web interface.
location VARCHAR(1024) NOT NULL,
--This should contain contact details for getting in touch with the server administrator.
admin_email VARCHAR(1024) NOT NULL DEFAULT 'admin@jamkazam.com',
-- This flag turns on the icecast2 fileserver from which static files can be served.
-- All files are served relative to the path specified in the <paths><webroot> configuration
-- setting. By DEFAULT the setting is enabled so that requests for the images
-- on the status page are retrievable.
fileserve BOOLEAN NOT NULL DEFAULT TRUE,
-- This optional setting allows for the administrator of the server to override the
-- DEFAULT server identification. The DEFAULT is icecast followed by a version number
-- and most will not care to change it however this setting will change that.
server_id VARCHAR(1024),
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE icecast_servermounts (
CREATE TABLE icecast_server_mounts (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
mount_id VARCHAR(64) REFERENCES icecast_mounts(id) ON DELETE CASCADE,
server_id VARCHAR(64) REFERENCES icecast_servers(id) ON DELETE CASCADE,
--REFERENCES icecast_mounts(id) ON DELETE CASCADE,
icecast_mount_id VARCHAR(64),
icecast_server_id VARCHAR(64) REFERENCES icecast_servers(id) ON DELETE CASCADE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE icecast_servermounts ADD CONSTRAINT server_mount_uniqkey UNIQUE (server_id, mount_id);
ALTER TABLE icecast_server_mounts ADD CONSTRAINT server_mount_uniqkey UNIQUE (icecast_mount_id, icecast_server_id);
CREATE TABLE icecast_serverrelays (
CREATE TABLE icecast_server_relays (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
relay_id VARCHAR(64) REFERENCES icecast_relays(id) ON DELETE CASCADE,
server_id VARCHAR(64) REFERENCES icecast_servers(id) ON DELETE CASCADE,
icecast_relay_id VARCHAR(64) REFERENCES icecast_relays(id) ON DELETE CASCADE,
icecast_server_id VARCHAR(64) REFERENCES icecast_servers(id) ON DELETE CASCADE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE icecast_serverrelays ADD CONSTRAINT server_relay_uniqkey UNIQUE (server_id, relay_id);
ALTER TABLE icecast_server_relays ADD CONSTRAINT server_relay_uniqkey UNIQUE (icecast_relay_id, icecast_server_id);
CREATE TABLE icecast_serversockets (
CREATE TABLE icecast_server_sockets (
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
socket_id VARCHAR(64) REFERENCES icecast_listen_sockets(id) ON DELETE CASCADE,
server_id VARCHAR(64) REFERENCES icecast_servers(id) ON DELETE CASCADE,
icecast_listen_socket_id VARCHAR(64) REFERENCES icecast_listen_sockets(id) ON DELETE CASCADE,
icecast_server_id VARCHAR(64) REFERENCES icecast_servers(id) ON DELETE CASCADE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE icecast_serversockets ADD CONSTRAINT server_socket_uniqkey UNIQUE (server_id, socket_id);
ALTER TABLE icecast_server_sockets ADD CONSTRAINT server_socket_uniqkey UNIQUE (icecast_listen_socket_id, icecast_server_id);

View File

@ -30,6 +30,7 @@ gem 'resque'
gem 'resque-retry'
gem 'resque-failed-job-mailer' #, :path => "/Users/seth/workspace/resque_failed_job_mailer"
gem 'oj'
gem 'builder'
if devenv
gem 'jam_db', :path=> "../db/target/ruby_package"

View File

@ -99,13 +99,13 @@ require "jam_ruby/models/icecast_directory"
require "jam_ruby/models/icecast_limit"
require "jam_ruby/models/icecast_listen_socket"
require "jam_ruby/models/icecast_logging"
require "jam_ruby/models/icecast_mastersvr_relay"
require "jam_ruby/models/icecast_master_server_relay"
require "jam_ruby/models/icecast_mount"
require "jam_ruby/models/icecast_path"
require "jam_ruby/models/icecast_relay"
require "jam_ruby/models/icecast_sercurity"
require "jam_ruby/models/icecast_security"
require "jam_ruby/models/icecast_server"
require "jam_ruby/models/icecast_servermisc"
#require "jam_ruby/models/icecast_servermisc"
require "jam_ruby/models/icecast_user_authentication"
include Jampb

View File

@ -1,102 +1,23 @@
module JAmXml
def jdumpXml (hash, nm, ident=1, output=$stdout, child=nil)
tb = "\t"
tbs = tb * ident
unless ident <= 0
tbse = tb * (ident-1)
output.puts "#{tbse}<#{nm}>"
end
hash.each do |key, val|
#puts "attrib: key=#{key} val=#{val}"
el = key
if !key.nil? && !key.empty?
el = key.gsub(/_/, '-')
end
sv = val
if val.to_s.empty?
#skip ???
next if val.to_s.empty?
else
if val.instance_of? String
#encode the string to be xml safe
sv = CGI.escapeHTML(val)
end
end
if key.empty?
output.puts "#{tbs}<#{sv}/>"
else
output.puts "#{tbs}<#{el}>#{sv}</#{el}>"
end
end
if !child.nil?
if child.kind_of? Array
child.each { |x| x.dumpXml(ident+1,output)}
else
child.dumpXml(ident+1,output)
end
end
unless ident <= 0
output.puts "#{tbse}</#{nm}>"
end
end
def jMakeStrXmlSafe(val)
sv = val
if val.to_s.empty?
#skip ???
sv =""
else
if val.instance_of? String
#encode the string to be xml safe
sv = CGI.escapeHTML(val)
end
end
return sv
end
end
module JamRuby
class IcecastAdminAuthentication < ActiveRecord::Base
include JAmXml
attr_accessible :source_password, :relay_user, :relay_password, :admin_user, :admin_password
#myattr_accessor = [:source_password, :relay_user, :relay_password, :admin_user, :admin_password ]
after_initialize :init
protected
def init
#set only if nil
self.source_password ||= "UndefinedSourcePassword"
self.admin_password ||= "JKAminPw"
end
public
self.primary_key = 'id'
has_many :servers, :class_name => "JamRuby::IcecastServer", :inverse_of => :admin_auth, :foreign_key => "admin_auth_id"
validates :source_password, presence: true, length: {minimum: 5}
validates :admin_password, presence: true, length: {minimum: 5}
validates :relay_user, presence: true, length: {minimum: 5}
validates :relay_password, presence: true, length: {minimum: 5}
validates :admin_user, presence: true, length: {minimum: 5}
def dumpXml (ident=1, output=$stdout)
hash = Hash["source_password" => self.source_password,
"relay_user" => self.relay_user,
"relay_password" => self.relay_password,
"admin_user" => self.admin_user,
"admin_password" => self.admin_password]
def dumpXml (builder)
self.jdumpXml(hash,"authentication", ident,output)
builder.tag! 'authentication' do |auth|
auth.tag! 'source-password', source_password
auth.tag! 'admin-user', admin_user
auth.tag! 'relay-user', relay_user
auth.tag! 'relay-password', relay_password
auth.tag! 'admin-password', admin_password
end
end
end
end

View File

@ -1,17 +1,20 @@
module JamRuby
class IcecastDirectory < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
has_many :servers, :class_name => "JamRuby::IcecastServer", :inverse_of => :directory, :foreign_key => "directory_id"
attr_accessible :yp_url_timeout, :yp_url
validates :yp_url_timeout, numericality: {only_integer: true}, length: {in: 1..30}
validates :yp_url_timeout, presence: true, numericality: {only_integer: true}, length: {in: 1..30}
validates :yp_url, presence: true
def dumpXml (ident=1, output=$stdout)
hash = Hash["yp_url_timeout" => self.yp_url_timeout,
"yp_url" => self.yp_url]
self.jdumpXml(hash, "directory", ident, output)
def dumpXml (builder)
builder.tag! 'directory' do |dir|
dir.tag! 'yp-url-timeout', yp_url_timeout
dir.tag! 'yp-url', yp_url
end
end
end
end

View File

@ -1,37 +1,28 @@
module JamRuby
class IcecastLimit < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
has_many :servers, class_name: 'JamRuby::IcecastServer', inverse_of: :limit, foreign_key: 'limit_id'
attr_accessible :clients, :sources, :queue_size, :client_timeout, :header_timeout, :source_timeout, :burst_size
validates :clients, presence: true, numericality: {only_integer: true}, length: {in: 1..15000}
validates :sources, presence: true, numericality: {only_integer: true}, length: {in:1..10000}
validates :queue_size, presence: true, numericality: {only_integer: true}
validates :client_timeout, presence: true, numericality: {only_integer: true}
validates :header_timeout, presence: true, numericality: {only_integer: true}
validates :source_timeout, presence: true, numericality: {only_integer: true}
validates :burst_size, presence: true, numericality: {only_integer: true}
validates :clients, numericality: {only_integer: true}, length: {in: 1..15000}
def dumpXml (builder)
after_initialize :init
def init
self.clients ||= 10000
self.sources ||= 1000
self.queue_size ||= 102400
self.client_timeout ||= 30
self.header_timeout ||= 15
self.source_timeout ||= 10
self.burst_size ||= 65536
end
def dumpXml (ident=1, output=$stdout)
hash = Hash["clients" => self.clients,
"sources" => self.sources,
"queue_size" => self.queue_size,
"client_timeout" => self.client_timeout,
"header_timeout" => self.header_timeout]
hash.merge! "source_timeout" => self.source_timeout,
"burst_size" => self.burst_size
self.jdumpXml(hash, "limits", ident, output)
builder.tag! 'limits' do |limits|
limits.tag! 'clients', clients
limits.tag! 'sources', sources
limits.tag! 'queue-size', queue_size
limits.tag! 'client-timeout', client_timeout
limits.tag! 'header-timeout', header_timeout
limits.tag! 'source-timeout', source_timeout
limits.tag! 'burst-on-connect', 1
limits.tag! 'burst-size', burst_size
end
end
end

View File

@ -1,21 +1,19 @@
module JamRuby
class IcecastListenSocket < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :port, :bind_address, :shoutcast_mount, :shoutcast_compat
belongs_to :server, :class_name => "JamRuby::IcecastServer" , :inverse_of => :sockets
has_and_belongs_to_many :servers, :class_name => "JamRuby::IcecastServer", :join_table => "icecast_server_sockets"
def dumpXml (ident=1, output=$stdout)
hash = Hash["port" => self.port,
"bind_address" => self.bind_address,
"shoutcast_mount" => self.shoutcast_mount,
"shoutcast_compat" => self.shoutcast_compat]
validates :port, presence: true, numericality: {only_integer: true}, length: {in: 1..65535}
validates :shoutcast_compat, :inclusion => {:in => [nil, true, false]}
self.jdumpXml(hash, "listen-socket", ident, output)
def dumpXml (builder)
builder.tag! 'listen-socket' do |listen|
listen.tag! 'port', port
listen.tag! 'bind-address', bind_address if bind_address
listen.tag! 'shoutcast-mount', shoutcast_mount if shoutcast_mount
listen.tag! 'shoutcast-compat', shoutcast_compat ? 1 : 0 unless shoutcast_compat.nil?
end
end
end
end

View File

@ -1,20 +1,23 @@
module JamRuby
class IcecastLogging < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :accesslog, :errorlog, :playlistlog, :loglevel
has_many :servers, :class_name => "JamRuby::IcecastServer", :inverse_of => :logging, :foreign_key => "logging_id"
def dumpXml (ident=1, output=$stdout)
hash = Hash["accesslog" => self.accesslog,
"errorlog" => self.errorlog,
"loglevel" => self.loglevel,
"playlistlog" => self.playlistlog]
self.jdumpXml(hash, "logging", ident, output)
validates :access_log, presence: true
validates :error_log, presence: true
validates :log_level, :inclusion => {:in => [1, 2, 3, 4]}
validates :log_archive, :inclusion => {:in => [nil, true, false]}
validates :log_size, numericality: {only_integer: true}, if: lambda {|m| m.log_size.present?}
def dumpXml(builder)
builder.tag! 'logging' do |log|
log.tag! 'accesslog', access_log
log.tag! 'errorlog', error_log
log.tag! 'playlistlog', playlist_log if playlist_log
log.tag! 'logsize', log_size if log_size
log.tag! 'logarchive', log_archive ? '1' : '0' unless log_archive.nil?
log.tag! 'loglevel', log_level
end
end
end
end

View File

@ -0,0 +1,22 @@
module JamRuby
class IcecastMasterServerRelay < ActiveRecord::Base
has_many :servers, :class_name => "JamRuby::IcecastServer", :inverse_of => :master_relay, :foreign_key => "master_relay_id"
validates :master_server, presence: true, length: {minimum: 1}
validates :master_server_port, presence: true, numericality: {only_integer: true}, length: {in: 1..65535}
validates :master_update_interval, presence: true, numericality: {only_integer: true}, length: {in: 1..1200}
validates :master_username, presence: true, length: {minimum: 5}
validates :master_password, presence: true, length: {minimum: 5}
validates :relays_on_demand, :inclusion => {:in => [true, false]}
def dumpXml(builder)
builder.tag! 'master-server', master_server
builder.tag! 'master-server-port', master_server_port
builder.tag! 'master-update-interval', master_update_interval
builder.tag! 'master-username', master_username
builder.tag! 'master-password', master_password
builder.tag! 'relays-on-demand', relays_on_demand ? '1' : '0'
end
end
end

View File

@ -1,18 +0,0 @@
module JamRuby
class IcecastMastersvrRelay < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :master_server, :master_server_port, :master_username, :master_password, :relays_on_demand
validates :master_password, :master_username, presence: true
def dumpXml (ident=0, output=$stdout)
hash = Hash["master_server" => self.master_server,
"master_server_port" => self.master_server_port,
"master_username" => self.master_username,
"master_password" => self.master_password,
"relays_on_demand" => self.relays_on_demand]
self.jdumpXml(hash, "masterrelay", ident, output)
end
end
end

View File

@ -1,64 +1,65 @@
module JamRuby
class IcecastMount < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :mount_name, :username, :password, :max_listeners, :max_listener_duration, :dump_file
attr_accessible :intro, :fallback_mount, :fallback_override, :fallback_when_full, :charset
attr_accessible :publicc, :stream_name, :stream_description, :stream_url, :genre, :bitrate
attr_accessible :mtype, :subtype, :hidden, :burst_size, :mp3_metadata_interval, :on_connect, :on_disconnect
belongs_to :authentication, class_name: "JamRuby::IcecastUserAuthentication", inverse_of: :mount
has_and_belongs_to_many :servers, :class_name => "JamRuby::IcecastServer", :join_table => "icecast_server_mounts"
validates :mount_name, presence: true
validates :username, presence: true
validates :password, presence: true
validates :username, length: {minimum: 5}, if: lambda {|m| m.username.present?}
validates :password, length: {minimum: 5}, if: lambda {|m| m.password.present?}
validates :max_listeners, length: {in: 1..15000}, if: lambda {|m| m.max_listeners.present?}
validates :max_listener_duration, length: {in: 1..3600 * 48}, if: lambda {|m| m.max_listener_duration.present?}
validates :fallback_override, :inclusion => {:in => [true, false]} , if: lambda {|m| m.fallback_mount.present?}
validates :fallback_when_full, :inclusion => {:in => [true, false]} , if: lambda {|m| m.fallback_mount.present?}
validates :is_public, presence: true, :inclusion => {:in => [-1, 0, 1]}
validates :stream_name, presence: true
validates :stream_description, presence: true
validates :stream_url, presence: true
validates :genre, presence: true
validates :bitrate, numericality: {only_integer: true}, if: lambda {|m| m.bitrate.present?}
validates :mime_type, presence: true
validates :subtype, presence: true
validates :burst_size, numericality: {only_integer: true}, if: lambda {|m| m.burst_size.present?}
validates :mp3_metadata_interval, numericality: {only_integer: true}, if: lambda {|m| m.mp3_metadata_interval.present?}
validates :hidden, presence: true, :inclusion => {:in => [true, false]}
#has_one :authentication, :class_name => "IcecastUserAuthentication"
has_one :authentication, :class_name => "IcecastUserAuthentication"
belongs_to :servermount, :class_name => "JamRuby::IcecastServermount" , :inverse_of => :mount
def dumpXml (ident=1, output=$stdout)
hash = Hash["mount_name" => self.mount_name,
"username" => self.username,
"password" => self.password,
"max_listeners" => self.max_listeners,
"max_listener_duration" => self.max_listener_duration,
"dump_file" => self.dump_file,
def dumpXml(builder)
builder.tag! 'mount' do |mount|
mount.tag! 'mount-name', mount_name
mount.tag! 'username', username if username
mount.tag! 'password', password if password
mount.tag! 'max-listeners', max_listeners if max_listeners
mount.tag! 'max-listener-duration', max_listener_duration if max_listener_duration
mount.tag! 'dump-file', dump_file if dump_file
mount.tag! 'intro', intro if intro
mount.tag! 'fallback-mount', fallback_mount if fallback_mount
mount.tag! 'fallback-override', fallback_override ? '1' : '0' unless fallback_override.nil?
mount.tag! 'fallback-when-full', fallback_when_full ? '1' : '0' unless fallback_when_full.nil?
mount.tag! 'charset', charset if charset
mount.tag! 'public', is_public
mount.tag! 'stream-name', stream_name if stream_name
mount.tag! 'stream-description', stream_description if stream_description
mount.tag! 'stream-url', stream_url if stream_url
mount.tag! 'genre', genre if genre
mount.tag! 'bitrate', bitrate if bitrate
mount.tag! 'type', mime_type
mount.tag! 'subtype', subtype
mount.tag! 'burst-size', burst_size if burst_size
mount.tag! 'mp3-metadata-interval', mp3_metadata_interval if mp3_metadata_interval
mount.tag! 'hidden', hidden ? '1' : '0'
mount.tag! 'on-connect', on_connect if on_connect
mount.tag! 'on-disconnect', on_disconnect if on_disconnect
"intro" => self.intro,
"fallback_mount" => self.fallback_mount,
"fallback_override" => self.fallback_override,
"fallback_when_full" => self.fallback_when_full,
"charset" => self.charset,
"public" => self.publicc,
"stream_name" => self.stream_name,
"stream_description" => self.stream_description,
"stream_url" => self.stream_url,
"genre" => self.genre,
"bitrate" => self.bitrate,
"type" => self.mtype,
"subtype" => self.subtype,
"hidden" => self.hidden,
"burst_size" => self.burst_size,
"mp3_metadata_interval" => self.mp3_metadata_interval,
"on_connect" => self.on_connect,
"on_disconnect" => self.on_disconnect
]
self.jdumpXml(hash, "mount", ident, output, self.authentication)
end
def getMediaUrl
if !self.servermount.nil?
@server = self.servermount.server
@misc = @server.misc
url = "http://" + @misc.hostname + self.mount_name
return url;
else
raise ("Undefined severid")
authentication.dumpXml(builder) if authentication
end
end
def get_media_url
raise "Unassociated server to mount" if self.server_mount.nil?
"http://" + server_mount.server.hostname + self.mount_name
end
end
end

View File

@ -1,25 +1,26 @@
module JamRuby
class IcecastPath < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :basedir, :logdir, :pidfile, :webroot, :adminroot, :allow_ip, :deny_ip, :aliass
has_many :servers, :class_name => "JamRuby::IcecastServer", :inverse_of => :path, :foreign_key => "path_id"
def dumpXml (ident=1, output=$stdout)
validates :base_dir, presence: true
validates :log_dir, presence: true
validates :pid_file, presence: true
validates :web_root, presence: true
validates :admin_root, presence: true
a = "alias #{self.aliass}"
hash = Hash["basedir" => self.basedir,
"logdir" => self.logdir,
"pidfile" => self.pidfile,
"webroot" => self.webroot,
"adminroot" => self.adminroot,
def dumpXml (builder)
"allow_ip" => self.allow_ip,
"deny_ip" => self.deny_ip,
"" => a,
]
self.jdumpXml(hash, "paths", ident, output)
builder.tag! 'paths' do |paths|
paths.tag! 'basedir', base_dir
paths.tag! 'logdir', log_dir
paths.tag! 'pidfile', pid_file
paths.tag! 'webroot', web_root
paths.tag! 'adminroot', admin_root
paths.tag! 'allow-ip', allow_ip if allow_ip
paths.tag! 'deny-ip', deny_ip if deny_ip
paths.tag! 'alias', :source => alias_source, :dest => alias_dest if alias_source
end
end
end
end

View File

@ -1,35 +1,25 @@
module JamRuby
class IcecastRelay < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :server, :port, :mount, :local_mount, :username, :password, :relay_shoutcast_metadata, :on_demand
has_and_belongs_to_many :servers, :class_name => "JamRuby::IcecastServer", :join_table => "icecast_server_relays"
validates :port, numericality: {only_integer: true}, length: {in: 1..65000}
validates :port, presence: true, numericality: {only_integer: true}, length: {in: 1..65535}
validates :mount, presence: true
validates :server, presence: true
validates :local_mount, presence: true
validates :username, presence: true
validates :password, presence: true
validates :relay_shoutcast_metadata, :inclusion => {:in => [true, false]}
validates :on_demand, presence: true, :inclusion => {:in => [true, false]}
belongs_to :sserver, :class_name => "JamRuby::IcecastServerrelay"
def dumpXml (ident=1, output=$stdout)
hash = Hash["server" => self.server,
"port" => self.port,
"mount" => self.mount,
"local_mount" => self.local_mount,
"username" => self.username,
"password" => self.password,
"relay_shoutcast_metadata" => self.relay_shoutcast_metadata,
"on_demand" => self.on_demand
]
self.jdumpXml(hash, "relay", ident, output)
def dumpXml (builder)
builder.tag! 'relay' do |listen|
listen.tag! 'server', server
listen.tag! 'port', port
listen.tag! 'mount', mount
listen.tag! 'local-mount', local_mount if local_mount
listen.tag! 'username', username if username
listen.tag! 'password', password if password
listen.tag! 'relay-shoutcast-metadata', relay_shoutcast_metadata ? 1 : 0
listen.tag! 'on-demand', on_demand ? 1 : 0
end
end
end
end

View File

@ -0,0 +1,20 @@
module JamRuby
class IcecastSecurity < ActiveRecord::Base
has_many :servers, :class_name => "JamRuby::IcecastServer", :inverse_of => :security, :foreign_key => "security_id"
validates :chroot, :inclusion => {:in => [true, false]}
def dumpXml(builder)
builder.tag! 'security' do |security|
security.tag! 'chroot', chroot ? '1' : '0'
if change_owner_user
security.tag! 'changeowner' do
security.tag! 'user', change_owner_user
security.tag! 'group', change_owner_group
end
end
end
end
end
end

View File

@ -1,41 +0,0 @@
module JamRuby
class IcecastSecurity < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :chroot, :changeowner_user, :changeowner_group
validates :chroot, numericality: {only_integer: true}, length: {in: 0..1}
def dumpXml (ident=1, output=$stdout)
tb = "\t"
tbs = tb * (ident)
tbs2 = tb * (ident+1)
tbse = tb * (ident-1)
if tbse.empty? || tbse.nil?
tbse=""
end
nm = "security"
output.puts "#{tbse}<#{nm}>"
output.puts "#{tbs}<chroot>#{self.chroot}</chroot>"
output.puts "#{tbs}<changeowner>"
v = jMakeStrXmlSafe(self.changeowner_user)
output.puts "#{tbs2}<user>#{v}</user>"
v = jMakeStrXmlSafe(self.changeowner_group)
output.puts "#{tbs2}<group>#{v}</group>"
output.puts "#{tbs}<changeowner>"
output.puts "#{tbse}</#{nm}>"
end
end
end

View File

@ -1,77 +1,63 @@
module JamRuby
class IcecastServer < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
has_one :limit, :class_name => "JamRuby::IcecastLimit" , foreign_key: "id"
has_one :adminauth, :class_name => "JamRuby::IcecastAdminAuthentication" , foreign_key: "id"
has_one :directory, :class_name => "JamRuby::IcecastDirectory" , foreign_key: "id"
has_one :misc, :class_name => "JamRuby::IcecastServermisc" , foreign_key: "id"
belongs_to :limit, :class_name => "JamRuby::IcecastLimit", foreign_key: 'limit_id', :inverse_of => :servers
belongs_to :admin_auth, :class_name => "JamRuby::IcecastAdminAuthentication", foreign_key: 'admin_auth_id', :inverse_of => :servers
belongs_to :directory, :class_name => "JamRuby::IcecastDirectory", foreign_key: 'directory_id', :inverse_of => :servers
belongs_to :master_relay, :class_name => "JamRuby::IcecastMasterServerRelay", foreign_key: 'master_relay_id', :inverse_of => :servers
belongs_to :path, :class_name => "JamRuby::IcecastPath", foreign_key: 'path_id', :inverse_of => :servers
belongs_to :logging, :class_name => "JamRuby::IcecastLogging", foreign_key: 'logging_id', :inverse_of => :servers
belongs_to :security, :class_name => "JamRuby::IcecastSecurity", foreign_key: 'security_id', :inverse_of => :servers
has_one :master_relay, :class_name => "JamRuby::IcecastMastersvrRelay" , foreign_key: "id"
has_and_belongs_to_many :mounts, :class_name => "JamRuby::IcecastMount", :join_table => "icecast_server_mounts"
has_and_belongs_to_many :listen_sockets, :class_name => "JamRuby::IcecastListenSocket", :join_table => "icecast_server_sockets"
has_and_belongs_to_many :relays, :class_name => "JamRuby::IcecastRelay", :join_table => "icecast_server_relays"
has_many :smounts, :class_name => "JamRuby::IcecastServermount"
has_many :mounts, :class_name => "JamRuby::IcecastMount", :through => :smounts
validates :config_changed, :inclusion => {:in => [true, false]}
validates :hostname, presence: true
validates :location, presence: true
validates :admin_email, presence: true
validates :fileserve, :inclusion => {:in => [true, false]}
validates :server_id, presence: true
has_many :ssockets, :class_name => "JamRuby::IcecastServersocket"
has_many :sockets, :class_name => "JamRuby::IcecastListenSocket" ,:through => :ssockets
validates :limit, presence: true
validates :admin_auth, presence: true
validates :path, presence: true
validates :logging, presence: true
validates :security, presence: true
validates :listen_sockets, length: {minimum: 1}
has_many :srelays, :class_name => "JamRuby::IcecastServerrelay" , :inverse_of => :server
has_many :relays, :class_name => "JamRuby::IcecastRelay" , :through => :srelays
def dumpXml (output=$stdout, indent=1)
builder = ::Builder::XmlMarkup.new(:target => output, :indent => indent)
has_one :path, :class_name => "JamRuby::IcecastPath" , foreign_key: "id"
has_one :logging, :class_name => "JamRuby::IcecastLogging" , foreign_key: "id"
has_one :security, :class_name => "JamRuby::IcecastSecurity" , foreign_key: "id"
builder.tag! 'icecast' do |icecast|
icecast.tag! 'hostname', hostname
icecast.tag! 'location', location
icecast.tag! 'admin', admin_email
icecast.tag! 'fileserve', fileserve ? 1 : 0
icecast.tag! 'server-id', server_id
def dumpXml (ident=1, output=$stdout)
ident += 1
unless self.limit.nil?
self.limit.dumpXml(ident,output)
limit.dumpXml(builder) unless limit.nil?
admin_auth.dumpXml(builder) unless admin_auth.nil?
directory.dumpXml(builder) unless directory.nil?
master_relay.dumpXml(builder) unless master_relay.nil?
path.dumpXml(builder) unless path.nil?
logging.dumpXml(builder) unless logging.nil?
security.dumpXml(builder) unless security.nil?
relays.each do |relay|
relay.dumpXml(builder)
end
listen_sockets.each do |listen_socket|
listen_socket.dumpXml(builder)
end
mounts.each do |mount|
mount.dumpXml(builder)
end
end
unless self.adminauth.nil?
self.adminauth.dumpXml(ident,output)
end
unless self.directory.nil?
self.directory.dumpXml(ident,output)
end
unless self.misc.nil?
self.misc.dumpXml(ident,output)
end
unless self.master_relay.nil?
self.master_relay.dumpXml(ident,output)
end
unless self.path.nil?
self.path.dumpXml(ident,output)
end
unless self.logging.nil?
self.logging.dumpXml(ident,output)
end
unless self.security.nil?
self.security.dumpXml(ident,output)
end
self.relays.each do |rl|
sock.rl(ident,output)
end
self.sockets.each do |sock|
sock.dumpXml(ident,output)
end
self.mounts.each do |mount|
mount.dumpXml(ident,output)
end
end
end
end

View File

@ -1,14 +1,12 @@
module JamRuby
class IcecastServermount < ActiveRecord::Base
class IcecastServerMount < ActiveRecord::Base
self.primary_key = 'id'
belongs_to :mount, :class_name => "JamRuby::IcecastMount" , :inverse_of => :servermount
belongs_to :mount, :class_name => "JamRuby::IcecastMount" , :inverse_of => :server_mount
belongs_to :server, :class_name => "JamRuby::IcecastServer"
validates :server_id, :presence => true
validates :mount_id, :presence => true
validates :mount_id, :presence => true
end
end

View File

@ -1,5 +1,5 @@
module JamRuby
class IcecastServerrelay < ActiveRecord::Base
class IcecastServerRelay < ActiveRecord::Base
self.primary_key = 'id'

View File

@ -1,14 +1,13 @@
module JamRuby
class IcecastServersocket < ActiveRecord::Base
class IcecastServerSocket < ActiveRecord::Base
self.primary_key = 'id'
belongs_to :socket, :class_name => "JamRuby::IcecastListenSocket" , foreign_key: "id"
belongs_to :server, :class_name => "JamRuby::IcecastServer" , foreign_key: "id"
belongs_to :socket, :class_name => "JamRuby::IcecastListenSocket"
belongs_to :server, :class_name => "JamRuby::IcecastServer"
validates :socket_id, :presence => true
validates :server_id, :presence => true
end
end

View File

@ -1,14 +1,6 @@
module JamRuby
class IcecastServermisc < ActiveRecord::Base
include JAmXml
class IcecastServerMisc < ActiveRecord::Base
self.primary_key = 'id'
attr_accessible :hostname, :location, :admin, :fileserve, :server_id
def dumpXml (ident=0, output=$stdout)
end
end
end

View File

@ -1,77 +1,41 @@
module JamRuby
class IcecastUserAuthentication < ActiveRecord::Base
include JAmXml
self.primary_key = 'id'
attr_accessible :stype, :filename, :allow_duplicate_users, :mount_add, :mount_remove,
:listener_add, :listener_remove, :username, :password, :auth_header, :timelimit_header
has_one :mount, class_name: 'JamRuby::IcecastMount', inverse_of: :authentication
validates :authentication_type, presence: true, :inclusion => {:in => ["url", "htpasswd"]}
validates :allow_duplicate_users, :inclusion => {:in => [true, false]}, if: :htpasswd_auth?
validates :username, length: {minimum: 5}, if: :url_auth?
validates :password, length: {minimum: 5}, if: :url_auth?
validates :mount_add, presence: true, if: :url_auth?
validates :mount_remove, presence: true, if: :url_auth?
validates :listener_add, presence: true, if: :url_auth?
validates :listener_remove, presence: true, if: :url_auth?
validates :auth_header, presence: true, if: :url_auth?
validates :timelimit_header, presence: true, if: :url_auth?
validates :stype, presence: true
def dumpXml (ident=1, output=$stdout)
tb = "\t"
tbs = tb * (ident)
tbse = tb * (ident-1)
if tbse.empty? || tbse.nil?
tbse=""
def dumpXml (builder)
builder.tag! 'authentication', type: authentication_type do |auth|
auth.tag! 'option', name: 'mount_add', value: mount_add if mount_add
auth.tag! 'option', name: 'mount_remove', value: mount_remove if mount_remove
auth.tag! 'option', name: 'username', value: username if username
auth.tag! 'option', name: 'password', value: password if password
auth.tag! 'option', name: 'listener_add', value: listener_add if listener_add
auth.tag! 'option', name: 'listener_remove', value: listener_remove if listener_remove
auth.tag! 'option', name: 'auth_header', value: auth_header if auth_header
auth.tag! 'option', name: 'timelimit_header', value: timelimit_header if timelimit_header
end
if self.stype.nil?
return
elsif self.stype.empty?
return
elsif self.stype == "htpasswd"
nm = "<authentication type=\"htpasswd\">"
output.puts "#{tbse}#{nm}"
fname = jMakeStrXmlSafe(self.filename)
output.puts "#{tbs}<option name=\"filename\" value=\"#{fname}\"/>"
output.puts "#{tbs}<option name=\"allow_duplicate_users\" value=\"#{self.allow_duplicate_users}\"/>"
nm = "authentication"
output.puts "#{tbse}</#{nm}>"
elsif self.stype == 'url'
nm = "<authentication type=\"url\">"
output.puts "#{tbse}#{nm}"
v = jMakeStrXmlSafe(self.mount_add)
output.puts "#{tbs}<option name=\"mount_add\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.mount_remove)
output.puts "#{tbs}<option name=\"mount_remove\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.listener_add)
output.puts "#{tbs}<option name=\"listener_add\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.listener_remove)
output.puts "#{tbs}<option name=\"listener_remove\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.listener_remove)
output.puts "#{tbs}<option name=\"listener_remove\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.username)
output.puts "#{tbs}<option name=\"username\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.password)
output.puts "#{tbs}<option name=\"password\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.auth_header)
output.puts "#{tbs}<option name=\"auth_header\" value=\"#{v}\"/>"
v = jMakeStrXmlSafe(self.timelimit_header)
output.puts "#{tbs}<option name=\"timelimit_header\" value=\"#{v}\"/>"
nm = "authentication"
output.puts "#{tbse}</#{nm}>"
else
raise 'Unsupported authentication format #{self.stype}'
end
end
def htpasswd_auth?
authentication_type == 'htpasswd'
end
def url_auth?
authentication_type == 'url'
end
end
end

View File

@ -136,8 +136,117 @@ FactoryGirl.define do
end
factory :promo_buzz, :class => JamRuby::PromoBuzz do
text_short Faker::Lorem.sentence
text_short Faker::Lorem.characters(10)
text_long Faker::Lorem.paragraphs(3).join("\n")
end
factory :icecast_limit, :class => JamRuby::IcecastLimit do
clients 5
sources 1
queue_size 102400
client_timeout 30
header_timeout 15
source_timeout 10
burst_size 65536
end
factory :icecast_admin_authentication, :class => JamRuby::IcecastAdminAuthentication do
source_password Faker::Lorem.characters(10)
admin_user Faker::Lorem.characters(10)
admin_password Faker::Lorem.characters(10)
relay_user Faker::Lorem.characters(10)
relay_password Faker::Lorem.characters(10)
end
factory :icecast_directory, :class => JamRuby::IcecastDirectory do
yp_url_timeout 15
yp_url Faker::Lorem.characters(10)
end
factory :icecast_master_server_relay, :class => JamRuby::IcecastMasterServerRelay do
master_server Faker::Lorem.characters(10)
master_server_port 8000
master_update_interval 120
master_username Faker::Lorem.characters(10)
master_password Faker::Lorem.characters(10)
relays_on_demand true
end
factory :icecast_path, :class => JamRuby::IcecastPath do
base_dir Faker::Lorem.characters(10)
log_dir Faker::Lorem.characters(10)
pid_file Faker::Lorem.characters(10)
web_root Faker::Lorem.characters(10)
admin_root Faker::Lorem.characters(10)
end
factory :icecast_logging, :class => JamRuby::IcecastLogging do
access_log Faker::Lorem.characters(10)
error_log Faker::Lorem.characters(10)
log_level 3
log_archive nil
log_size 10000
end
factory :icecast_security, :class => JamRuby::IcecastSecurity do
chroot false
end
factory :icecast_mount, :class => JamRuby::IcecastMount do
mount_name Faker::Lorem.characters(10)
username Faker::Lorem.characters(10)
password Faker::Lorem.characters(10)
max_listeners 100
max_listener_duration 3600
fallback_mount Faker::Lorem.characters(10)
fallback_override true
fallback_when_full true
is_public -1
stream_name Faker::Lorem.characters(10)
stream_description Faker::Lorem.characters(10)
stream_url Faker::Lorem.characters(10)
genre Faker::Lorem.characters(10)
hidden false
end
factory :icecast_listen_socket, :class => JamRuby::IcecastListenSocket do
port 8000
end
factory :icecast_relay, :class => JamRuby::IcecastRelay do
port 8000
mount Faker::Lorem.characters(10)
server Faker::Lorem.characters(10)
on_demand true
end
factory :icecast_user_authentication, :class => JamRuby::IcecastUserAuthentication do
authentication_type 'url'
username Faker::Lorem.characters(10)
password Faker::Lorem.characters(10)
mount_add Faker::Lorem.characters(10)
mount_remove Faker::Lorem.characters(10)
listener_add Faker::Lorem.characters(10)
listener_remove Faker::Lorem.characters(10)
auth_header 'icecast-auth-user: 1'
timelimit_header 'icecast-auth-timelimit:'
end
factory :icecast_server, :class => JamRuby::IcecastServer do
hostname Faker::Lorem.characters(10)
location Faker::Lorem.characters(10)
server_id Faker::Lorem.characters(10)
factory :icecast_server_minimal do
association :limit, :factory => :icecast_limit
association :admin_auth, :factory => :icecast_admin_authentication
association :path, :factory => :icecast_path
association :logging, :factory => :icecast_logging
association :security, :factory => :icecast_security
before(:create) do |server|
server.listen_sockets << FactoryGirl.build(:icecast_listen_socket)
end
end
end
end

View File

@ -3,23 +3,42 @@ require 'spec_helper'
describe IcecastAdminAuthentication do
let(:admin) { IcecastAdminAuthentication.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
before(:all) do
admin.source_password = "GoodJob@</>"
it "save error" do
admin.save.should be_false
admin.errors[:source_password].length.should == 2
admin.errors[:admin_user].length.should == 2
admin.errors[:admin_password].length.should == 2
admin.errors[:relay_user].length.should == 2
admin.errors[:relay_password].length.should == 2
end
it "save" do
admin.save!
#puts "source password #{admin.source_password}"
#puts "id #{admin.id}"
#puts admin.errors
#puts admin.inspect
#puts admin.to_yaml
#puts JSON.pretty_generate admin
#puts admin.dumpXml (1)
#puts admin.errors.inspect
admin.errors.any?.should be_false
admin.source_password = Faker::Lorem.characters(10)
admin.admin_user = Faker::Lorem.characters(10)
admin.admin_password = Faker::Lorem.characters(10)
admin.relay_user = Faker::Lorem.characters(10)
admin.relay_password = Faker::Lorem.characters(10)
admin.save.should be_true
admin.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('authentication source-password').text.should == admin.source_password
xml.css('authentication source-password').length.should == 1
xml.css('authentication admin-user').text.should == admin.admin_user
xml.css('authentication admin-user').length.should == 1
xml.css('authentication relay-user').text.should == admin.relay_user
xml.css('authentication relay-user').length.should == 1
xml.css('authentication relay-password').text.should == admin.relay_password
xml.css('authentication relay-password').length.should == 1
xml.css('authentication admin-password').text.should == admin.admin_password
xml.css('authentication admin-password').length.should == 1
end
end

View File

@ -11,21 +11,32 @@ example output:
=end
describe IcecastDirectory do
let(:idir) { IcecastDirectory.new }
let(:output) { StringIO.new }
let(:dir) { IcecastDirectory.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
before(:each) do
end
it "save error" do
dir.save.should be_false
dir.errors[:yp_url].length.should == 1
dir.errors[:yp_url_timeout].length.should == 0
end
it "save" do
idir.save.should be_true
idir.dumpXml(1, output)
dir.yp_url = Faker::Lorem.characters(10)
dir.yp_url_timeout = 20
dir.save.should be_true
dir.dumpXml(builder)
output.rewind
directory = Nokogiri::XML(output)
directory.css('directory yp-url-timeout').text.should == "15"
directory.css('directory yp-url').text.should == "http://dir.xiph.org/cgi-bin/yp-cgi"
xml = Nokogiri::XML(output)
xml.css('directory yp-url-timeout').text.should == dir.yp_url_timeout.to_s
xml.css('directory yp-url-timeout').length.should == 1
xml.css('directory yp-url').text.should == dir.yp_url
xml.css('directory yp-url').length.should == 1
end
end

View File

@ -3,26 +3,57 @@ require 'spec_helper'
describe IcecastLimit do
let(:limit) { IcecastLimit.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
before(:all) do
it "save defaults" do
limit.save.should be_true
limit.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('limits clients').text.should == "1000"
xml.css('limits clients').length.should == 1
xml.css('limits sources').text.should == "50"
xml.css('limits sources').length.should == 1
xml.css('limits queue-size').text.should == "102400"
xml.css('limits queue-size').length.should == 1
xml.css('limits client-timeout').text.should == "30"
xml.css('limits client-timeout').length.should == 1
xml.css('limits header-timeout').text.should == "15"
xml.css('limits header-timeout').length.should == 1
xml.css('limits source-timeout').text.should == "10"
xml.css('limits source-timeout').length.should == 1
xml.css('limits burst-on-connect').text.should == "1"
xml.css('limits burst-on-connect').length.should == 1
xml.css('limits burst-size').text.should == "65536"
xml.css('limits burst-size').length.should == 1
end
it "save" do
limit.clients = 9999
limit.save
#limit.dumpXml
limit.errors.any?.should be_false
v = IcecastLimit.find(limit.id)
it "save specified" do
limit.clients = 10000
limit.sources = 2000
limit.queue_size = 1000
limit.client_timeout = 10
limit.header_timeout = 20
limit.source_timeout = 30
limit.burst_size = 1000
limit.save.should be_true
limit.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('limits clients').text.should == limit.clients.to_s
xml.css('limits sources').text.should == limit.sources.to_s
xml.css('limits queue-size').text.should == limit.queue_size.to_s
xml.css('limits client-timeout').text.should == limit.client_timeout.to_s
xml.css('limits header-timeout').text.should == limit.header_timeout.to_s
xml.css('limits source-timeout').text.should == limit.source_timeout.to_s
xml.css('limits burst-on-connect').text.should == "1"
xml.css('limits burst-size').text.should == limit.burst_size.to_s
end
it "non-integer clients should be checked" do
limit.clients = 'a'
#puts limit.clients
#puts limit.inspect
limit.save.should be_false
limit.errors[:clients].should === ['is not a number']
end
end

View File

@ -2,21 +2,20 @@ require 'spec_helper'
describe IcecastListenSocket do
let(:iobj) { IcecastListenSocket.new }
let(:listen) { IcecastListenSocket.new }
let(:output) { StringIO.new }
before(:all) do
end
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
it "save" do
iobj.save.should be_true
iobj.dumpXml(1, output)
listen.save!
listen.dumpXml(builder)
output.rewind
directory = Nokogiri::XML(output)
directory.css('listen-socket port').text.should == "8001"
directory.css('listen-socket shoutcast-compat').text.should == "0"
xml = Nokogiri::XML(output)
xml.css('listen-socket port').text.should == "8001"
xml.css('listen-socket shoutcast-compat').length.should == 0
xml.css('listen-socket shoutcast-mount').length.should == 0
xml.css('listen-socket bind-address').length.should == 0
end
end

View File

@ -2,20 +2,33 @@ require 'spec_helper'
describe IcecastLogging do
let(:iobj) { IcecastLogging.new }
let(:logging) { IcecastLogging.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
it "save works by default db values" do
logging.save.should be_true
logging.access_log.should == 'access.log'
logging.error_log.should == 'error.log'
end
it "save" do
iobj.save.should be_true
iobj.dumpXml(1, output)
logging.access_log = Faker::Lorem.characters(10)
logging.error_log = Faker::Lorem.characters(10)
logging.log_level = 4
logging.log_size = 20000
logging.save!
logging.dumpXml(builder)
output.rewind
directory = Nokogiri::XML(output)
directory.css('logging accesslog').text.should == "access.log"
directory.css('logging errorlog').text.should == "error.log"
directory.css('logging loglevel').text.should == "4"
directory.css('logging playlistlog').text.should == "playlist.log"
xml = Nokogiri::XML(output)
xml.css('logging accesslog').text.should == logging.access_log
xml.css('logging errorlog').text.should == logging.error_log
xml.css('logging loglevel').text.should == logging.log_level.to_s
xml.css('logging logsize').text.should == logging.log_size.to_s
xml.css('logging playlistlog').length.should == 0
xml.css('logging logarchive').length.should == 0
end
end

View File

@ -0,0 +1,38 @@
require 'spec_helper'
describe IcecastMasterServerRelay do
let(:relay) { IcecastMasterServerRelay.new }
let(:output){ StringIO.new }
let(:root) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
it "should not save" do
relay.save.should be_false
relay.errors[:master_password].should == ["can't be blank", "is too short (minimum is 5 characters)"]
relay.errors[:master_username].should == ["can't be blank", "is too short (minimum is 5 characters)"]
relay.errors[:master_server].should == ["can't be blank", "is too short (minimum is 1 characters)"]
end
it "should save" do
relay.master_server = "test.www.com"
relay.master_server_port = 7111
relay.master_username = "hackme-user"
relay.master_password = "hackme-password"
relay.save.should be_true
root.tag! 'root' do |builder|
relay.dumpXml(builder)
end
output.rewind
xml = Nokogiri::XML(output)
xml.css('root master-server').text.should == relay.master_server.to_s
xml.css('root master-server-port').text.should == relay.master_server_port.to_s
xml.css('root master-update-interval').text.should == relay.master_update_interval.to_s
xml.css('root master-username').text.should == relay.master_username.to_s
xml.css('root master-password').text.should == relay.master_password.to_s
xml.css('root relays-on-demand').text.should == (relay.relays_on_demand ? '1' : '0')
end
end

View File

@ -1,29 +0,0 @@
require 'spec_helper'
describe IcecastMastersvrRelay do
let(:iobj) { IcecastMastersvrRelay.new }
before(:all) do
end
it "should not save" do
iobj.save.should be_false
#puts iobj.errors.inspect
iobj.errors[:master_password].should === ["can't be blank"]
end
it "should save" do
iobj.master_server = "test.www.com"
iobj.master_server_port = 7111
iobj.master_username = "hack"
iobj.master_password = "hackme"
iobj.save.should be_true
#iobj.dumpXml
end
end

View File

@ -2,43 +2,71 @@ require 'spec_helper'
describe IcecastMount do
let(:iobj) { IcecastMount.new }
before(:all) do
let(:mount) { IcecastMount.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
it "save error" do
mount.save.should be_false
mount.errors[:mount_name].should == ["can't be blank"]
mount.errors[:stream_name].should == ["can't be blank"]
mount.errors[:stream_description].should == ["can't be blank"]
mount.errors[:stream_url].should == ["can't be blank"]
mount.errors[:genre].should == ["can't be blank"]
end
=begin
it "save" do
iobj.build_authentication
@ua = iobj.authentication
@ua.username ="testcase"
iobj.mount_name = "Dhdhjd<>&%&&s@#$% gg8io9 fdfdj"
iobj.save
#puts iobj.inspect
iobj.dumpXml
iobj.errors.any?.should be_false
mount.mount_name = Faker::Lorem.characters(10)
mount.stream_name = Faker::Lorem.characters(10)
mount.stream_description = Faker::Lorem.characters(10)
mount.stream_url = Faker::Lorem.characters(10)
mount.genre = Faker::Lorem.characters(10)
mount.username = Faker::Lorem.characters(10)
mount.password = Faker::Lorem.characters(10)
mount.intro = Faker::Lorem.characters(10)
mount.fallback_mount = Faker::Lorem.characters(10)
mount.on_connect = Faker::Lorem.characters(10)
mount.on_disconnect = Faker::Lorem.characters(10)
mount.fallback_override = true
mount.fallback_when_full = true
mount.max_listeners = 1000
mount.max_listener_duration = 3600
mount.authentication = FactoryGirl.create(:icecast_user_authentication)
mount.save!
mount.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('mount mount-name').text.should == mount.mount_name
xml.css('mount username').text.should == mount.username
xml.css('mount password').text.should == mount.password
xml.css('mount max-listeners').text.should == mount.max_listeners.to_s
xml.css('mount max-listener-duration').text.should == mount.max_listener_duration.to_s
xml.css('mount intro').text.should == mount.intro
xml.css('mount fallback-mount').text.should == mount.fallback_mount
xml.css('mount fallback-override').text.should == (mount.fallback_override ? '1' : '0')
xml.css('mount fallback-when-full').text.should == (mount.fallback_when_full ? '1' : '0')
xml.css('mount stream-name').text.should == mount.stream_name
xml.css('mount stream-description').text.should == mount.stream_description
xml.css('mount stream-url').text.should == mount.stream_url
xml.css('mount genre').text.should == mount.genre
xml.css('mount bitrate').length.should == 0
xml.css('mount charset').text == mount.charset
xml.css('mount public').text == mount.is_public.to_s
xml.css('mount type').text == mount.mime_type
xml.css('mount subtype').text == mount.subtype
xml.css('mount burst-size').length.should == 0
xml.css('mount mp3-metadata-interval').length.should == 0
xml.css('mount hidden').text.should == (mount.hidden ? '1' : '0')
xml.css('mount on-connect').text.should == mount.on_connect
xml.css('mount on-disconnect').text.should == mount.on_disconnect
xml.css('mount dump-file').length.should == 0
xml.css('mount authentication').length.should == 1 # no reason to test futher; it's tested in that model
end
it "save 2" do
iobj.build_authentication
@ua = iobj.authentication
@ua.stype =""
iobj.mount_name = "No auth 473873434"
iobj.save
#puts iobj.inspect
#puts iobj.errors.inspect
iobj.dumpXml
iobj.errors.any?.should be_false
end
=end
end

View File

@ -2,25 +2,56 @@ require 'spec_helper'
describe IcecastPath do
let(:iobj) { IcecastPath.new }
let(:path) { IcecastPath.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
it "save" do
iobj.save.should be_true
iobj.dumpXml(1, output)
it "save default" do
path.save.should be_true
path.dumpXml(builder)
output.rewind
directory = Nokogiri::XML(output)
directory.css('paths basedir').text.should == "./"
directory.css('paths logdir').text.should == "./logs"
directory.css('paths pidfile').text.should == "./icecast.pid"
directory.css('paths webroot').text.should == "./web"
directory.css('paths adminroot').text.should == "./admin"
directory.css('paths allow-ip').text.should == "/path/to/ip_allowlist"
directory.css('paths deny-ip').text.should == "/path_to_ip_denylist"
directory.css('paths alias').text.should == ""
#puts directory.css('paths alias').first["source"]
xml = Nokogiri::XML(output)
xml.css('paths basedir').text.should == "./"
xml.css('paths basedir').length.should == 1
xml.css('paths logdir').text.should == "./logs"
xml.css('paths logdir').length.should == 1
xml.css('paths pidfile').text.should == "./icecast.pid"
xml.css('paths pidfile').length.should == 1
xml.css('paths webroot').text.should == "./web"
xml.css('paths webroot').length.should == 1
xml.css('paths adminroot').text.should == "./admin"
xml.css('paths adminroot').length.should == 1
xml.css('paths allow-ip').length.should == 0
xml.css('paths deny-ip').length.should == 0
xml.css('paths alias').length.should == 0
end
it "save set values" do
path.base_dir = Faker::Lorem.characters(10)
path.log_dir = Faker::Lorem.characters(10)
path.pid_file = Faker::Lorem.characters(10)
path.web_root = Faker::Lorem.characters(10)
path.admin_root = Faker::Lorem.characters(10)
path.allow_ip = Faker::Lorem.characters(10)
path.deny_ip = Faker::Lorem.characters(10)
path.alias_source = Faker::Lorem.characters(10)
path.alias_dest = Faker::Lorem.characters(10)
path.save.should be_true
path.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('paths basedir').text.should == path.base_dir
xml.css('paths logdir').text.should == path.log_dir
xml.css('paths pidfile').text.should == path.pid_file
xml.css('paths webroot').text.should == path.web_root
xml.css('paths adminroot').text.should == path.admin_root
xml.css('paths allow-ip').text.should == path.allow_ip
xml.css('paths deny-ip').text.should == path.deny_ip
xml.css('paths alias').first['source'] == path.alias_source
xml.css('paths alias').first['dest'] == path.alias_dest
end
end

View File

@ -2,21 +2,35 @@ require 'spec_helper'
describe IcecastRelay do
let(:iobj) { IcecastRelay.new }
let(:relay) { IcecastRelay.new }
let(:output){ StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
before(:all) do
it "should not save" do
relay.save.should be_false
relay.errors[:mount].should == ["can't be blank"]
relay.errors[:server].should == ["can't be blank"]
end
=begin
it "save" do
iobj.server ="10.7.0.99"
iobj.mount ="/lcrock.ogg"
iobj.save.should be_true
iobj.dumpXml
end
=end
relay.mount = Faker::Lorem.characters(10)
relay.server = Faker::Lorem.characters(10)
relay.relay_shoutcast_metadata = false
relay.save!
relay.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('relay port').text.should == relay.port.to_s
xml.css('relay mount').text.should == relay.mount
xml.css('relay server').text.should == relay.server
xml.css('relay local-mount').length.should == 0
xml.css('relay username').length.should == 0
xml.css('relay password').length.should == 0
xml.css('relay relay-shoutcast-metadata').text.should == "0"
xml.css('relay on-demand').text.should == "1"
end
end

View File

@ -2,28 +2,32 @@ require 'spec_helper'
describe IcecastSecurity do
let(:iobj) { IcecastSecurity.new }
let(:security) { IcecastSecurity.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
=begin
example output:
it "save with chroot" do
security.change_owner_user ="hotdog"
security.change_owner_group ="mongrel"
security.chroot = true
security.save!
security.dumpXml(builder)
<security>
<chroot>0</chroot>
<changeowner>
<user>hotdog</user>
<group>mongrel</group>
<changeowner>
</security>
=end
it "save" do
iobj.changeowner_user ="hotdog"
iobj.changeowner_group ="mongrel"
iobj.save.should be_true
iobj.dumpXml(1, output)
output.rewind
xml = Nokogiri::XML(output)
xml.css('security chroot').text.should == '1'
xml.css('security changeowner user').text.should == 'hotdog'
xml.css('security changeowner group').text.should == 'mongrel'
end
it "save without chroot" do
security.save!
security.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('security chroot').text.should == '0'
xml.css('security changeowner').length.should == 0
end
end

View File

@ -2,67 +2,31 @@ require 'spec_helper'
describe IcecastServer do
let(:iobj) { IcecastServer.new }
let(:server) { IcecastServer.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
before(:all) do
it "save" do
server = FactoryGirl.create(:icecast_server_minimal)
server.save!
server.reload
server.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('icecast hostname').text.should == server.hostname
xml.css('icecast location').text.should == server.location
xml.css('icecast admin').text.should == server.admin_email
xml.css('icecast fileserve').text.should == (server.fileserve ? '1' : '0')
xml.css('icecast server-id').text.should == server.server_id
xml.css('icecast limits').length.should == 1
xml.css('icecast authentication').length.should == 1
xml.css('icecast directory').length.should == 0
xml.css('icecast master-server').length.should == 0
xml.css('icecast paths').length.should == 1
xml.css('icecast logging').length.should == 1
xml.css('icecast security').length.should == 1
xml.css('icecast listen-socket').length.should == 1
end
=begin
it "save master" do
iobj.build_limit
iobj.build_adminauth
iobj.build_directory
iobj.build_logging
iobj.build_path
iobj.build_master_relay
iobj.build_misc
m1 = IcecastMount.new
m1.mount_name = "/m1hottstuff.og"
m2 = IcecastMount.new
m1.mount_name = "/m2.ogg"
sm = IcecastServermount.new
sm.build_mount= iobj,m1
sm.build_mount= iobj,m2
# iobj.mounts=m1,m2
iobj.save
puts iobj.errors.inspect
iobj.dumpXml
iobj.errors.any?.should be_false
end
it "save relay" do
iobj.build_limit
iobj.build_adminauth
iobj.build_directory
iobj.build_path
iobj.build_relay
iobj.build_misc
iobj.build_logging
iobj.build_security
m1 = IcecastMount.new
m1.mount_name = "/relaymout.ogg"
m2 = IcecastMount.new
m1.mount_name = "/local.ogg"
iobj.mounts=m1,m2
iobj.save
#puts iobj.inspect
iobj.dumpXml
iobj.errors.any?.should be_false
end
=end
end

View File

@ -2,31 +2,46 @@ require 'spec_helper'
describe IcecastUserAuthentication do
let(:iobj) { IcecastUserAuthentication.new }
let(:auth) { IcecastUserAuthentication.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
before(:all) do
it "save error" do
auth.save.should be_false
auth.errors[:mount_add].should == ["can't be blank"]
auth.errors[:mount_remove].should == ["can't be blank"]
auth.errors[:listener_add].should == ["can't be blank"]
auth.errors[:listener_remove].should == ["can't be blank"]
auth.errors[:username].should == ["is too short (minimum is 5 characters)"]
auth.errors[:password].should == ["is too short (minimum is 5 characters)"]
end
it "save" do
iobj.save
#puts iobj.inspect
iobj.dumpXml(1, output)
iobj.errors.any?.should be_false
auth.mount_add = Faker::Lorem.characters(10)
auth.mount_remove = Faker::Lorem.characters(10)
auth.listener_add = Faker::Lorem.characters(10)
auth.listener_remove = Faker::Lorem.characters(10)
auth.username = Faker::Lorem.characters(10)
auth.password = Faker::Lorem.characters(10)
auth.save!
auth.dumpXml(builder)
output.rewind
xml = Nokogiri::XML(output)
xml.css('authentication')[0]["type"].should == auth.authentication_type
xml.css('authentication option[name="mount_add"]')[0]["value"].should == auth.mount_add
xml.css('authentication option[name="mount_remove"]')[0]["value"].should == auth.mount_remove
xml.css('authentication option[name="listener_add"]')[0]["value"].should == auth.listener_add
xml.css('authentication option[name="listener_remove"]')[0]["value"].should == auth.listener_remove
xml.css('authentication option[name="username"]')[0]["value"].should == auth.username
xml.css('authentication option[name="auth_header"]')[0]["value"].should == auth.auth_header
xml.css('authentication option[name="timelimit_header"]')[0]["value"].should == auth.timelimit_header
end
it "http autthenication" do
iobj.stype = 'htpasswd'
#puts limit.clients
#puts limit.inspect
iobj.filename ="/dfdfd</$%%%6566.auth"
iobj.save.should be_true
iobj.dumpXml(1, output)
end
end