Implement sending bridgelines to the bridge scanner endpoint and receive whether to use or not the bridge
We're working on a bridge scanner (tpo/network-health/onbasca#130 (closed)) and we have already a branch to test.
It currently accept POST requests via Content-Type multipart/form-data, application/json or application/x-www-form-urlencoded with one several bridgelines at a time. It can easily be changed to accept several.
Examples with curl
:
# The test server url
URL=http://localhost:8000
# multipart/form-data
# replies with code 200
curl -X POST -F "bridgelines=[obfs4 0.0.0.0:00000 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA cert=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA iat-mode=0]" $URL
{'fingerprint': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'valid': True}
# application/x-www-form-urlencoded
# replies with code 200
$CURL -X POST -d "bridgelines=[obfs4 0.0.0.0:00000 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA cert=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA iat-mode=0]" $URL
{'fingerprint': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'valid': True}
# application/json
# replies with code 200
$CURL -X POST -H "Content-Type: application/json" -d '{"bridgelines": ["obfs4 0.0.0.0:00000 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA cert=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA iat-mode=0"}]' $URL
{"bridges": [{"fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "valid": true}]}
# Several bridges
# replies with code 200
$CURL -X POST -H "Content-Type: application/json" -d '{"bridgelines": ["obfs4 0.0.0.0:00000 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA cert=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA iat-mode=0", "obfs4 0.0.0.0:00000 BBB cert=BBB iat-mode=0"]}' $URL
{"bridges": [{"fingerprint": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "valid": true}, {"fingerprint": "BBB", "valid": true}]}
# HTTP GET
# replies with code 403 (Forbidden)
curl $URL
The replies are:
- status code:
- 200: if the request is correct
- 403: a request that is not POST
- 404: a wrong path
- body:
- json: { "fingerprint": , "valid": <bool: whether or not the bridge should be handled> }
It also replies "valid" when it's a new bridge and it still don't have bandwidth measurements.
The reply can also easily be changed to be just a status code that says whether to handle or not the bridge or change the format and/or the keys/values.
Edited by juga