File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,14 @@ func newHeyFil(o ...Option) (*heyFil, error) {
38
38
if err != nil {
39
39
return nil , err
40
40
}
41
+ c := jsonrpc .NewClient (opts .api )
42
+ if opts .apiToken != "" {
43
+ c = jsonrpc .NewClientWithOpts (opts .api , & jsonrpc.RPCClientOpts {CustomHeaders : map [string ]string {"Authorization" : "Bearer " + opts .apiToken }})
44
+
45
+ }
41
46
hf := & heyFil {
42
47
options : opts ,
43
- c : jsonrpc . NewClient ( opts . api ) ,
48
+ c : c ,
44
49
targets : make (map [string ]* Target ),
45
50
toCheck : make (chan * Target , 100 ),
46
51
checked : make (chan * Target , 100 ),
Original file line number Diff line number Diff line change @@ -13,12 +13,14 @@ func main() {
13
13
httpIndexerEndpoint := flag .String ("httpIndexerEndpoint" , "https://cid.contact" , "The HTTP IPNI endpoint to which announcements are made." )
14
14
maxConcurrentChecks := flag .Int ("maxConcurrentChecks" , 10 , "The maximum number of concurrent checks." )
15
15
storePath := flag .String ("storePath" , "" , "The directory to use for storing the discovered SP information." )
16
+ token := flag .String ("token" , "" , "A bearer token to pass for auth to the filecoin api endpoint." )
16
17
flag .Parse ()
17
18
18
19
hf , err := newHeyFil (
19
20
WithHttpIndexerEndpoint (* httpIndexerEndpoint ),
20
21
WithMaxConcurrentChecks (* maxConcurrentChecks ),
21
22
WithStorePath (* storePath ),
23
+ WithFileCoinAPIToken (* token ),
22
24
)
23
25
if err != nil {
24
26
panic (err )
Original file line number Diff line number Diff line change 14
14
Option func (* options ) error
15
15
options struct {
16
16
api string
17
+ apiToken string
17
18
h host.Host
18
19
topic string
19
20
headProtocolPattern * regexp.Regexp
36
37
func newOptions (o ... Option ) (* options , error ) {
37
38
opts := & options {
38
39
api : `https://api.node.glif.io` ,
40
+ apiToken : `` ,
39
41
marketDealsS3Snapshot : `https://marketdeals.s3.amazonaws.com/StateMarketDeals.json.zst` ,
40
42
marketDealsFilTools : `https://filecoin.tools/api/deals/list` ,
41
43
httpIndexerEndpoint : `https://cid.contact` ,
@@ -74,6 +76,13 @@ func WithFileCoinAPI(url string) Option {
74
76
}
75
77
}
76
78
79
+ func WithFileCoinAPIToken (token string ) Option {
80
+ return func (o * options ) error {
81
+ o .apiToken = token
82
+ return nil
83
+ }
84
+ }
85
+
77
86
// WithHost specifies the libp2p host.
78
87
// If unset, a new host with random identity is instantiated.
79
88
func WithHost (h host.Host ) Option {
You can’t perform that action at this time.
0 commit comments