atomic-swap icon indicating copy to clipboard operation
atomic-swap copied to clipboard

ui: make swapd ports configurable

Open noot opened this issue 3 years ago • 2 comments

make swapd http and ws ports configurable instead of hard-coded

noot avatar Jun 07 '22 04:06 noot

Can clarify the issue a little and the desired behavior? It looks like the ports are configurable already:

atomic-swap$ ./swapd --help | grep port
   --rpc-port value                port for the daemon RPC server to run on; default 5001 (default: 0)
   --ws-port value                 port for the daemon RPC websockets server to run on; default 8080 (default: 0)
   --libp2p-port value             libp2p port to listen on (default: 0)

I can see above that there is an issue with how the values are defaulted. Setting the default value correctly in the argument parsing code to the stated (above) value is a trivial change, but it looks like the default value is actually dependent on other flags:

	p = uint16(c.Uint(flagRPCPort))
	switch {
	case p != 0:
		rpcPort = p
	case devXMRTaker:
		rpcPort = defaultXMRTakerRPCPort
	case devXMRMaker:
		rpcPort = defaultXMRMakerRPCPort
	default:
		rpcPort = defaultRPCPort
	}

	wsPort := uint16(c.Uint(flagWSPort))
	switch {
	case wsPort != 0:
	case devXMRTaker:
		wsPort = defaultXMRTakerWSPort
	case devXMRMaker:
		wsPort = defaultXMRMakerWSPort
	default:
		wsPort = defaultWSPort
	}

dimalinux avatar Jun 13 '22 23:06 dimalinux

hey @dimalinux , the issue is referencing the port for the UI only. currently it's hard-coded to send RPC calls to http://localhost:5001, see here: https://github.com/noot/atomic-swap/blob/master/ui/src/utils/rpcApi.ts#L12

the intended behaviour is to have the UI select what port to use based on some env variable, falling back to 5001 if it's not set.

noot avatar Jun 15 '22 01:06 noot