neomsg 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/clientlib.rb +78 -0
- data/lib/neomsg.rb +2 -0
- data/lib/server_config.rb +16 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 188085dd40b2c0d07a7e5f7a06b48421d1e820fb
|
4
|
+
data.tar.gz: a5276fc35541291ab93b7e39a80e1b57b334dc4f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82838cb69e94dff0b02174da8331f424bb0306ee58fb38970edf5e13d5b36344b5eb2d53a09190d6f0ac923b2dd3846f2df9a9cad198760af557ec9c60c99ad6
|
7
|
+
data.tar.gz: 52a1cd811b27f4887022959714c068e0b0935efceda6155ce1a35b94da64e9b455cdb9f1925014bcac88a56811ef232cc06af3e66c97ef6899bee188958b4706
|
data/lib/clientlib.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class AMXClient
|
5
|
+
def sock
|
6
|
+
@sock ||= TCPSocket.open(@hostname, 2026)
|
7
|
+
end
|
8
|
+
|
9
|
+
def sock= (value)
|
10
|
+
@sock = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize (hostname, username, password = '', keepalive = false)
|
14
|
+
@hostname = hostname
|
15
|
+
if !password.empty? then
|
16
|
+
@remember_token = auth username, password
|
17
|
+
else
|
18
|
+
@remember_token = username
|
19
|
+
end
|
20
|
+
@keepalive = keepalive
|
21
|
+
exit_real unless @keepalive or password.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
def list (limit = '*', namespace = '/')
|
25
|
+
auth @remember_token unless @keepalive
|
26
|
+
value = JSON.parse(send_message "LIST #{limit} #{namespace}")
|
27
|
+
exit_real unless @keepalive
|
28
|
+
return value
|
29
|
+
end
|
30
|
+
|
31
|
+
def send (message)
|
32
|
+
auth @remember_token unless @keepalive
|
33
|
+
value = send_message 'SEND', message.to_json
|
34
|
+
exit_real unless @keepalive
|
35
|
+
return value
|
36
|
+
end
|
37
|
+
|
38
|
+
def fetch (message_id)
|
39
|
+
auth @remember_token unless @keepalive
|
40
|
+
value = JSON.parse(send_message "FETCH #{message_id}")
|
41
|
+
exit_real unless @keepalive
|
42
|
+
return value
|
43
|
+
end
|
44
|
+
|
45
|
+
def exit ()
|
46
|
+
return unless @keepalive
|
47
|
+
exit_real
|
48
|
+
end
|
49
|
+
|
50
|
+
#PROPERTIES
|
51
|
+
attr_reader :remember_token
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def auth (username, password = '')
|
56
|
+
token = send_message "AUTH #{username} #{password}"
|
57
|
+
return token.chop
|
58
|
+
end
|
59
|
+
|
60
|
+
def exit_real
|
61
|
+
send_message 'EXIT'
|
62
|
+
sock.close
|
63
|
+
self.sock = nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def send_message (message, body = nil)
|
67
|
+
sock.puts message
|
68
|
+
if (body) then
|
69
|
+
sock.puts (body)
|
70
|
+
sock.puts '.'
|
71
|
+
end
|
72
|
+
response = ''
|
73
|
+
while line = sock.gets and line.chop != '.' do # Read lines from the socket
|
74
|
+
response += line
|
75
|
+
end
|
76
|
+
return response
|
77
|
+
end
|
78
|
+
end
|
data/lib/neomsg.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Antimail
|
4
|
+
def self.config
|
5
|
+
@config ||= begin
|
6
|
+
if File.exist?('/etc/antimail.yml') then
|
7
|
+
YAML.load_file('/etc/antimail.yml')
|
8
|
+
elsif File.exist?('antimail.yml') then
|
9
|
+
YAML.load_file('antimail.yml')
|
10
|
+
else
|
11
|
+
puts 'No config file. Using defaults'
|
12
|
+
{'domains' => [], 'stdport' => 2026, 'myport' => 2026, 'localregistrations' => false}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neomsg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Parks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Contains a simple clientlib and server config reader
|
14
|
+
email: bparks@synapsesoftware.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/neomsg.rb
|
20
|
+
- lib/clientlib.rb
|
21
|
+
- lib/server_config.rb
|
22
|
+
homepage: http://neomsg.com/
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.0.6
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Neomsg client and utility library
|
46
|
+
test_files: []
|