Aim to set up a tracker server for sobani service and clients
Clone to your instance
git clone https://github.com/nekomeowww/sobani-tracker.git
Install dependencies
cd sobani-tracker
yarn install
Start server
yarn run test
Announce action relates to the first connection from peer to server, within this action, a client send three parameters to tracker server in order to record and make the share action possible.
If sending is successful, an announceReceived object will be returned.
Field | Type | Required | Description |
---|---|---|---|
action | string | yes | Fixed value, "announce" |
Expected response from server:
{
"action": "announceReceived",
"data": {
"shareId": "1AbhoECj"
}
}
Pulse action meant to make maintaining the connection and the sharing session valid and possible by rapidly sending a packet to server to report the Alive
state of the client. By doing this, server will store the session and shareId while the clients are alive, if a client stopped to send a packet, server will delete the related shareId and multiaddr it announced before. (Default expiration time will be 5 minutes)
If sending is successful, a pulseReceived object is returned.
Field | Type | Required | Description |
---|---|---|---|
action | string | yes | Fixed value, "pulse" |
override | boolean | optional | If set to true , the following data in this body object will be updated to server, default is false |
ip | string | optional | Based on override param, server will update the ip address according to the given one |
port | string | optional | Based on override param, server will update the port mapping according to the given one |
multiaddr | string | optional | Based on override param, server will update the port mapping according to the given one |
shareId | boolean | optional | If set to true , server will regenerate a shareId to client |
Expected response from server:
{
"action": "pulseReceived",
"data": {
"status": "0",
"overriden": "false"
}
}
Push action tells the server the unique shareId of the target client the peers shared. Tracker server respond with the IP:Port
back to the requesting client, so on, the client can try to establish the connection between.
If sending is successful, a pushReceived is returned.
Field | Type | Required | Description |
---|---|---|---|
action | string | yes | Fixed value, "push" |
shareId | string | yes | The unique shareId from other client, this shareId can be get through announce method or pulse method with override set to true |
Expected response from server:
{
"action": "pushReceived",
"data": {
"peeraddr": "1.2.3.4:23333"
}
}
Field | Type | Required | Description |
---|---|---|---|
action | string | yes | Fixed value, "announceReceived" |
data | dict | yes |
Field | Type | Required | Description |
---|---|---|---|
shareId | string | yes | shareId generated by server side |
Field | Type | Required | Description |
---|---|---|---|
action | string | yes | Fixed value, "pulseReceived" |
data | dict | yes |
Field | Type | Required | Description |
---|---|---|---|
status | string | yes | 0 if pulse sent successful |
overriden | string | Yes | true if overriden data was successfully set |
Field | Type | Required | Description |
---|---|---|---|
action | string | yes | Fixed value, "pushReceived" |
data | dict | yes |
Field | Type | Required | Description |
---|---|---|---|
peeraddr | string | yes | IP:Port |