Merge pull request #11294 from filecoin-project/phi-connect-listen-not-set
fix: worker: Connect when --listen is not set
This commit is contained in:
commit
d64bc2c9be
@ -627,7 +627,7 @@ var runCmd = &cli.Command{
|
|||||||
Storage: lr,
|
Storage: lr,
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Setting up control endpoint at " + address)
|
log.Info("Setting up control endpoint at " + newAddress)
|
||||||
|
|
||||||
timeout, err := time.ParseDuration(cctx.String("http-server-timeout"))
|
timeout, err := time.ParseDuration(cctx.String("http-server-timeout"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -652,13 +652,13 @@ var runCmd = &cli.Command{
|
|||||||
log.Warn("Graceful shutdown successful")
|
log.Warn("Graceful shutdown successful")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
nl, err := net.Listen("tcp", address)
|
nl, err := net.Listen("tcp", newAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
a, err := net.ResolveTCPAddr("tcp", address)
|
a, err := net.ResolveTCPAddr("tcp", newAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("parsing address: %w", err)
|
return xerrors.Errorf("parsing address: %w", err)
|
||||||
}
|
}
|
||||||
@ -739,7 +739,7 @@ var runCmd = &cli.Command{
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-readyCh:
|
case <-readyCh:
|
||||||
if err := nodeApi.WorkerConnect(ctx, "http://"+address+"/rpc/v0"); err != nil {
|
if err := nodeApi.WorkerConnect(ctx, "http://"+newAddress+"/rpc/v0"); err != nil {
|
||||||
log.Errorf("Registering worker failed: %+v", err)
|
log.Errorf("Registering worker failed: %+v", err)
|
||||||
cancel()
|
cancel()
|
||||||
return
|
return
|
||||||
@ -801,15 +801,13 @@ func extractRoutableIP(timeout time.Duration) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
minerIP, _ := maddr.ValueForProtocol(multiaddr.P_IP6)
|
minerIP, _ := maddr.ValueForProtocol(multiaddr.P_IP6)
|
||||||
|
if minerIP == "" {
|
||||||
|
minerIP, _ = maddr.ValueForProtocol(multiaddr.P_IP4)
|
||||||
|
}
|
||||||
minerPort, _ := maddr.ValueForProtocol(multiaddr.P_TCP)
|
minerPort, _ := maddr.ValueForProtocol(multiaddr.P_TCP)
|
||||||
|
|
||||||
// Check if the IP is IPv6 and format the address appropriately
|
// Format the address appropriately
|
||||||
var addressToDial string
|
addressToDial := net.JoinHostPort(minerIP, minerPort)
|
||||||
if ip := net.ParseIP(minerIP); ip.To4() == nil && ip.To16() != nil {
|
|
||||||
addressToDial = "[" + minerIP + "]:" + minerPort
|
|
||||||
} else {
|
|
||||||
addressToDial = minerIP + ":" + minerPort
|
|
||||||
}
|
|
||||||
|
|
||||||
conn, err := net.DialTimeout("tcp", addressToDial, timeout)
|
conn, err := net.DialTimeout("tcp", addressToDial, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user