5
0
mirror of https://github.com/cwinfo/hyperboria-peers.git synced 2024-11-09 16:40:27 +00:00

Wrap JSON dicts in {} like the rest of the world

Update tests.py, README.md to reflect this
tests.py also now checks exact formatting. Must be four spaces indented, etc. Also has --clean option to do it for you
This commit is contained in:
Finn 2016-03-13 10:46:55 -07:00
parent 8a63833742
commit 52240ec1e9
18 changed files with 163 additions and 134 deletions

View File

@ -1,8 +1,8 @@
"128.199.246.213:64022": {
{ "128.199.246.213:64022":{
"password":"public_access", "contact":"hype@smash-net.org",
"publicKey":"ff3yru5mxjf13c4kpw1nys4j6pz9q191cds85srmsnxnql47q5p0.k", "password":"public_access",
"user":"weuxel", "publicKey":"ff3yru5mxjf13c4kpw1nys4j6pz9q191cds85srmsnxnql47q5p0.k",
"contact": "hype@smash-net.org" "user":"weuxel"
} }
}

View File

@ -1,8 +1,9 @@
"176.9.105.201:4464": { {
"login":"public", "176.9.105.201:4464":{
"password":"ir88xwtel72fen3ch7aug603s26nu3a", "contact":"webmaster@jazzanet.com",
"publicKey":"yrgb0xwfr9pz8swvnv6m9by8zw7v7uxxhl07qz318cjuvfgs1fc0.k", "login":"public",
"contact":"webmaster@jazzanet.com", "password":"ir88xwtel72fen3ch7aug603s26nu3a",
"peerName":"jazzanet" "peerName":"jazzanet",
"publicKey":"yrgb0xwfr9pz8swvnv6m9by8zw7v7uxxhl07qz318cjuvfgs1fc0.k"
}
} }

View File

@ -1,6 +1,8 @@
"hub.icfreedom.net:64749": { {
"password":")h.1-_[?bFW!0H:O{=a>H+9&17q]*j1~Bjzk{e.$", "hub.icfreedom.net:64749":{
"publicKey":"ny90t66vzmfywtcs3rs8fwwhzfk7frgvdfxutqxslk18jrj82hx0.k", "contact":"mixxit@hyperboria.name",
"contact":"mixxit@hyperboria.name", "password":")h.1-_[?bFW!0H:O{=a>H+9&17q]*j1~Bjzk{e.$",
"peerName":"icfreedom.net" "peerName":"icfreedom.net",
"publicKey":"ny90t66vzmfywtcs3rs8fwwhzfk7frgvdfxutqxslk18jrj82hx0.k"
}
} }

View File

@ -1,6 +1,8 @@
"51.254.25.16:1132": { {
"password":"thah9aePha1Vusha6ovhpublic", "51.254.25.16:1132":{
"publicKey":"kw0vfw3tmb6u6p21z5jmmymdlumwknlg3x8muk5mcw66tdpqlw30.k", "contact":"me@magik6k.net",
"contact":"me@magik6k.net", "password":"thah9aePha1Vusha6ovhpublic",
"peerName":"Magik6k-sbg1" "peerName":"Magik6k-sbg1",
"publicKey":"kw0vfw3tmb6u6p21z5jmmymdlumwknlg3x8muk5mcw66tdpqlw30.k"
}
} }

View File

@ -1,7 +1,9 @@
"rethymno-meshnet.tk:38295": { {
"login": "default-login", "rethymno-meshnet.tk:38295":{
"password":"wgs9k7n7j5yh0kx7kyl5m7cpp71ls4y", "contact":"kaotisk@irc.fc00.io",
"publicKey":"wb3pt76psbt28mt9t2wzyudyh9zkqwq9z3jqb3t06y53g6f5qzh0.k", "login":"default-login",
"peerName":"gr-rethymno-meshnet", "password":"wgs9k7n7j5yh0kx7kyl5m7cpp71ls4y",
"contact":"kaotisk@irc.fc00.io" "peerName":"gr-rethymno-meshnet",
"publicKey":"wb3pt76psbt28mt9t2wzyudyh9zkqwq9z3jqb3t06y53g6f5qzh0.k"
}
} }

View File

