Server for the Bounce file-sharing network. Client is here
- Microsoft WebMatrix
- GitHub for Windows
- Node.js
- MongoDB (set up: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/) (reading about mongo: http://docs.mongodb.org/manual/)
- POSTman
Packages:
Tutorials:
- Control flow: http://howtonode.org/control-flow
- Passing parameters to callbacks: http://stackoverflow.com/questions/939032/jquery-pass-more-parameters-into-callback
- Closures: http://web.archive.org/web/20080209105120/http://blog.morrisjohns.com/javascript_closures_for_dummies
###Keeping track of online users HTTP pings to /pending
###Authentication MAC is the primary key, still not sure how to prevent spoofing of the HTTP post
###Server-initiated transfers, peer-initiated transfers Every client will listen on a port for server commands
###Network protocol HTTP, as that is well-supported by Node and is easily debuggable in the browser and via Fiddler
###Data transfer JSON.
###Encryption over the wire HTTPS, yet to obtain certificate.
###Encryption on disk for friend-files Could use the hash of the file as the encryption key, this would make life very easy as the requesting peer only needs to know the hash - which is anyway the primary key for a file. To be implemented.
###Encryption for standard transfers Don't think this is worth the time and complexity, MITM can simply be prevented by using the comparing against the expected hash
###Local storage Currently a config file, will move to VS-default config soon
###Distribution of network-specific configuration Hardcode the common server into the distributable. Give server address on download web-page.
###Failover/Load sharing Will be implemented later.
###Update mechanism ClickOnce
###GET /pending
Request Body None
Response Body [{'uploader':XYZ, 'type':'indirect'...},]
(apart from everything in pending - this must return IP of uploader as well)
Client Action Repeated every 'x' seconds
Server Action Reset the timeout at which the server will mark the user offline
###GET /search/the+big+bang+theory
Request Body None
Response Body [{'uploader':XYZ, 'mac':'XYZ', 'type':'online', 'hash':XYZ, 'size':1234, ...},]
Client Action When user searches for a file
Server Action Return list of matching files
###GET /key/transferID
Request Body None
Response Body {'key':XYZ}
Client Action When a client recieves a request to serve a file
Server Action Return the key for a transferID
###GET /status
Request Body None
Response Body [{'transferId':XYZ, 'hash':XYZ, 'mac': XYZ, 'sent': 2, 'total': 5},]
Client Action Every x seconds, display on the 'bounces' tab
Server Action Compute which transferIDs have what status
###POST /register
Request Body mac=XYZ, nick=XYZ, space_allocated=265348
Response Body {'status': 'OK', 'text':'xyz'}
Client Action Application start
Server Action Mark user as online and start the timeout
###POST /download
Request Body hash=XYZ, mac=XYZ, type=online
Response Body {'status': 'OK', 'text':'xyz'}
Client Action User click on 'download' or 'bounce' button
Server Action Populate the pending queue appropriately
###POST /sync
Request Body added=[{'name':'file1'...}]
Response Body {'status': 'OK', 'text':'xyz'}
Client Action Client finishes calculating diffs
Server Action Make appropriate changes to file table
###POST /update
Request Body transferID=XYZ, status=canceled/done/hash_mismatch, [newHash=XYZ], [uploader=XYZ]
Response Body {'status': 'OK', 'text':'xyz'}
Client Action Client cancels or completes download
Server Action Modify the pending queue appropriately
###Client initiates download
- User selects a file and selects 'download'
- Client makes request to /download with mac, hash, type
- If the file is 'online', the server creates 1 entry in the pending table from uploader to downloader. Otherwise, it will also create 'x' entries for the user's friends to download the file.
- User downloads file directly, file remains online throughout
- User requests offline file, file is replicated, downloaded from original holder
- User requests offline file, file is replicated, downloaded from friend
- Node is instructed to download file for friend
- Node is instructed to download file for itself
- User changes nick - only on next restart
- Sync is initiated - only on explicit call
- User becomes offline
- Transfer is completed
- Transfer failed
- Friend loses file it has downloaded
- User receives file, and other nodes are still holding file for user
- User never comes online to receive the file
- Transfer is restarted at a given point
- Original holder loses/deletes file
- Transfer is corrupted (direct)
- Server is down
- Unable to conect to TCP node
- Convert a failed direct to an indirect transfer
- Server does not realise that a user has recieved the file (satus should last b/w app restarts)
- Duplicate nicks selected - reject register request
- Hard drive space less-remove pendings.
- Requester recieves file while it is being replicated to other nodes as well
- Tranfer is corrupted for a bounced file - delete the file at the replicated node
- Logging - http://thechangelog.com/post/2844869169/winston-a-multi-transport-async-logging-library-for-node
direct firstleg secondleg delete
done delete all P + F delete P, add new P delete all P + F delete P
canceled delete all P + F delete P delete all P + F