-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactor of server/annoucne -> announce/announce.go
- Loading branch information
1 parent
bc80fec
commit a879c23
Showing
8 changed files
with
162 additions
and
517 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package server | ||
package announce | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package announce | ||
|
||
import ( | ||
"github.com/jinzhu/gorm" | ||
"gopkg.in/redis.v3" | ||
) | ||
|
||
const ( | ||
RATIOLESS = iota | ||
SEMIRATIOLESS | ||
NORMALRATIO | ||
) | ||
|
||
type AnnounceData struct { | ||
InfoHash string //20 byte sha1 hash | ||
PeerID string //max len 20 | ||
IP string //optional | ||
Event string // TorrentEvent | ||
|
||
Port uint64 // port number the peer is listening | ||
// on | ||
|
||
Uploaded uint64 // base10 ascii amount uploaded so far | ||
Downloaded uint64 // base10 ascii amount downloaded so | ||
// far | ||
|
||
Left uint64 // # of bytes left to download | ||
// (base 10 ascii) | ||
|
||
Numwant uint64 // Number of peers requested by client. | ||
|
||
Compact bool // Bep23 peer list compression | ||
// decision: True -> compress bep23 | ||
|
||
RequestContext requestAppContext // The request-specific connections | ||
} | ||
|
||
// requestAppContext First of all naming things is the hardest part of | ||
// programming real talk. Second of all, this essentially houses | ||
// request-specific data like db connections and in the future the redisClient. | ||
// Things that should persist only within the duration of a request. | ||
type requestAppContext struct { | ||
dbConn *gorm.DB | ||
redisClient *redis.Client // The redis client connection handler to use. | ||
Whitelist bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.