racoon 0.6.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,5 +8,5 @@ require 'racoon/worker'
8
8
  require 'racoon/firehose'
9
9
 
10
10
  module Racoon
11
- VERSION = "0.6.0"
11
+ VERSION = "1.0.0"
12
12
  end
@@ -36,6 +36,14 @@ module Racoon
36
36
  @sock = nil
37
37
  end
38
38
 
39
+ def read
40
+ errors ||= []
41
+ while error = @ssl.read(6)
42
+ errors << parse_tuple(error)
43
+ end
44
+ errors
45
+ end
46
+
39
47
  def write(bytes)
40
48
  if host.include? "sandbox"
41
49
  notification = Notification.parse(bytes)
@@ -47,6 +55,13 @@ module Racoon
47
55
  def connected?
48
56
  @ssl
49
57
  end
58
+
59
+ private
60
+
61
+ def parse_tuple(data)
62
+ packet = data.unpack("c1c1N1")
63
+ { :command => packet[0], :status => packet[1], :identifier => packet[2] }
64
+ end
50
65
  end
51
66
  end
52
67
  end
@@ -32,7 +32,7 @@ module Racoon
32
32
 
33
33
  private
34
34
 
35
- def apns(project, bytes, retries=2)
35
+ def apns(project, bytes, retries=2, &error_callback)
36
36
  uri = "gateway.#{project[:sandbox] ? 'sandbox.' : ''}push.apple.com"
37
37
  hash = Digest::SHA1.hexdigest("#{project[:name]}-#{project[:certificate]}")
38
38
 
@@ -44,6 +44,7 @@ module Racoon
44
44
 
45
45
  connection.connect! unless connection.connected?
46
46
  connection.write(bytes)
47
+ connection.read.each(&error_callback) unless error_callback.nil?
47
48
  rescue Errno::EPIPE, OpenSSL::SSL::SSLError, Errno::ECONNRESET
48
49
  connection.disconnect!
49
50
  retry if (retries -= 1) > 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: racoon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yajl-ruby
17
- requirement: &70102154456440 !ruby/object:Gem::Requirement
17
+ requirement: &70296020668120 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.7.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70102154456440
25
+ version_requirements: *70296020668120
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: beanstalk-client
28
- requirement: &70102154455980 !ruby/object:Gem::Requirement
28
+ requirement: &70296020667620 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70102154455980
36
+ version_requirements: *70296020667620
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: ffi-rzmq
39
- requirement: &70102154455520 !ruby/object:Gem::Requirement
39
+ requirement: &70296020667140 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.8.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70102154455520
47
+ version_requirements: *70296020667140
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
- requirement: &70102154455060 !ruby/object:Gem::Requirement
50
+ requirement: &70296020666680 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70102154455060
58
+ version_requirements: *70296020666680
59
59
  description: A distributed Apple Push Notification Service (APNs) provider developed
60
60
  for hosting multiple projects.
61
61
  email: jeremy.tregunna@me.com
@@ -67,8 +67,6 @@ extensions: []
67
67
  extra_rdoc_files:
68
68
  - README.mdown
69
69
  files:
70
- - bin/apnserverd.fedora.init
71
- - bin/apnserverd.ubuntu.init
72
70
  - bin/racoon-firehose
73
71
  - bin/racoon-send
74
72
  - bin/racoon-worker