@ -1,6 +1,8 @@
"188.166.3.174:4841":{ {
"password":"public-20150903-6pb6aEKDDKVr9zsBJIyDUYfrXYzQv1", "188.166.3.174:4841":{
"publicKey":"s680fh7g69ww3y9cmrxt910u5hvrwrmcnln1sz6mq1jk5mquq8k0.k", "contact":"oniichan@mrowr.me",
"user":"katt", "password":"public-20150903-6pb6aEKDDKVr9zsBJIyDUYfrXYzQv1",
"contact":"oniichan@mrowr.me" "publicKey":"s680fh7g69ww3y9cmrxt910u5hvrwrmcnln1sz6mq1jk5mquq8k0.k",
"user":"katt"
}
} }

View File

@ -1,7 +1,8 @@
"188.226.183.183:43328": { {
"password":"public_access", "188.226.183.183:43328":{
"publicKey":"1y1jmqrw4r31jlp6yqmq30067rcp0tsgsdm3cs4k8l33pyfhpwn0.k", "contact":"hype@smash-net.org",
"user":"weuxel", "password":"public_access",
"contact": "hype@smash-net.org" "publicKey":"1y1jmqrw4r31jlp6yqmq30067rcp0tsgsdm3cs4k8l33pyfhpwn0.k",
"user":"weuxel"
}
} }

View File

@ -1,7 +1,9 @@
"185.125.216.67:24297": { {
"login": "default-login", "185.125.216.67:24297":{
"password":"c5q2j63x5nkmt2yg2vjmlnfuh1jnjjf", "contact":"contact@bunjlabs.com",
"publicKey":"5dkw4x4tczb6x164qklggbgfy35cs5uxjl6tyyu4slu7nm4062q0.k", "login":"default-login",
"peerName":"h.bunjlabs.com", "password":"c5q2j63x5nkmt2yg2vjmlnfuh1jnjjf",
"contact":"contact@bunjlabs.com" "peerName":"h.bunjlabs.com",
"publicKey":"5dkw4x4tczb6x164qklggbgfy35cs5uxjl6tyyu4slu7nm4062q0.k"
}
} }

View File

@ -1,8 +1,10 @@
"leeloo.kyriasis.com:65149": { {
"login": "public-peer", "leeloo.kyriasis.com:65149":{
"password": "3fPUWtOiQfKRupM7y9zIAdZhbLiaumoCutVJx9Igw/bZerEhbOfDdEFxJZojcnw0jMcOR/dZvFElmqI6", "contact":"johannes@kyriasis.com",
"publicKey": "4dhktl7cmwp0f1grjuhn1m5gg3tllx1mccssmgq2s6xqltzpu620.k", "gpg":"50FB9B273A9D0BB5",
"contact": "johannes@kyriasis.com", "login":"public-peer",
"gpg": "50FB9B273A9D0BB5", "password":"3fPUWtOiQfKRupM7y9zIAdZhbLiaumoCutVJx9Igw/bZerEhbOfDdEFxJZojcnw0jMcOR/dZvFElmqI6",
"peerName": "leeloo.kyriasis.com" "peerName":"leeloo.kyriasis.com",
"publicKey":"4dhktl7cmwp0f1grjuhn1m5gg3tllx1mccssmgq2s6xqltzpu620.k"
}
} }

View File

@ -1,6 +1,8 @@
"139.162.219.143:2331":{ {
"password":"CJ36KhxxO7nmfCy1kVB27rhwlWgnG95i", "139.162.219.143:2331":{
"publicKey":"bddc5j6sc45hlrdnccu120zwnmm2z0qlbfkxn9n8xbs0vqgx9fh0.k", "contact":"ansuz@transitiontech.ca",
"user":"ansuz", "password":"CJ36KhxxO7nmfCy1kVB27rhwlWgnG95i",
"contact":"ansuz@transitiontech.ca" "publicKey":"bddc5j6sc45hlrdnccu120zwnmm2z0qlbfkxn9n8xbs0vqgx9fh0.k",
"user":"ansuz"
}
} }

View File

@ -1,7 +1,8 @@
"142.4.212.42:1441": { {
"password":"201510034nnmj97n54nby3797xt227lr0538ty4", "142.4.212.42:1441":{
"publicKey":"9uf222z95bxd7sgvncdtzr2skgjp7vdr472f7u74pc0zxu0pjxl0.k", "contact":"derp@projectmeshnet.org",
"user": "derp", "password":"201510034nnmj97n54nby3797xt227lr0538ty4",
"contact": "derp@projectmeshnet.org" "publicKey":"9uf222z95bxd7sgvncdtzr2skgjp7vdr472f7u74pc0zxu0pjxl0.k",
"user":"derp"
}
} }

View File

