Browse files

Added happy hour and bug fixes

  • Loading branch information...
1 parent f2e1e29 commit 7c33d861ff643eab137e490d1362c4a4125e9cf7 @jimmykane committed Feb 10, 2012
Showing with 30 additions and 12 deletions.
  1. +6 −3 config.example.yml
  2. +11 −0 lib/siriproxy.rb
  3. +2 −2 lib/siriproxy/command_line.rb
  4. +1 −1 lib/siriproxy/connection.rb
  5. +10 −6 lib/siriproxy/db_classes.rb
View
9 config.example.yml
@@ -11,9 +11,12 @@ db_database: 'siri'
#Programm options
#1. Auto Key Ban -> When a key cannot create more assistants then it is marked as banned,
-# and wont be used for creating assistants in apple db
-# Default = ON , Recommended='ON'
-
+# and wont be used for creating assistants in apple db. This doesnt imply that the key is banned though :-)
+# Just a precation measure
+# Default = ON , Recommended='ON'
+# Also if this is set to on there is a happy_hour_countdown that when is reached sets the keys unbanned again
+# Defalut 6 hours = 21600 sec
+happy_hour_countdown: 21600
enable_auto_key_ban: 'ON'
#For Generating Certs for iPhones. Has 2 hosts, so that you can use guzzoni on a 4S,
View
11 lib/siriproxy.rb
@@ -79,6 +79,16 @@ def initialize()
$statistics=$statisticsDao.getstats()
$statistics.elapsed+=@timer
$statistics.uptime+=@timer
+ $statistics.happy_hour_elapsed+=@timer
+
+ #Happy hour enabler
+ if $statistics.happy_hour_elapsed > $APP_CONFIG.happy_hour_countdown and ($APP_CONFIG.enable_auto_key_ban=='ON' or $APP_CONFIG.enable_auto_key_ban=='on')
+ $keyDao.unban_keys
+ $statistics.happy_hour_elapsed=0
+ puts "[Happy hour - SiriProxy] Unbanning Keys and Doors are open"
+ end
+
+ #KeyLoad DropDown
if $statistics.elapsed>$conf.keyload_dropdown_interval
@overloaded_keys_count=$keyDao.findoverloaded().count
if (@overloaded_keys_count>0)
@@ -92,6 +102,7 @@ def initialize()
end
$statistics.elapsed=0
end
+
$statisticsDao.savestats($statistics)
$conf.active_connections = EM.connection_count
$confDao.update($conf)
View
4 lib/siriproxy/command_line.rb
@@ -177,11 +177,11 @@ def gen_tables
dbh.query("CREATE TABLE `stats` (
`id` int(255) unsigned NOT NULL AUTO_INCREMENT,
`elapsed_key_check_interval` int(255) NOT NULL,
- `up_time` int(255) NOT NULL,
+ `up_time` int(255) NOT NULL,`happy_hour_elapsed` int(255) NOT NULL
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;")
puts "Table Statistics Created"
- dbh.query("INSERT INTO `stats` VALUES ('1', '0', '0');")
+ dbh.query("INSERT INTO `stats` VALUES ('1', '0', '0','0');")
puts "Table Statistics Initialized"
View
2 lib/siriproxy/connection.rb
@@ -517,7 +517,7 @@ def prep_received_object(object)
@client.appleDBid="NA"
end
- if object["properties"]["abSources"][0]["properties"]["accountIdentifier"]!=nil and object["properties"]["abSources"]!=nil and object["properties"]!=nil
+ if object["properties"]!=nil and object["properties"]["abSources"][0]["properties"]["accountIdentifier"]!=nil and object["properties"]["abSources"]!=nil
@client.appleAccountid=object["properties"]["abSources"][0]["properties"]["accountIdentifier"]
else
@client.appleAccountid="NA"
View
16 lib/siriproxy/db_classes.rb
@@ -358,7 +358,7 @@ def fetchResults(stmt)
end
#added stats fixes crash with interval
class Statistics
- attr_accessor :id, :elapsed,:uptime
+ attr_accessor :id, :elapsed,:uptime,:happy_hour_elapsed
def id=(value) # The setter method for @id
@id = value
@@ -367,6 +367,10 @@ def id=(value) # The setter method for @id
def elapsed=(value) # The setter method for @elapsedkeycheck
@elapsed = value
end
+
+ def happy_hour_elapsed=(value) # The setter method for @uptime
+ @happy_hour_elapsed = value
+ end
def uptime=(value) # The setter method for @uptime
@uptime = value
@@ -395,11 +399,10 @@ def getstats()
return result[0]
end
- def savestats(dto)
-
- sql = "UPDATE `stats` SET elapsed_key_check_interval=?,up_time=? WHERE id=1"
+ def savestats(dto)
+ sql = "UPDATE `stats` SET elapsed_key_check_interval=?,up_time=?,happy_hour_elapsed=? WHERE id=1"
st = @my.prepare(sql)
- st.execute(dto.elapsed,dto.uptime)
+ st.execute(dto.elapsed,dto.uptime,dto.happy_hour_elapsed)
st.close
end
@@ -408,8 +411,9 @@ def fetchResults(stmt)
while row = stmt.fetch do
dto = Statistics.new
dto.id = row[0]
- dto.elapsed= row[1]
+ dto.elapsed= row[1]
dto.uptime=row[2]
+ dto.happy_hour_elapsed=row[3]
rows << dto
end
return rows

0 comments on commit 7c33d86

Please sign in to comment.