diff options
author | Maran <maran.hidskes@gmail.com> | 2017-01-05 18:57:41 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-01-05 18:57:41 +0800 |
commit | f087633efdf42f23ada99a5750af30320a7905a8 (patch) | |
tree | b905d58611b342650657c20810aa9cc1d44b73e2 /cmd | |
parent | bbce726c8a85e72141d9d7e690711738c09ede3b (diff) | |
download | dexon-f087633efdf42f23ada99a5750af30320a7905a8.tar dexon-f087633efdf42f23ada99a5750af30320a7905a8.tar.gz dexon-f087633efdf42f23ada99a5750af30320a7905a8.tar.bz2 dexon-f087633efdf42f23ada99a5750af30320a7905a8.tar.lz dexon-f087633efdf42f23ada99a5750af30320a7905a8.tar.xz dexon-f087633efdf42f23ada99a5750af30320a7905a8.tar.zst dexon-f087633efdf42f23ada99a5750af30320a7905a8.zip |
swarm/api/http: add support for CORS headers (#3388)
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/swarm/main.go | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index 04930760e..954ad3b13 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -82,15 +82,15 @@ var ( Name: "bzzconfig", Usage: "Swarm config file path (datadir/bzz)", } - SwarmSwapEnabled = cli.BoolFlag{ + SwarmSwapEnabledFlag = cli.BoolFlag{ Name: "swap", Usage: "Swarm SWAP enabled (default false)", } - SwarmSyncEnabled = cli.BoolTFlag{ + SwarmSyncEnabledFlag = cli.BoolTFlag{ Name: "sync", Usage: "Swarm Syncing enabled (default true)", } - EthAPI = cli.StringFlag{ + EthAPIFlag = cli.StringFlag{ Name: "ethapi", Usage: "URL of the Ethereum API provider", Value: node.DefaultIPCEndpoint("geth"), @@ -112,6 +112,10 @@ var ( Name: "defaultpath", Usage: "path to file served for empty url path (none)", } + CorsStringFlag = cli.StringFlag{ + Name: "corsdomain", + Usage: "Domain on which to send Access-Control-Allow-Origin header (multiple domains can be supplied seperated by a ',')", + } ) func init() { @@ -171,10 +175,11 @@ Prints the swarm hash of file or directory. utils.IPCApiFlag, utils.IPCPathFlag, // bzzd-specific flags - EthAPI, + CorsStringFlag, + EthAPIFlag, SwarmConfigPathFlag, - SwarmSwapEnabled, - SwarmSyncEnabled, + SwarmSwapEnabledFlag, + SwarmSyncEnabledFlag, SwarmPortFlag, SwarmAccountFlag, SwarmNetworkIdFlag, @@ -252,10 +257,11 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) { if len(bzzport) > 0 { bzzconfig.Port = bzzport } - swapEnabled := ctx.GlobalBool(SwarmSwapEnabled.Name) - syncEnabled := ctx.GlobalBoolT(SwarmSyncEnabled.Name) + swapEnabled := ctx.GlobalBool(SwarmSwapEnabledFlag.Name) + syncEnabled := ctx.GlobalBoolT(SwarmSyncEnabledFlag.Name) - ethapi := ctx.GlobalString(EthAPI.Name) + ethapi := ctx.GlobalString(EthAPIFlag.Name) + cors := ctx.GlobalString(CorsStringFlag.Name) boot := func(ctx *node.ServiceContext) (node.Service, error) { var client *ethclient.Client @@ -265,7 +271,7 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) { utils.Fatalf("Can't connect: %v", err) } } - return swarm.NewSwarm(ctx, client, bzzconfig, swapEnabled, syncEnabled) + return swarm.NewSwarm(ctx, client, bzzconfig, swapEnabled, syncEnabled, cors) } if err := stack.Register(boot); err != nil { utils.Fatalf("Failed to register the Swarm service: %v", err) |