Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Seth Call 2014-01-07 23:30:55 +00:00
commit f0dcf419b5
36 changed files with 524 additions and 15 deletions

View File

@ -81,6 +81,7 @@ notification_band_invite.sql
band_photo_filepicker.sql
bands_geocoding.sql
store_s3_filenames.sql
icecast.sql
discardable_recorded_tracks.sql
music_sessions_have_claimed_recording.sql
discardable_recorded_tracks2.sql

305
db/up/icecast.sql Normal file
View File

@ -0,0 +1,305 @@
-- see http://www.icecast.org/docs/icecast-2.3.3/icecast2_config_file.html#limits
CREATE TABLE icecast_limits (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- number of listening clients
clients INTEGER NOT NULL DEFAULT 1000,
--number of sources include souce clients and relays
sources INTEGER NOT NULL DEFAULT 50,
-- maximum size (in bytes) of the stream queue
queue_size INTEGER NOT NULL DEFAULT 102400,
-- does not appear to be used
client_timeout INTEGER DEFAULT 10,
-- The maximum time (in seconds) to wait for a request to come in once
-- the client has made a connection to the server.
-- In general this value should not need to be tweaked.
header_timeout INTEGER DEFAULT 15,
-- If a connected source does not send any data within this
-- timeout period (in seconds), then the source connection
-- will be removed from the server.
source_timeout INTEGER DEFAULT 10,
-- The burst size is the amount of data (in bytes)
-- to burst to a client at connection time.
burst_size INTEGER DEFAULT 65536,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
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
-- can be changed in the individual mount sections.
source_password character NOT NULL DEFAULT 'icejam321',
-- 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 character NOT NULL DEFAULT 'relay',
relay_password character NOT NULL DEFAULT 'jkrelayhack',
--The username/password used for all administration functions.
admin_user character NOT NULL DEFAULT 'jkadmin',
admin_password character NOT NULL DEFAULT 'jKadmin123',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
--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_directorys (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
yp_url_timeout integer not null default 15,
yp_url character not null UNIQUE default 'http://dir.xiph.org/cgi-bin/yp-cgi',
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 character 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 character not null default 'earth',
--This should contain contact details for getting in touch with the server administrator.
admin character 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 character 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 (
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,
-- 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 character,
shoutcast_mount character default NULL,
shoutcast_compat INTEGER not null default 0,
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 character 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 character not null default 'relay',
master_password character 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 (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- ip address of server we are relaying from and port number
server character not null,
port integer not null default 8001,
-- mount at server. eg /example.ogg
mount character not null,
-- eg /different.ogg
local_mount character not null,
-- eg joe. could be null
username character default NULL ,
-- user password
password character default null ,
relay_shoutcast_metadata INTEGER default 0,
--- relay only if we have someone wanting to listen
on_demand INTEGER default 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create TABLE icecast_user_authentications(
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
--"htpasswd or url"
type CHARACTER DEFAULT NULL ,
-- these are for httpasswd
filename CHARACTER default NULL,
allow_duplicate_users INTEGER DEFAULT 0,
-- these options are for url
-- eg value="http://myauthserver.com/stream_start.php"
mount_add CHARACTER default NULL,
--value="http://myauthserver.com/stream_end.php"
mount_remove CHARACTER default NULL,
--value="http://myauthserver.com/listener_joined.php"
listener_add CHARACTER default NULL,
--value="http://myauthserver.com/listener_left.php"
listener_remove CHARACTER default NULL,
-- value="user"
username CHARACTER default NULL,
-- value="pass"
password CHARACTER default NULL,
-- value="icecast-auth-user: 1"
auth_header CHARACTER default NULL,
-- value="icecast-auth-timelimit:"
timelimit_header CHARACTER default NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_mounts (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
-- eg/example-complex.ogg
mount_name CHARACTER UNIQUE NOT NULL,
username CHARACTER NOT NULL DEFAULT 'jamsource',
password CHARACTER NOT NULL DEFAULT 'jamksource',
max_listeners INTEGER NOT NULL DEFAULT 4,
max_listener_duration INTEGER NOT NULL DEFAULT 3600,
-- dump of the stream coming through on this mountpoint.
-- eg /tmp/dump-example1.ogg
dump_file CHARACTER DEFAULT NULL,
-- 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 CHARACTER NOT NULL DEFAULT '/intro.ogg',
fallback_mount CHARACTER NOT NULL DEFAULT '/sourcedown.ogg',
-- 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,
-- 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,
--For non-Ogg streams like MP3, the metadata that is inserted into the stream often
-- has no defined character set.
charset CHARACTER NOT NULL DEFAULT 'ISO8859-1',
-- possilble values are -1, 0, 1
public INTEGER DEFAULT 1,
stream_name VARCHAR NOT NULL DEFAULT 'My Jamkazam Audio Stream',
stream_description VARCHAR NOT NULL DEFAULT 'My JK audio description',
-- direct to user page
stream_url CHARACTER NOT NULL DEFAULT 'http://wwww.jamakazam.com#user_id',
-- get this from the session info
genre VARCHAR NOT NULL DEFAULT 'Unknown',
bitrate integer NOT NULL default 92,
type CHARACTER NOT NULL DEFAULT 'application/ogg' ,
subtype CHARACTER NOT NULL DEFAULT 'vorbis',
-- 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,
--called when the source connects or disconnects. The scripts are called with the name of the mount
on_connect CHARACTER DEFAULT '/home/icecast/bin/source-start',
on_disconnect CHARACTER DEFAULT '/home/icecast/bin/source-end',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
auth_id VARCHAR(64) NOT NULL REFERENCES icecast_user_authentications(id)
);
create table icecast_paths (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
basedir CHARACTER NOT NULL DEFAULT './',
logdir CHARACTER NOT NULL DEFAULT './logs',
pidfile CHARACTER NOT NULL DEFAULT './icecast.pid',
webroot CHARACTER NOT NULL DEFAULT './web',
adminroot CHARACTER NOT NULL DEFAULT './admin',
allow_ip CHARACTER NOT NULL DEFAULT '/path/to/ip_allowlist',
deny_ip CHARACTER NOT NULL DEFAULT '/path_to_ip_denylist',
alias CHARACTER DEFAULT 'source="/foo" dest="/bar"',
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 CHARACTER NOT NULL DEFAULT 'access.log',
errorlog CHARACTER NOT NULL DEFAULT 'error.log',
playlistlog CHARACTER NOT NULL DEFAULT 'playlist.log',
-- 4 Debug, 3 Info, 2 Warn, 1 Error
loglevel INTEGER NOT NULL DEFAULT 4 ,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
create table icecast_securitys (
id VARCHAR(64) PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),
chroot INTEGER NOT NULL DEFAULT 0,
changeowner_user CHARACTER DEFAULT 'nobody',
changeowner_group CHARACTER DEFAULT 'nogroup',
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(),
icecast_limit_id VARCHAR(64) REFERENCES icecast_limits(id)
-- configs
-- mounts
);

View File

@ -13,6 +13,7 @@ require "sendgrid"
require "postgres-copy"
require "geokit-rails"
require "postgres_ext"
require 'builder'
require "jam_ruby/constants/limits"
require "jam_ruby/constants/notification_types"
@ -83,6 +84,19 @@ require "jam_ruby/models/mix"
require "jam_ruby/models/claimed_recording"
require "jam_ruby/models/crash_dump"
require "jam_ruby/models/isp_score_batch"
require "jam_ruby/models/icecast_admin_authentication"
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_mount"
require "jam_ruby/models/icecast_path"
require "jam_ruby/models/icecast_relay"
require "jam_ruby/models/icecast_sercurity"
require "jam_ruby/models/icecast_server"
require "jam_ruby/models/icecast_servermisc"
require "jam_ruby/models/icecast_user_authentication"
include Jampb

View File

@ -0,0 +1,9 @@
module JamRuby
class IcecastAdminAuthentication < ActiveRecord::Base
self.primary_key = 'id'
validates :source_password, length: {minimum: 5}
end
end

View File

@ -0,0 +1,9 @@
module JamRuby
class IcecastDirectory < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,13 @@
module JamRuby
class IcecastLimit < ActiveRecord::Base
self.primary_key = 'id'
validates :clients, numericality: {only_integer: true}
def dumpXml()
end
end
end

View File

@ -0,0 +1,8 @@
module JamRuby
class IcecastListenSocket < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,9 @@
module JamRuby
class IcecastLogging < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,7 @@
module JamRuby
class IcecastMastersvrRelay < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,9 @@
module JamRuby
class IcecastMount < ActiveRecord::Base
self.primary_key = 'id'
has_one :authentication, :class_name => "IcecastUserAuthentication"
end
end

View File

@ -0,0 +1,9 @@
module JamRuby
class IcecastPath < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,8 @@
module JamRuby
class IcecastRelay < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,9 @@
module JamRuby
class IcecastSecurity < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,18 @@
module JamRuby
class IcecastServer < ActiveRecord::Base
self.primary_key = 'id'
has_one :limit, :class_name => "JamRuby::IcecastLimit"
has_one :adminauth, :class_name => "JamRuby::IcecastAdminAuthentication"
has_one :directory, :class_name => "JamRuby::IcecastDirectory"
has_one :misc, :class_name => "JamRuby::IcecastServermisc"
has_many :listen_sockets, :class_name => "JamRuby::IcecastListenSocket"
has_one :master_relay, :class_name => "JamRuby::IcecastMastersvrRelay"
has_one :relay, :class_name => "JamRuby::IcecastRelay"
has_many :mounts, :class_name => "JamRuby::IcecastMount"
has_one :path, :class_name => "JamRuby::IcecastPath"
has_one :logging, :class_name => "JamRuby::IcecastLogging"
has_one :security, :class_name => "JamRuby::IceCastSecurity"
end
end

View File

@ -0,0 +1,7 @@
module JamRuby
class IcecastServermisc < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,8 @@
module JamRuby
class IcecastUserAuthentication < ActiveRecord::Base
self.primary_key = 'id'
end
end

View File

@ -0,0 +1,20 @@
require 'spec_helper'
describe IcecastAdminAuthentication do
let(:admin) { IcecastAdminAuthentication.new }
before(:all) do
end
it "save" do
admin.save.should be_true
end
it "non-string password should be checked" do
admin.source_password = 1
admin.save.should be_false
admin.errors[:source_password].should == ['is not a string']
end
end

View File

@ -0,0 +1,20 @@
require 'spec_helper'
describe IcecastLimit do
let(:limit) { IcecastLimit.new }
before(:all) do
end
it "save" do
limit.save.should be_true
end
it "non-integer clients should be checked" do
limit.clients = "a"
limit.save.should be_false
limit.errors[:clients].should == ['is not a number']
end
end

View File

@ -78,6 +78,10 @@ Spork.prefork do
DatabaseCleaner.clean
end
config.after(:suite) do
wipe_s3_test_bucket
end
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.

View File

@ -1,8 +1,9 @@
JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' # cuz i'm not comfortable using aws_bucket accessor directly
def app_config
klass = Class.new do
def aws_bucket
'jamkazam-testing'
JAMKAZAM_TESTING_BUCKET
end
def aws_access_key_id
@ -15,4 +16,16 @@ def app_config
end
return klass.new
end
def wipe_s3_test_bucket
test_config = app_config
s3 = AWS::S3.new(:access_key_id => test_config.aws_access_key_id,
:secret_access_key => test_config.aws_secret_access_key)
test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET]
if test_bucket.name == JAMKAZAM_TESTING_BUCKET
puts "Ruby - Pretending to delete all contents of #{test_bucket.name}"
#test_bucket.delete_all
end
end

2
runweb
View File

@ -1,4 +1,4 @@
#!/bin/bash -l
#!/bin/bash
pushd web
# run jam-web rails server

2
update
View File

@ -1,4 +1,4 @@
#!/bin/bash -l
#!/bin/bash
set -e

View File

@ -18,7 +18,7 @@ else
gem 'jam_ruby', "0.1.#{ENV["BUILD_NUMBER"]}"
gem 'jam_websockets', "0.1.#{ENV["BUILD_NUMBER"]}"
end
gem 'builder'
gem 'rails', '>=3.2.11'
gem 'jquery-rails', '2.0.2'
gem 'jquery-ui-rails'

View File

@ -99,31 +99,23 @@ Spork.prefork do
config.include Snapshot
config.before(:suite) do
#set_up_snapshot
end
config.before(:all) do
set_up_snapshot
end
config.before(:each) do
if example.metadata[:js]
page.driver.resize(1920, 1080)
page.driver.headers = { 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' }
end
if example.metadata[:snap]
snapshot_example
end
end
config.before(:each, :js => true) do
end
config.before(:each) do
end
config.append_after(:each) do
Capybara.reset_sessions!
@ -144,7 +136,12 @@ Spork.prefork do
end
config.after(:all) do
tear_down_snapshot
end
config.after(:suite) do
#tear_down_snapshot
wipe_s3_test_bucket
end
end
end

View File

@ -30,6 +30,18 @@ def cookie_jar
end
#see also ruby/spec/support/utilities.rb
JAMKAZAM_TESTING_BUCKET = 'jamkazam-testing' #at least, this is the name given in jam-ruby
def wipe_s3_test_bucket
s3 = AWS::S3.new(:access_key_id => Rails.application.config.aws_access_key_id,
:secret_access_key => Rails.application.config.aws_secret_access_key)
test_bucket = s3.buckets[JAMKAZAM_TESTING_BUCKET]
if test_bucket.name == JAMKAZAM_TESTING_BUCKET
puts "Web - Pretending to delete all contents of #{test_bucket.name}"
#test_bucket.delete_all
end
end
def sign_in(user)
visit signin_path