From 93321ab3ad307ea3348bce82d75c81226699b9e7 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Mon, 6 Nov 2017 00:59:42 +0100 Subject: [PATCH] [TASK] Add editorconfig & format code (#94) --- .editorconfig | 17 ++++++++++ contrib/yanic-remove-node | 4 +-- respond/respond.go | 1 - runtime/testdata/node1.json | 66 ++++++++++++++++++++--------------- runtime/testdata/node2.json | 47 +++++++++++++------------ runtime/testdata/node3.json | 59 ++++++++++++++++++-------------- runtime/testdata/node4.json | 52 ++++++++++++++++------------ runtime/testdata/nodes.json | 68 ++++++++++++++++++++----------------- 8 files changed, 184 insertions(+), 130 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..29261ad --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +; http://editorconfig.org/ + +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true + +[*.go] +indent_style = tab +indent_size = 4 + +[*.{json,yml}] +indent_style = space +indent_size = 2 diff --git a/contrib/yanic-remove-node b/contrib/yanic-remove-node index 8953837..517ee20 100755 --- a/contrib/yanic-remove-node +++ b/contrib/yanic-remove-node @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -import json import argparse +import json import sys @@ -18,6 +18,7 @@ def main(states, nodeid): with open(states, 'w') as handle: json.dump(data, handle) + if __name__ == '__main__': parser = argparse.ArgumentParser() @@ -29,4 +30,3 @@ if __name__ == '__main__': args = parser.parse_args() main(args.states, args.nodeid) - diff --git a/respond/respond.go b/respond/respond.go index 4ad3aa2..068a6d6 100644 --- a/respond/respond.go +++ b/respond/respond.go @@ -8,7 +8,6 @@ import ( var multiCastGroup = net.ParseIP("ff02:0:0:0:0:0:2:1001") const ( - // default udp port used by announced port = 1001 diff --git a/runtime/testdata/node1.json b/runtime/testdata/node1.json index eea2d3b..76ef542 100644 --- a/runtime/testdata/node1.json +++ b/runtime/testdata/node1.json @@ -1,30 +1,42 @@ { - "nodeinfo":{ - "node_id":"node1.json", - "network":{ - "mac": "a", - "mesh":{ - "bat0":{ - "interfaces":{ - "wireless":["a"], - "other":["a2"] - } - } - } - } - }, - "neighbours":{ - "batadv":{ - "a":{ - "neighbours":{ - "b":{"tq":150,"lastseen":0.42}, - "c":{"tq":250,"lastseen":0.42} - } - } - }, - "lldp":{ - "a2": {"c2": {}} - } - } + "nodeinfo": { + "node_id": "node1.json", + "network": { + "mac": "a", + "mesh": { + "bat0": { + "interfaces": { + "wireless": [ + "a" + ], + "other": [ + "a2" + ] + } + } + } + } + }, + "neighbours": { + "batadv": { + "a": { + "neighbours": { + "b": { + "tq": 150, + "lastseen": 0.42 + }, + "c": { + "tq": 250, + "lastseen": 0.42 + } + } + } + }, + "lldp": { + "a2": { + "c2": {} + } + } + } } diff --git a/runtime/testdata/node2.json b/runtime/testdata/node2.json index 141039a..600ceb2 100644 --- a/runtime/testdata/node2.json +++ b/runtime/testdata/node2.json @@ -1,24 +1,29 @@ { - "nodeinfo":{ - "node_id":"node2.json", - "network":{ - "mesh":{ - "bat0":{ - "interfaces":{ - "wireless":["b"] - } - } - } - } - }, - "neighbours":{ - "batadv":{ - "b":{ - "neighbours":{ - "a":{"tq":250,"lastseen":0.42} - } - } - } - } + "nodeinfo": { + "node_id": "node2.json", + "network": { + "mesh": { + "bat0": { + "interfaces": { + "wireless": [ + "b" + ] + } + } + } + } + }, + "neighbours": { + "batadv": { + "b": { + "neighbours": { + "a": { + "tq": 250, + "lastseen": 0.42 + } + } + } + } + } } diff --git a/runtime/testdata/node3.json b/runtime/testdata/node3.json index 0a24051..13c579f 100644 --- a/runtime/testdata/node3.json +++ b/runtime/testdata/node3.json @@ -1,28 +1,37 @@ { - "nodeinfo":{ - "node_id":"node3.json", - "network":{ - "mesh":{ - "bat0":{ - "interfaces":{ - "wireless":["c"], - "other":["c2"] - } - } - } - } - }, - "neighbours":{ - "batadv":{ - "c":{ - "neighbours":{ - "a":{"tq":200,"lastseen":0.42} - } - } - }, - "lldp":{ - "c2": {"a2": {}} - } - } + "nodeinfo": { + "node_id": "node3.json", + "network": { + "mesh": { + "bat0": { + "interfaces": { + "wireless": [ + "c" + ], + "other": [ + "c2" + ] + } + } + } + } + }, + "neighbours": { + "batadv": { + "c": { + "neighbours": { + "a": { + "tq": 200, + "lastseen": 0.42 + } + } + } + }, + "lldp": { + "c2": { + "a2": {} + } + } + } } diff --git a/runtime/testdata/node4.json b/runtime/testdata/node4.json index 0176389..3b73c10 100644 --- a/runtime/testdata/node4.json +++ b/runtime/testdata/node4.json @@ -1,25 +1,33 @@ { - "nodeinfo":{ - "node_id":"node4.json", - "network":{ - "mesh":{ - "bat0":{ - "interfaces":{ - "wireless":["unneed","unneed2"], - "tunnel":["d"] - } - } - } - } - }, - "neighbours":{ - "batadv":{ - "d":{ - "neighbours":{ - "a":{"tq":200,"lastseen":0.42} - } - } - } - } + "nodeinfo": { + "node_id": "node4.json", + "network": { + "mesh": { + "bat0": { + "interfaces": { + "wireless": [ + "unneed", + "unneed2" + ], + "tunnel": [ + "d" + ] + } + } + } + } + }, + "neighbours": { + "batadv": { + "d": { + "neighbours": { + "a": { + "tq": 200, + "lastseen": 0.42 + } + } + } + } + } } diff --git a/runtime/testdata/nodes.json b/runtime/testdata/nodes.json index 1cd51f2..e9b542d 100644 --- a/runtime/testdata/nodes.json +++ b/runtime/testdata/nodes.json @@ -1,34 +1,38 @@ { - "nodes": { - "f4f26dd7a30a": { - "firstseen": "2017-03-10T12:12:01", - "nodeinfo": { - "node_id":"f4f26dd7a30a", - "network":{ - "mesh":{ - "bat0":{ - "interfaces":{ - "wireless":["a"] - } - } - } - } - } - }, - "f4f26dd7a30b": { - "firstseen": "2016-03-10T12:12:01", - "nodeinfo": { - "node_id":"f4f26dd7a30b", - "network":{ - "mesh":{ - "bat0":{ - "interfaces":{ - "wireless":["a"] - } - } - } - } - } - } - } + "nodes": { + "f4f26dd7a30a": { + "firstseen": "2017-03-10T12:12:01", + "nodeinfo": { + "node_id": "f4f26dd7a30a", + "network": { + "mesh": { + "bat0": { + "interfaces": { + "wireless": [ + "a" + ] + } + } + } + } + } + }, + "f4f26dd7a30b": { + "firstseen": "2016-03-10T12:12:01", + "nodeinfo": { + "node_id": "f4f26dd7a30b", + "network": { + "mesh": { + "bat0": { + "interfaces": { + "wireless": [ + "a" + ] + } + } + } + } + } + } + } }