@ -1,7 +1,9 @@
"192.169.7.142:14400":{ {
"contact":"Igel@hyperboria.ca", "192.169.7.142:14400":{
"gpg":"A84DFFE62B451511", "contact":"Igel@hyperboria.ca",
"peerName":"igel-losangeles", "gpg":"A84DFFE62B451511",
"password":"alfa-charlie-alfa-bravo", "password":"alfa-charlie-alfa-bravo",
"publicKey":"mh9m0411cfcg7xhdc8n6ckls1tjgnvvbdfzdgqf5196tfkw96rr0.k" "peerName":"igel-losangeles",
"publicKey":"mh9m0411cfcg7xhdc8n6ckls1tjgnvvbdfzdgqf5196tfkw96rr0.k"
}
} }

View File

@ -1,16 +1,18 @@
"107.170.57.34:63472": { {
"login": "public-peer", "107.170.57.34:63472":{
"password":"ppm6j89mgvss7uvtntcd9scy6166mwb", "contact":"code@ventricle.us",
"publicKey":"1xkf13m9r9h502yuffsq1cg13s5648bpxrtf2c3xcq1mlj893s90.k", "location":"digitalocean nyc2",
"peerName":"Jacob Henner", "login":"public-peer",
"contact":"code@ventricle.us", "password":"ppm6j89mgvss7uvtntcd9scy6166mwb",
"location":"digitalocean nyc2" "peerName":"Jacob Henner",
}, "publicKey":"1xkf13m9r9h502yuffsq1cg13s5648bpxrtf2c3xcq1mlj893s90.k"
"[2604:a880:0:1010::f:4001]:63472": { },
"login": "public-peer", "[2604:a880:0:1010::f:4001]:63472":{
"password":"ppm6j89mgvss7uvtntcd9scy6166mwb", "contact":"code@ventricle.us",
"publicKey":"1xkf13m9r9h502yuffsq1cg13s5648bpxrtf2c3xcq1mlj893s90.k", "location":"digitalocean nyc2",
"peerName":"Jacob Henner", "login":"public-peer",
"contact":"code@ventricle.us", "password":"ppm6j89mgvss7uvtntcd9scy6166mwb",
"location":"digitalocean nyc2" "peerName":"Jacob Henner",
"publicKey":"1xkf13m9r9h502yuffsq1cg13s5648bpxrtf2c3xcq1mlj893s90.k"
}
} }

View File

@ -1,7 +1,8 @@
"192.241.171.154:62718": { {
"password":"public_access", "192.241.171.154:62718":{
"publicKey":"q5nhj9kg6ddmk571jb259mct2ljd10z9xvyf05y3hu66wk4qnk20.k", "contact":"hype@smash-net.org",
"user":"weuxel", "password":"public_access",
"contact": "hype@smash-net.org" "publicKey":"q5nhj9kg6ddmk571jb259mct2ljd10z9xvyf05y3hu66wk4qnk20.k",
"user":"weuxel"
}
} }

View File

@ -1,7 +1,9 @@
"192.198.82.242:27823":{ {
"contact":"Igel@hyperboria.ca", "192.198.82.242:27823":{
"gpg":"A84DFFE62B451511", "contact":"Igel@hyperboria.ca",
"peerName":"igel-northcarolina", "gpg":"A84DFFE62B451511",
"password":"alfa-charlie-alfa-bravo", "password":"alfa-charlie-alfa-bravo",
"publicKey":"1nctdb89gtfrlnu71zyq97n14frl1r4z0ylwzc8vn7kpvrzu4yl0.k" "peerName":"igel-northcarolina",
"publicKey":"1nctdb89gtfrlnu71zyq97n14frl1r4z0ylwzc8vn7kpvrzu4yl0.k"
}
} }

View File

@ -1,10 +1,12 @@
"173.62.245.186:55249": { {
"peerName": "NAT", "173.62.245.186:55249":{
"ipv6": "fcda:9958:9093:49f2:2677:6df6:2a5a:b01d", "contact":"natebrune@gmail.com",
"country": "us", "country":"us",
"website": "https://github.com/NateBrune", "gpg":"C95CE6BC6735BAD7",
"contact": "natebrune@gmail.com", "ipv6":"fcda:9958:9093:49f2:2677:6df6:2a5a:b01d",
"gpg": "C95CE6BC6735BAD7", "password":"Public",
"publicKey": "vgxqyputh4ldhxktg9msmr61pw938l0ymhkmryljsyzvmr0dtwy0.k", "peerName":"NAT",
"password": "Public" "publicKey":"vgxqyputh4ldhxktg9msmr61pw938l0ymhkmryljsyzvmr0dtwy0.k",
"website":"https://github.com/NateBrune"
}
} }

