mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-26 17:38:14 -07:00
(untested) refactor code
This commit is contained in:
@@ -160,7 +160,7 @@ func (h *hook) HandleAnnounce(ctx context.Context, req *bittorrent.AnnounceReque
|
||||
err = ErrInvalidJWT
|
||||
} else {
|
||||
var claimIH bittorrent.InfoHash
|
||||
if claimIH, err = bittorrent.NewInfoHash(claims.InfoHash); err != nil {
|
||||
if claimIH, err = bittorrent.NewInfoHashString(claims.InfoHash); err != nil {
|
||||
logger.Info().
|
||||
Err(err).
|
||||
Object("source", req.RequestPeer).
|
||||
@@ -206,7 +206,7 @@ func (h *hook) HandleScrape(ctx context.Context, req *bittorrent.ScrapeRequest,
|
||||
} else {
|
||||
var claimIHs bittorrent.InfoHashes
|
||||
for _, s := range claims.InfoHashes {
|
||||
if providedIh, err := bittorrent.NewInfoHash(s); err == nil {
|
||||
if providedIh, err := bittorrent.NewInfoHashString(s); err == nil {
|
||||
claimIHs = append(claimIHs, providedIh)
|
||||
} else {
|
||||
logger.Info().
|
||||
|
||||
@@ -56,7 +56,7 @@ func build(conf conf.MapConfig, st storage.DataStorage) (container.Container, er
|
||||
if len(c.HashList) > 0 {
|
||||
init := make([]storage.Entry, 0, len(c.HashList))
|
||||
for _, hashString := range c.HashList {
|
||||
ih, err := bittorrent.NewInfoHash(hashString)
|
||||
ih, err := bittorrent.NewInfoHashString(hashString)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("whitelist : %s : %w", hashString, err)
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestHandleAnnounce(t *testing.T) {
|
||||
req := &bittorrent.AnnounceRequest{}
|
||||
resp := &bittorrent.AnnounceResponse{}
|
||||
|
||||
hashinfo, err := bittorrent.NewInfoHash(tt.ih)
|
||||
hashinfo, err := bittorrent.NewInfoHashString(tt.ih)
|
||||
require.Nil(t, err)
|
||||
|
||||
req.InfoHash = hashinfo
|
||||
|
||||
Reference in New Issue
Block a user