19
commands "github.com/ipfs/go-ipfs/core/commands"
20
corehttp "github.com/ipfs/go-ipfs/core/corehttp"
21
"github.com/ipfs/go-ipfs/core/corerouting"
22
+ conn "github.com/ipfs/go-ipfs/p2p/net/conn"
23
peer "github.com/ipfs/go-ipfs/p2p/peer"
24
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"
25
util "github.com/ipfs/go-ipfs/util"
33
writableKwd = "writable"
34
ipfsMountKwd = "mount-ipfs"
35
ipnsMountKwd = "mount-ipns"
35
- unrestrictedApiAccess = "unrestricted-api"
36
+ unrestrictedApiAccessKwd = "unrestricted-api"
37
+ unencryptTransportKwd = "disable-transport-encryption"
38
// apiAddrKwd = "address-api"
39
// swarmAddrKwd = "address-swarm"
40
)
78
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
79
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount)"),
80
cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount)"),
79
- cmds.BoolOption(unrestrictedApiAccess, "Allow API access to unlisted hashes"),
81
+ cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
82
+ cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
83
84
// TODO: add way to override addresses. tricky part: updating the config if also --init.
85
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
113
}
114
}()
115
116
+ // check transport encryption flag.
117
+ unencrypted, _, _ := req.Option(unencryptTransportKwd).Bool()
118
+ if unencrypted {
119
+ log.Warningf(`Running with --%s: All connections are UNENCRYPTED.
120
+ You will not be able to connect to regular encrypted networks.`, unencryptTransportKwd)
121
+ conn.EncryptConnections = false
122
+ }
123
+
124
// first, whether user has provided the initialization flag. we may be
125
// running in an uninitialized state.
126
initialize, _, err := req.Option(initOptionKwd).Bool()
270
apiMaddr = apiLis.Multiaddr()
271
fmt.Printf("API server listening on %s\n", apiMaddr)
272
262
- unrestricted, _, err := req.Option(unrestrictedApiAccess).Bool()
273
+ unrestricted, _, err := req.Option(unrestrictedApiAccessKwd).Bool()
274
if err != nil {
264
- return fmt.Errorf("serveHTTPApi: Option(%s) failed: %s", unrestrictedApiAccess, err), nil
275
+ return fmt.Errorf("serveHTTPApi: Option(%s) failed: %s", unrestrictedApiAccessKwd, err), nil
276
}
277
278
apiGw := corehttp.NewGateway(corehttp.GatewayConfig{