View File

@ -45,7 +45,7 @@ By following this scheme, we make it possible for users to programmatically find
## JSON formatting ## JSON formatting
* Your credentials must be [valid JSON](http://jsonlint.com/) when inserted into a block of curly braces `{}` * Your credentials must be [valid JSON](http://jsonlint.com/).
* They should be small enough so as to be inserted into a `cjdroute.conf` **as is** without triggering the [connectTo-overflow bug](https://github.com/hyperboria/docs/blob/master/bugs/connectTo-overflow.md). * They should be small enough so as to be inserted into a `cjdroute.conf` **as is** without triggering the [connectTo-overflow bug](https://github.com/hyperboria/docs/blob/master/bugs/connectTo-overflow.md).
* They must contain the necessary fields: * They must contain the necessary fields:
+ ip/port + ip/port
@ -56,17 +56,16 @@ By following this scheme, we make it possible for users to programmatically find
``` ```
"192.168.1.5:10326": { {
"login": "default-login", "192.168.1.5:10326": {
"password":"nq1uhmf06k8c5594jqmpgy26813b81s", "login": "default-login",
"publicKey":"ssxlh80x0bqjfrnbkm1801xsxyd8zd45jkwn1zhlnccqj4hdqun0.k", "password":"nq1uhmf06k8c5594jqmpgy26813b81s",
"peerName":"your-name-goes-here" "publicKey":"ssxlh80x0bqjfrnbkm1801xsxyd8zd45jkwn1zhlnccqj4hdqun0.k",
"peerName":"your-name-goes-here"
}
} }
``` ```
> Note: the snippet above is **not valid json**. It would need to be wrapped in an additional block of curly braces `{ }`
## Naming your entry ## Naming your entry
You can name your file whatever you want, but for simplicity's sake, avoid characters which will need to be escaped at the command line. You can name your file whatever you want, but for simplicity's sake, avoid characters which will need to be escaped at the command line.

View File

@ -18,9 +18,20 @@ def validate(path):
print("Validating %s" % path) print("Validating %s" % path)
try: try:
creds = open(path).read() creds = open(path).read()
peers = json.loads("{%s}" % creds) peers = json.loads(creds)
# Check formatting
pretty = json.dumps(peers, sort_keys=True, indent=4, separators=(',', ':'))
pretty = "%s\n" % pretty
formatting = True
if pretty != creds:
if "--clean" in sys.argv:
with open(path, 'w') as outfile:
outfile.write(pretty)
print(" %sJSON in %s has been fixed.%s" % (YELLOW, path, END))
else:
print(" %sJSON in %s is NOT properly formatted.%s" % (YELLOW, path, END))
formatting = False
hosts = peers.keys() hosts = peers.keys()
warning = False
for host in hosts: for host in hosts:
for field in REQUIRED_FIELDS: for field in REQUIRED_FIELDS:
if field not in peers[host]: if field not in peers[host]:
@ -29,29 +40,22 @@ def validate(path):
return False return False
for field in RECOMMENDED_FIELDS: for field in RECOMMENDED_FIELDS:
if field not in peers[host]: if field not in peers[host]:
warning = True
print(" %sHost %s is missing the recommended field %s%s" % (YELLOW, host, print(" %sHost %s is missing the recommended field %s%s" % (YELLOW, host,
field, END)) field, END))
if warning: if not formatting:
print(" %sSuccess, but missing recommended fields%s" % (YELLOW, END)) return False
else:
print(" %sSuccess!%s" % (YELLOW, END))
return True
except ValueError: except ValueError:
print(" %sInvalid JSON!%s" % (RED, END)) print(" %sInvalid JSON!%s" % (RED, END))
return False return False
if __name__ == "__main__": if __name__ == "__main__":
success = True success = True
if len(sys.argv) == 2: for directory, subdirs, files in os.walk('.'):
success = validate(sys.argv[1]) if len(files) > 0:
else: if directory != '.' and not directory.startswith('./.git'):
for directory, subdirs, files in os.walk('.'):
if len(files) > 0:
for f in files: for f in files:
if f.endswith('.k'): result = validate("%s/%s" % (directory, f))
result = validate("%s/%s" % (directory, f)) if not result:
if not result: success = False
success = False
if not success: if not success:
sys.exit(1) sys.exit(1)