mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 22:58:49 +00:00
chore: update version to 0.53.6 in Makefile and add IP extraction utility for multiaddr in setup.go
This commit is contained in:
parent
042e516b8c
commit
5b05f52162
2
Makefile
2
Makefile
@ -21,7 +21,7 @@ test-e2e:
|
||||
|
||||
.PHONY: build clean test run-node run-node2 run-node3 run-example deps tidy fmt vet lint clear-ports
|
||||
|
||||
VERSION := 0.53.5
|
||||
VERSION := 0.53.6
|
||||
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.date=$(DATE)'
|
||||
|
||||
@ -134,6 +134,37 @@ func HandleSetupCommand(args []string) {
|
||||
fmt.Printf(" Proxy endpoint: POST http://localhost:6001/v1/proxy/anon\n\n")
|
||||
}
|
||||
|
||||
// extractIPFromMultiaddr extracts the IP address from a multiaddr string
|
||||
// Format: /ip4/51.83.128.181/tcp/4001/p2p/12D3KooW...
|
||||
func extractIPFromMultiaddr(multiaddr string) string {
|
||||
if multiaddr == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Split by "/ip4/"
|
||||
parts := strings.Split(multiaddr, "/ip4/")
|
||||
if len(parts) < 2 {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Get the part after "/ip4/"
|
||||
ipPart := parts[1]
|
||||
// Extract IP until the next "/"
|
||||
ipEnd := strings.Index(ipPart, "/")
|
||||
if ipEnd == -1 {
|
||||
// If no "/" found, the whole string might be the IP
|
||||
return strings.TrimSpace(ipPart)
|
||||
}
|
||||
|
||||
ip := strings.TrimSpace(ipPart[:ipEnd])
|
||||
// Validate it looks like an IP address
|
||||
if net.ParseIP(ip) != nil {
|
||||
return ip
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// getVPSIPv4Address gets the primary IPv4 address of the VPS
|
||||
func getVPSIPv4Address() (string, error) {
|
||||
interfaces, err := net.Interfaces()
|
||||
@ -904,7 +935,22 @@ func generateConfigsInteractive(force bool) {
|
||||
if isBootstrap {
|
||||
nodeConfig = generateBootstrapConfigWithIP("bootstrap", "", 4001, 5001, 7001, vpsIP)
|
||||
} else {
|
||||
nodeConfig = generateNodeConfigWithIP("node", "", 4001, 5001, 7001, "", bootstrapPeers, vpsIP)
|
||||
// Extract IP from bootstrap peer multiaddr for rqlite_join_address
|
||||
// Use first bootstrap peer if multiple provided
|
||||
var joinAddr string
|
||||
if bootstrapPeers != "" {
|
||||
firstPeer := strings.Split(bootstrapPeers, ",")[0]
|
||||
firstPeer = strings.TrimSpace(firstPeer)
|
||||
extractedIP := extractIPFromMultiaddr(firstPeer)
|
||||
if extractedIP != "" {
|
||||
joinAddr = fmt.Sprintf("%s:7001", extractedIP)
|
||||
} else {
|
||||
joinAddr = "localhost:7001"
|
||||
}
|
||||
} else {
|
||||
joinAddr = "localhost:7001"
|
||||
}
|
||||
nodeConfig = generateNodeConfigWithIP("node", "", 4001, 5001, 7001, joinAddr, bootstrapPeers, vpsIP)
|
||||
}
|
||||
|
||||
// Write node config
|
||||
@ -1019,7 +1065,7 @@ func generateNodeConfigWithIP(name, id string, listenPort, rqliteHTTPPort, rqlit
|
||||
}
|
||||
|
||||
if joinAddr == "" {
|
||||
joinAddr = "localhost:5001"
|
||||
joinAddr = "localhost:7001"
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`node:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user