icwot 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -2
- data/bin/icwot +4 -4
- data/lib/icwot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de385402f1226360527fe24047fdcdfa43e07a73
|
4
|
+
data.tar.gz: adc408b40362093aa3e0f84dca6cf197d220b25f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baaa83c802c66bae4cfd6f7c8634fe33f90612fa1b2d867d29aad973f9edc17b512562450b9d61b48dbec75d748fd910ed21f5ddc763924167db6823617a37ee
|
7
|
+
data.tar.gz: d464c39e9cab1905e59f923be7f5874a2960b264e014899530ffa34d67b4e22a57338cadb1ddb5a8eac8a626be3fc8441e31891d1cf675375df20f32db5a8b59
|
data/README.md
CHANGED
@@ -20,9 +20,40 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
In a terminal run:
|
22
22
|
|
23
|
-
$ icwot
|
23
|
+
$ icwot <HOST>
|
24
24
|
|
25
|
-
It will
|
25
|
+
It will:
|
26
|
+
|
27
|
+
1. Register to the specified host by ` POST ` method and sending in the body information(s).
|
28
|
+
Currently, the body information is the uri needed for the host to send informations to the client.
|
29
|
+
2. Start a [sinatra](http://www.sinatrarb.com) server on default port 4567. Logging messages will be saved by default to :
|
30
|
+
your-home-directory/log/icwot-msg.log
|
31
|
+
|
32
|
+
By default, the header of the ` POST ` method will have these values:
|
33
|
+
|
34
|
+
content-type=application/json
|
35
|
+
accept=application/json
|
36
|
+
|
37
|
+
You can change it by specifying the ` -c your-content-type ` and ` -a your-accept ` in the command line call. Actaually, it can encode the body in two different maners:
|
38
|
+
|
39
|
+
* json, the body will typically be like this : ` {"uri": "your-ip-address:port-where-sinatra-is running"} `
|
40
|
+
* xml, the body will typically be like this:
|
41
|
+
` <client xmlns=\"http://jaxb.xwot.first.ch.unifr.diuf\">
|
42
|
+
<uri>your-ip-address:port-where-sinatra-is running</uri>
|
43
|
+
</client> `
|
44
|
+
The xml is not as the best for the moment. We recommand to use json.
|
45
|
+
|
46
|
+
### There are several options for the commande line:
|
47
|
+
|
48
|
+
icwot <host>
|
49
|
+
-h print help
|
50
|
+
-l the host is localhost
|
51
|
+
-c the content-type value for the header application/json by default
|
52
|
+
-a the accept value for the header text/plain by default
|
53
|
+
-p the port where to run the server
|
54
|
+
-t the protocol to use http:// by default
|
55
|
+
-l where to save the log. By default your-home-directory/log/icwot-{port}-msg.log
|
56
|
+
host is where to register for the service.
|
26
57
|
|
27
58
|
## Contributing
|
28
59
|
|
data/bin/icwot
CHANGED
@@ -40,9 +40,10 @@ class Client
|
|
40
40
|
{uri: uri}
|
41
41
|
end
|
42
42
|
|
43
|
+
# inspired by http://stackoverflow.com/questions/11897269/get-own-ip-address
|
43
44
|
def get_ip
|
44
45
|
ip=Socket.ip_address_list.detect{|intf| intf.ipv4_private?}
|
45
|
-
ip.ip_address
|
46
|
+
ip ? ip.ip_address : '127.0.0.1'
|
46
47
|
end
|
47
48
|
|
48
49
|
def to_s
|
@@ -75,7 +76,7 @@ ARGV.each_with_index do |a, index|
|
|
75
76
|
-a the accept value for the header text/plain by default
|
76
77
|
-p the port where to run the server
|
77
78
|
-t the protocol to use http:// by default
|
78
|
-
-l where to save the log
|
79
|
+
-l where to save the log. By default your-home-directory/log/icwot-{port}-msg.log
|
79
80
|
host is where to register for the service.
|
80
81
|
'
|
81
82
|
exit 0
|
@@ -114,10 +115,9 @@ if is_port_open?('localhost', port)
|
|
114
115
|
end
|
115
116
|
|
116
117
|
client = Client.new
|
117
|
-
client.uri = "http://#{client.get_ip
|
118
|
+
client.uri = "http://#{client.get_ip}:#{port}/"
|
118
119
|
client.content_type = produces
|
119
120
|
|
120
|
-
|
121
121
|
response = RestClient.post protocol+host, client.to_s, accept: accept, content_type: produces
|
122
122
|
|
123
123
|
unless response.code == 200
|
data/lib/icwot/version.rb
CHANGED