8
_ "net/http/pprof"
9
"os"
10
"sort"
11
- "strings"
11
"sync"
12
13
"gx/ipfs/QmPpRcbNUXauP3zWZ1NJMLWpe4QnmEHrd2ba2D3yqWznw7/go-multiaddr-net"
134
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)").Default(false),
135
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."),
136
cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount). Defaults to config setting."),
138
- cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes").Default(false),
137
+ cmds.BoolOption(unrestrictedApiAccessKwd, "This option has no effect since v0.4.3").Default(false),
138
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)").Default(false),
139
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection").Default(false),
140
cmds.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").Default(false),
363
apiMaddr = apiLis.Multiaddr()
364
fmt.Printf("API server listening on %s\n", apiMaddr)
365
367
- unrestricted, _, err := req.Option(unrestrictedApiAccessKwd).Bool()
368
- if err != nil {
369
- return fmt.Errorf("serveHTTPApi: Option(%s) failed: %s", unrestrictedApiAccessKwd, err), nil
370
- }
371
-
372
- apiGw := corehttp.NewGateway(corehttp.GatewayConfig{
373
- Writable: true,
374
- BlockList: &corehttp.BlockList{
375
- Decider: func(s string) bool {
376
- if unrestricted {
377
- return true
378
- }
379
- // for now, only allow paths in the WebUI path
380
- for _, webuipath := range corehttp.WebUIPaths {
381
- if strings.HasPrefix(s, webuipath) {
382
- return true
383
- }
384
- }
385
- return false
386
- },
387
- },
388
- })
366
var opts = []corehttp.ServeOption{
367
corehttp.MetricsCollectionOption("api"),
368
corehttp.CommandsOption(*req.InvocContext()),
369
corehttp.WebUIOption,
393
- apiGw.ServeOption(),
370
+ corehttp.GatewayOption("/ipfs", "/ipns"),
371
corehttp.VersionOption(),
372
defaultMux("/debug/vars"),
373
defaultMux("/debug/pprof/"),
429
if err != nil {
430
return fmt.Errorf("serveHTTPGateway: req.Option(%s) failed: %s", writableKwd, err), nil
431
}
455
- if !writableOptionFound {
456
- writable = cfg.Gateway.Writable
432
+ if writableOptionFound {
433
+ cfg.Gateway.Writable = writable
434
}
435
436
gwLis, err := manet.Listen(gatewayMaddr)
451
corehttp.CommandsROOption(*req.InvocContext()),
452
corehttp.VersionOption(),
453
corehttp.IPNSHostnameOption(),
477
- corehttp.GatewayOption(writable, cfg.Gateway.PathPrefixes),
454
+ corehttp.GatewayOption("/ipfs", "/ipns"),
455
}
456
457
if len(cfg.Gateway.RootRedirect) > 0 {