nserver 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/bin/nserver +11 -0
- data/lib/nserver.rb +14 -5
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 1.1.1 /
|
2
|
+
|
3
|
+
* Fixes to incoming IP address checks
|
4
|
+
* Read defaults from config file ($HOME/.nserverrc)
|
5
|
+
* It's a YAML file with (:bind_ip, :allowed_client_ips, and :port as keys)
|
6
|
+
* Don't explode when no 'RNotify' library present, just don't allow a server
|
7
|
+
to be instanciated. This lets the 'nclient' work on any machine.
|
8
|
+
|
9
|
+
|
1
10
|
== 1.1.0 / 2007-11.07
|
2
11
|
|
3
12
|
* Major feature - accept connections from any host
|
data/bin/nserver
CHANGED
@@ -4,11 +4,22 @@ require 'rubygems'
|
|
4
4
|
require 'daemons'
|
5
5
|
require 'nserver'
|
6
6
|
require 'getoptlong'
|
7
|
+
require 'yaml'
|
7
8
|
|
8
9
|
bind_ip = nil
|
9
10
|
allowed_client_ips = nil
|
10
11
|
port = nil
|
11
12
|
|
13
|
+
## Check for config file.
|
14
|
+
config_file = File.join( ENV['HOME'], '.nserverrc' )
|
15
|
+
|
16
|
+
if File.exists?( config_file )
|
17
|
+
config = YAML.load( File.open(config_file, 'r') {|f| f.read } )
|
18
|
+
bind_ip = config[:bind_ip]
|
19
|
+
allowed_client_ips = config[:allowed_client_ips]
|
20
|
+
port = config[:port]
|
21
|
+
end
|
22
|
+
|
12
23
|
opts = GetoptLong.new(
|
13
24
|
['--bind-ip', GetoptLong::REQUIRED_ARGUMENT ],
|
14
25
|
['--allowed-client-ips', GetoptLong::REQUIRED_ARGUMENT ],
|
data/lib/nserver.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'RNotifyx'
|
4
|
+
RNOTIFY_FOUND = true
|
5
|
+
rescue LoadError
|
6
|
+
RNOTIFY_FOUND = false
|
7
|
+
end
|
8
|
+
|
2
9
|
require 'gserver'
|
3
10
|
require 'socket'
|
4
11
|
require 'ipaddr'
|
5
12
|
|
6
13
|
module NServer
|
7
|
-
VERSION = '1.1.
|
14
|
+
VERSION = '1.1.1'
|
8
15
|
class Server < GServer
|
9
|
-
|
10
16
|
# Create a NServer::Server instance
|
11
17
|
#
|
12
18
|
# Options:
|
@@ -28,6 +34,9 @@ module NServer
|
|
28
34
|
# msg_timeout::
|
29
35
|
# Message display timeout. Default is 5000ms (5s).
|
30
36
|
def initialize( opts = {} )
|
37
|
+
unless RNOTIFY_FOUND
|
38
|
+
raise StandardError.new("RNotify library not found.")
|
39
|
+
end
|
31
40
|
opts[:port] ||= 10001
|
32
41
|
opts[:host] ||= "127.0.0.1"
|
33
42
|
|
@@ -86,8 +95,8 @@ module NServer
|
|
86
95
|
|
87
96
|
# Get and add a message to the list. GServer method.
|
88
97
|
def serve(io)
|
89
|
-
unless @allowed_clients.include?(
|
90
|
-
io.puts "#{io.
|
98
|
+
unless @allowed_clients.any? {|allowed| allowed.include?(IPAddr.new(io.peeraddr.last)) }
|
99
|
+
io.puts "#{io.peeraddr.last} is not allowed."
|
91
100
|
return
|
92
101
|
end
|
93
102
|
io.puts("Enter message, terminate with line break.")
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4.5
|
|
3
3
|
specification_version: 2
|
4
4
|
name: nserver
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.1.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 1.1.1
|
7
|
+
date: 2007-11-08 00:00:00 -05:00
|
8
8
|
summary: Notification server for ruby using libnotify
|
9
9
|
require_paths:
|
10
10
|
- lib
|