/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2013-12-15 22:21:28 UTC
  • mto: (237.7.272 trunk)
  • mto: This revision was merged to the branch mainline in revision 307.
  • Revision ID: teddy@recompile.se-20131215222128-k6f1wbl6lv4v0kd8
Suppress spurious warnings when needed.

* plugin-runner.c (main): Suppress warning by -Wsign-conversion
                          generated by FD_SET, FD_CLR and FD_ISSET in
                          GNU libc before version 2.16.
* plugins.d/mandos-client.c (start_mandos_communication): Suppress
  warning by -Wstrict-aliasing generated by IN6_IS_ADDR_LINKLOCAL.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
server_path = "/"
67
67
server_interface = domain + ".Mandos"
68
68
client_interface = domain + ".Mandos.Client"
69
 
version = "1.6.0"
 
69
version = "1.6.2"
70
70
 
71
71
def timedelta_to_milliseconds(td):
72
72
    """Convert a datetime.timedelta object to milliseconds"""
85
85
 
86
86
 
87
87
def rfc3339_duration_to_delta(duration):
88
 
    """Parse a RFC 3339 "duration" and return a datetime.timedelta
 
88
    """Parse an RFC 3339 "duration" and return a datetime.timedelta
89
89
    
90
90
    >>> rfc3339_duration_to_delta("P7D")
91
91
    datetime.timedelta(7)
103
103
    datetime.timedelta(1, 200)
104
104
    """
105
105
    
106
 
    # Parsing a RFC 3339 duration with regular expressions is not
 
106
    # Parsing an RFC 3339 duration with regular expressions is not
107
107
    # possible - there would have to be multiple places for the same
108
 
    # values, like seconds.  This, while more esoteric, is cleaner
109
 
    # without depending on a parsing library.  If Python had a
 
108
    # values, like seconds.  The current code, while more esoteric, is
 
109
    # cleaner without depending on a parsing library.  If Python had a
110
110
    # built-in library for parsing we would use it, but we'd like to
111
111
    # avoid excessive use of external libraries.
112
112
    
199
199
    >>> string_to_delta("5m 30s")
200
200
    datetime.timedelta(0, 330)
201
201
    """
202
 
    value = datetime.timedelta(0)
203
 
    regexp = re.compile(r"(\d+)([dsmhw]?)")
204
202
    
205
203
    try:
206
204
        return rfc3339_duration_to_delta(interval)
207
205
    except ValueError:
208
206
        pass
209
207
    
 
208
    value = datetime.timedelta(0)
 
209
    regexp = re.compile(r"(\d+)([dsmhw]?)")
 
210
    
210
211
    for num, suffix in regexp.findall(interval):
211
212
        if suffix == "d":
212
213
            value += datetime.timedelta(int(num))