5
0
mirror of https://github.com/cwinfo/hyperboria-peers.git synced 2024-11-09 15:30:26 +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":
{
"password":"public_access",
"publicKey":"ff3yru5mxjf13c4kpw1nys4j6pz9q191cds85srmsnxnql47q5p0.k",
"user":"weuxel",
"contact": "hype@smash-net.org"
}
{
"128.199.246.213:64022":{
"contact":"hype@smash-net.org",
"password":"public_access",
"publicKey":"ff3yru5mxjf13c4kpw1nys4j6pz9q191cds85srmsnxnql47q5p0.k",
"user":"weuxel"
}
}

View File

@ -1,8 +1,9 @@
"176.9.105.201:4464": {
"login":"public",
"password":"ir88xwtel72fen3ch7aug603s26nu3a",
"publicKey":"yrgb0xwfr9pz8swvnv6m9by8zw7v7uxxhl07qz318cjuvfgs1fc0.k",
"contact":"webmaster@jazzanet.com",
"peerName":"jazzanet"
{
"176.9.105.201:4464":{
"contact":"webmaster@jazzanet.com",
"login":"public",
"password":"ir88xwtel72fen3ch7aug603s26nu3a",
"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.$",
"publicKey":"ny90t66vzmfywtcs3rs8fwwhzfk7frgvdfxutqxslk18jrj82hx0.k",
"contact":"mixxit@hyperboria.name",
"peerName":"icfreedom.net"
{
"hub.icfreedom.net:64749":{
"contact":"mixxit@hyperboria.name",
"password":")h.1-_[?bFW!0H:O{=a>H+9&17q]*j1~Bjzk{e.$",
"peerName":"icfreedom.net",
"publicKey":"ny90t66vzmfywtcs3rs8fwwhzfk7frgvdfxutqxslk18jrj82hx0.k"
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,12 @@
"173.62.245.186:55249": {
"peerName": "NAT",
"ipv6": "fcda:9958:9093:49f2:2677:6df6:2a5a:b01d",
"country": "us",
"website": "https://github.com/NateBrune",
"contact": "natebrune@gmail.com",
"gpg": "C95CE6BC6735BAD7",
"publicKey": "vgxqyputh4ldhxktg9msmr61pw938l0ymhkmryljsyzvmr0dtwy0.k",
"password": "Public"
{
"173.62.245.186:55249":{
"contact":"natebrune@gmail.com",
"country":"us",
"gpg":"C95CE6BC6735BAD7",
"ipv6":"fcda:9958:9093:49f2:2677:6df6:2a5a:b01d",
"password":"Public",
"peerName":"NAT",
"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
* 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 must contain the necessary fields:
+ 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",
"password":"nq1uhmf06k8c5594jqmpgy26813b81s",
"publicKey":"ssxlh80x0bqjfrnbkm1801xsxyd8zd45jkwn1zhlnccqj4hdqun0.k",
"peerName":"your-name-goes-here"
{
"192.168.1.5:10326": {
"login": "default-login",
"password":"nq1uhmf06k8c5594jqmpgy26813b81s",
"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
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)
try:
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()
warning = False
for host in hosts:
for field in REQUIRED_FIELDS:
if field not in peers[host]:
@ -29,29 +40,22 @@ def validate(path):
return False
for field in RECOMMENDED_FIELDS:
if field not in peers[host]:
warning = True
print(" %sHost %s is missing the recommended field %s%s" % (YELLOW, host,
field, END))
if warning:
print(" %sSuccess, but missing recommended fields%s" % (YELLOW, END))
else:
print(" %sSuccess!%s" % (YELLOW, END))
return True
if not formatting:
return False
except ValueError:
print(" %sInvalid JSON!%s" % (RED, END))
return False
if __name__ == "__main__":
success = True
if len(sys.argv) == 2:
success = validate(sys.argv[1])
else:
for directory, subdirs, files in os.walk('.'):
if len(files) > 0:
for directory, subdirs, files in os.walk('.'):
if len(files) > 0:
if directory != '.' and not directory.startswith('./.git'):
for f in files:
if f.endswith('.k'):
result = validate("%s/%s" % (directory, f))
if not result:
success = False
result = validate("%s/%s" % (directory, f))
if not result:
success = False
if not success:
sys.exit(1)