@@ -1,71 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # /etc/rc.d/init.d/apnserverd
4
- # apnserverd This shell script takes care of starting and stopping
5
- # the APN Server Proxy
6
- #
7
- # chkconfig: 345 20 80
8
- # Author: Ben Poweski bpoweski@gmail.com
9
- #
10
- # Source function library.
11
- . /etc/init.d/functions
12
-
13
- NAME=apnserverd
14
- APNSERVERD=/usr/bin/$NAME
15
- PIDFILE=/var/run/$NAME.pid
16
-
17
- if [ -f /etc/sysconfig/$NAME ]; then
18
- . /etc/sysconfig/$NAME
19
- fi
20
-
21
-
22
- start() {
23
- echo -n "Starting APN Server: "
24
- if [ -f $PIDFILE ]; then
25
- PID=`cat $PIDFILE`
26
- echo $NAME already running: $PID
27
- exit 2;
28
- elif [ -f $PIDFILE ]; then
29
- PID=`cat $PIDFILE`
30
- echo $NAME already running: $PID
31
- exit 2;
32
- else
33
- daemon $APNSERVERD $OPTIONS
34
- RETVAL=$?
35
- echo
36
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$NAME
37
- return $RETVAL
38
- fi
39
-
40
- }
41
-
42
- stop() {
43
- echo -n "Shutting down APN Server: "
44
- echo
45
- kill `cat $PIDFILE`
46
- echo
47
- rm -f /var/lock/subsys/$NAME
48
- rm -f $PIDFILE
49
- return 0
50
- }
51
-
52
- case "$1" in
53
- start)
54
- start
55
- ;;
56
- stop)
57
- stop
58
- ;;
59
- status)
60
- status $NAME
61
- ;;
62
- restart)
63
- stop
64
- start
65
- ;;
66
- *)
67
- echo "Usage: {start|stop|status|restart}"
68
- exit 1
69
- ;;
70
- esac
71
- exit $?
@@ -1,116 +0,0 @@
1
- #! /bin/sh
2
- ### BEGIN INIT INFO
3
- # Provides: apnserverd
4
- # Required-Start: $remote_fs
5
- # Required-Stop: $remote_fs
6
- # Default-Start: 2 3 4 5
7
- # Default-Stop: 0 1 6
8
- # Short-Description: Apple Push Notification Server Daemon
9
- ### END INIT INFO
10
-
11
- # Author: Philipp Schmid <philipp.schmid@openresearch.com>
12
-
13
- PATH=/sbin:/usr/sbin:/bin:/usr/bin
14
- DESC="Apple Push Notification Server Daemon"
15
- NAME=apnserverd
16
- DAEMON=/usr/bin/$NAME
17
- PEMPATH=""
18
- DAEMON_ARGS="--daemon --pem $PEMPATH"
19
- PIDFILE=/var/run/$NAME.pid
20
- SCRIPTNAME=/etc/init.d/$NAME
21
-
22
- # Exit if the package is not installed
23
- [ -x "$DAEMON" ] || exit 0
24
-
25
- # Load the VERBOSE setting and other rcS variables
26
- . /lib/init/vars.sh
27
-
28
- # Define LSB log_* functions.
29
- # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
30
- . /lib/lsb/init-functions
31
-
32
- #
33
- # Function that starts the daemon/service
34
- #
35
- do_start()
36
- {
37
- # Return
38
- # 0 if daemon has been started
39
- # 1 if daemon was already running
40
- # 2 if daemon could not be started
41
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
42
- || return 1
43
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
44
- $DAEMON_ARGS \
45
- || return 2
46
- }
47
-
48
- #
49
- # Function that stops the daemon/service
50
- #
51
- do_stop()
52
- {
53
- # Return
54
- # 0 if daemon has been stopped
55
- # 1 if daemon was already stopped
56
- # 2 if daemon could not be stopped
57
- # other if a failure occurred
58
- start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
59
- RETVAL="$?"
60
- [ "$RETVAL" = 2 ] && return 2
61
- # Wait for children to finish too if this is a daemon that forks
62
- # and if the daemon is only ever run from this initscript.
63
- # If the above conditions are not satisfied then add some other code
64
- # that waits for the process to drop all resources that could be
65
- # needed by services started subsequently. A last resort is to
66
- # sleep for some time.
67
- start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
68
- [ "$?" = 2 ] && return 2
69
- # Many daemons don't delete their pidfiles when they exit.
70
- rm -f $PIDFILE
71
- return "$RETVAL"
72
- }
73
-
74
-
75
- case "$1" in
76
- start)
77
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
78
- do_start
79
- case "$?" in
80
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
81
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
82
- esac
83
- ;;
84
- stop)
85
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
86
- do_stop
87
- case "$?" in
88
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
89
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
90
- esac
91
- ;;
92
- restart|force-reload)
93
- log_daemon_msg "Restarting $DESC" "$NAME"
94
- do_stop
95
- case "$?" in
96
- 0|1)
97
- do_start
98
- case "$?" in
99
- 0) log_end_msg 0 ;;
100
- 1) log_end_msg 1 ;; # Old process is still running
101
- *) log_end_msg 1 ;; # Failed to start
102
- esac
103
- ;;
104
- *)
105
- # Failed to stop
106
- log_end_msg 1
107
- ;;
108
- esac
109
- ;;
110
- *)
111
- echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
112
- exit 3
113
- ;;
114
- esac
115
-
116
- :